summaryrefslogtreecommitdiff
path: root/deps/npm/test/tap
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/test/tap')
-rw-r--r--deps/npm/test/tap/00-check-mock-dep.js17
-rw-r--r--deps/npm/test/tap/00-config-setup.js85
-rw-r--r--deps/npm/test/tap/00-verify-bundle-deps.js16
-rw-r--r--deps/npm/test/tap/00-verify-ls-ok.js27
-rw-r--r--deps/npm/test/tap/00-verify-no-scoped.js30
-rw-r--r--deps/npm/test/tap/404-parent.js54
-rw-r--r--deps/npm/test/tap/404-private-registry-scoped.js36
-rw-r--r--deps/npm/test/tap/404-private-registry.js37
-rw-r--r--deps/npm/test/tap/404.js72
-rw-r--r--deps/npm/test/tap/access.js587
-rw-r--r--deps/npm/test/tap/add-named-update-protocol-port.js113
-rw-r--r--deps/npm/test/tap/add-remote-git-file.js85
-rw-r--r--deps/npm/test/tap/add-remote-git-shrinkwrap.js137
-rw-r--r--deps/npm/test/tap/add-remote-git-submodule.js142
-rw-r--r--deps/npm/test/tap/add-remote-git.js104
-rw-r--r--deps/npm/test/tap/adduser-always-auth.js266
-rw-r--r--deps/npm/test/tap/adduser-legacy-auth.js102
-rw-r--r--deps/npm/test/tap/adduser-oauth.js82
-rw-r--r--deps/npm/test/tap/adduser-saml.js82
-rw-r--r--deps/npm/test/tap/aliases.js268
-rw-r--r--deps/npm/test/tap/all-package-metadata-cache-stream-unit.js112
-rw-r--r--deps/npm/test/tap/all-package-metadata-entry-stream-unit.js190
-rw-r--r--deps/npm/test/tap/all-package-metadata-update-stream-unit.js176
-rw-r--r--deps/npm/test/tap/all-package-metadata-write-stream-unit.js125
-rw-r--r--deps/npm/test/tap/all-package-metadata.js212
-rw-r--r--deps/npm/test/tap/anon-cli-metrics.js151
-rw-r--r--deps/npm/test/tap/audit-fix.js829
-rw-r--r--deps/npm/test/tap/audit.js578
-rw-r--r--deps/npm/test/tap/auto-prune.js147
-rw-r--r--deps/npm/test/tap/bearer-token-check.js109
-rw-r--r--deps/npm/test/tap/bin-overwriting.js108
-rw-r--r--deps/npm/test/tap/bin.js23
-rw-r--r--deps/npm/test/tap/bitbucket-https-url-with-creds-package.js70
-rw-r--r--deps/npm/test/tap/bitbucket-https-url-with-creds.js69
-rw-r--r--deps/npm/test/tap/bitbucket-shortcut-package.js73
-rw-r--r--deps/npm/test/tap/bitbucket-shortcut.js70
-rw-r--r--deps/npm/test/tap/bugs.js172
-rw-r--r--deps/npm/test/tap/build-already-built.js60
-rw-r--r--deps/npm/test/tap/builtin-config.js136
-rw-r--r--deps/npm/test/tap/bundled-dependencies-nonarray.js71
-rw-r--r--deps/npm/test/tap/bundled-dependencies.js109
-rw-r--r--deps/npm/test/tap/bundled-no-add-to-move.js50
-rw-r--r--deps/npm/test/tap/bundled-transitive-deps.js108
-rw-r--r--deps/npm/test/tap/cache-add-unpublished.js37
-rw-r--r--deps/npm/test/tap/cache-eacces-error-message.js35
-rw-r--r--deps/npm/test/tap/cache-shasum-fork.js92
-rw-r--r--deps/npm/test/tap/check-cpu-reqs.js50
-rw-r--r--deps/npm/test/tap/check-engine-reqs.js63
-rw-r--r--deps/npm/test/tap/check-install-self.js56
-rw-r--r--deps/npm/test/tap/check-os-reqs.js50
-rw-r--r--deps/npm/test/tap/check-permissions.js95
-rw-r--r--deps/npm/test/tap/ci-header.js139
-rw-r--r--deps/npm/test/tap/ci-permissions.js53
-rw-r--r--deps/npm/test/tap/ci-with-local-dependency.js82
-rw-r--r--deps/npm/test/tap/ci.js344
-rw-r--r--deps/npm/test/tap/circular-dep.js93
-rw-r--r--deps/npm/test/tap/config-basic.js79
-rw-r--r--deps/npm/test/tap/config-builtin.js66
-rw-r--r--deps/npm/test/tap/config-certfile.js19
-rw-r--r--deps/npm/test/tap/config-credentials.js350
-rw-r--r--deps/npm/test/tap/config-edit.js74
-rw-r--r--deps/npm/test/tap/config-envReplace.js58
-rw-r--r--deps/npm/test/tap/config-list.js69
-rw-r--r--deps/npm/test/tap/config-malformed.js14
-rw-r--r--deps/npm/test/tap/config-meta.js137
-rw-r--r--deps/npm/test/tap/config-new-cafile.js37
-rw-r--r--deps/npm/test/tap/config-private.js83
-rw-r--r--deps/npm/test/tap/config-project.js66
-rw-r--r--deps/npm/test/tap/config-save.js91
-rw-r--r--deps/npm/test/tap/correct-mkdir.js167
-rw-r--r--deps/npm/test/tap/cruft-test.js43
-rw-r--r--deps/npm/test/tap/debug-logs.js97
-rw-r--r--deps/npm/test/tap/dedupe-git-semver.js138
-rw-r--r--deps/npm/test/tap/dedupe-scoped.js155
-rw-r--r--deps/npm/test/tap/dedupe.js122
-rw-r--r--deps/npm/test/tap/deprecate.js157
-rw-r--r--deps/npm/test/tap/dist-tag.js271
-rw-r--r--deps/npm/test/tap/do-not-remove-other-bins.js117
-rw-r--r--deps/npm/test/tap/doctor-ping-registry-404.js108
-rw-r--r--deps/npm/test/tap/doctor.js131
-rw-r--r--deps/npm/test/tap/extraneous-dep-cycle-ls-ok.js71
-rw-r--r--deps/npm/test/tap/false-name.js79
-rw-r--r--deps/npm/test/tap/fetch-package-metadata.js48
-rw-r--r--deps/npm/test/tap/format-package-lock.js116
-rw-r--r--deps/npm/test/tap/full-warning-messages.js112
-rw-r--r--deps/npm/test/tap/fund.js405
-rw-r--r--deps/npm/test/tap/gently-rm-cmdshims.js161
-rw-r--r--deps/npm/test/tap/gently-rm-linked-module.js100
-rw-r--r--deps/npm/test/tap/gently-rm-overeager.js60
-rw-r--r--deps/npm/test/tap/gently-rm-symlinked-global-dir.js119
-rw-r--r--deps/npm/test/tap/gist-short-shortcut-package.js71
-rw-r--r--deps/npm/test/tap/gist-short-shortcut.js68
-rw-r--r--deps/npm/test/tap/gist-shortcut-package.js65
-rw-r--r--deps/npm/test/tap/gist-shortcut.js58
-rw-r--r--deps/npm/test/tap/git-dependency-install-link.js172
-rw-r--r--deps/npm/test/tap/git-npmignore.js200
-rw-r--r--deps/npm/test/tap/git-prepare.js166
-rw-r--r--deps/npm/test/tap/github-shortcut-package.js61
-rw-r--r--deps/npm/test/tap/github-shortcut.js61
-rw-r--r--deps/npm/test/tap/gitlab-shortcut-package.js60
-rw-r--r--deps/npm/test/tap/gitlab-shortcut.js57
-rw-r--r--deps/npm/test/tap/global-prefix-set-in-userconfig.js36
-rw-r--r--deps/npm/test/tap/graceful-restart.js94
-rw-r--r--deps/npm/test/tap/help.js26
-rw-r--r--deps/npm/test/tap/hook.js243
-rw-r--r--deps/npm/test/tap/ignore-install-link.js71
-rw-r--r--deps/npm/test/tap/ignore-scripts.js128
-rw-r--r--deps/npm/test/tap/init-create.js171
-rw-r--r--deps/npm/test/tap/init-interrupt.js38
-rw-r--r--deps/npm/test/tap/install-actions.js117
-rw-r--r--deps/npm/test/tap/install-at-locally.js52
-rw-r--r--deps/npm/test/tap/install-at-sub-path-locally.js49
-rw-r--r--deps/npm/test/tap/install-bad-dep-format.js33
-rw-r--r--deps/npm/test/tap/install-bad-man.js61
-rw-r--r--deps/npm/test/tap/install-before.js89
-rw-r--r--deps/npm/test/tap/install-bin-null.js73
-rw-r--r--deps/npm/test/tap/install-cli-only-development.js95
-rw-r--r--deps/npm/test/tap/install-cli-only-production.js81
-rw-r--r--deps/npm/test/tap/install-cli-only-shrinkwrap.js119
-rw-r--r--deps/npm/test/tap/install-cli-production-nosave.js48
-rw-r--r--deps/npm/test/tap/install-cli-production.js79
-rw-r--r--deps/npm/test/tap/install-cli-unicode.js57
-rw-r--r--deps/npm/test/tap/install-contributors-count.js69
-rw-r--r--deps/npm/test/tap/install-dep-classification.js188
-rw-r--r--deps/npm/test/tap/install-duplicate-deps-warning.js51
-rw-r--r--deps/npm/test/tap/install-from-local-multipath.js173
-rw-r--r--deps/npm/test/tap/install-from-local.js89
-rw-r--r--deps/npm/test/tap/install-into-likenamed-folder.js44
-rw-r--r--deps/npm/test/tap/install-lifecycle.js35
-rw-r--r--deps/npm/test/tap/install-link-metadeps-locally.js52
-rw-r--r--deps/npm/test/tap/install-link-metadeps-subfolders.js68
-rw-r--r--deps/npm/test/tap/install-link-scripts.js121
-rw-r--r--deps/npm/test/tap/install-local-dep-cycle.js79
-rw-r--r--deps/npm/test/tap/install-local-from-local.js94
-rw-r--r--deps/npm/test/tap/install-man.js57
-rw-r--r--deps/npm/test/tap/install-mention-funding.js127
-rw-r--r--deps/npm/test/tap/install-noargs-dev.js90
-rw-r--r--deps/npm/test/tap/install-order.js65
-rw-r--r--deps/npm/test/tap/install-package-json-order.js42
-rw-r--r--deps/npm/test/tap/install-package-lock-only.js123
-rw-r--r--deps/npm/test/tap/install-parse-error.js50
-rw-r--r--deps/npm/test/tap/install-property-conflicts.js53
-rw-r--r--deps/npm/test/tap/install-report-just-installed.js74
-rw-r--r--deps/npm/test/tap/install-save-consistent-newlines.js98
-rw-r--r--deps/npm/test/tap/install-save-exact.js82
-rw-r--r--deps/npm/test/tap/install-save-local.js181
-rw-r--r--deps/npm/test/tap/install-save-prefix.js164
-rw-r--r--deps/npm/test/tap/install-scoped-already-installed.js129
-rw-r--r--deps/npm/test/tap/install-scoped-link.js73
-rw-r--r--deps/npm/test/tap/install-scoped-with-bundled-dependency.js83
-rw-r--r--deps/npm/test/tap/install-scoped-with-peer-dependency.js40
-rw-r--r--deps/npm/test/tap/install-shrinkwrapped-git.js155
-rw-r--r--deps/npm/test/tap/install-test-cli-with-broken-package-lock.js118
-rw-r--r--deps/npm/test/tap/install-test-cli-without-package-lock.js64
-rw-r--r--deps/npm/test/tap/install-windows-newlines.js90
-rw-r--r--deps/npm/test/tap/install-with-dev-dep-duplicate.js81
-rw-r--r--deps/npm/test/tap/install-without-registry-config.js35
-rw-r--r--deps/npm/test/tap/install.fund.js99
-rw-r--r--deps/npm/test/tap/invalid-cmd-exit-code.js34
-rw-r--r--deps/npm/test/tap/invalid-dep-version-filtering.js135
-rw-r--r--deps/npm/test/tap/is-fs-access-available.js55
-rw-r--r--deps/npm/test/tap/is-registry.js27
-rw-r--r--deps/npm/test/tap/it.js65
-rw-r--r--deps/npm/test/tap/legacy-ignore-nested-nm.js64
-rw-r--r--deps/npm/test/tap/legacy-missing-bindir.js78
-rw-r--r--deps/npm/test/tap/legacy-no-auth-leak.js74
-rw-r--r--deps/npm/test/tap/legacy-platform-all.js74
-rw-r--r--deps/npm/test/tap/legacy-platform.js64
-rw-r--r--deps/npm/test/tap/legacy-private.js58
-rw-r--r--deps/npm/test/tap/legacy-test-package.js70
-rw-r--r--deps/npm/test/tap/lifecycle-INIT_CWD.js36
-rw-r--r--deps/npm/test/tap/lifecycle-order.js33
-rw-r--r--deps/npm/test/tap/lifecycle-path.js210
-rw-r--r--deps/npm/test/tap/link.js205
-rw-r--r--deps/npm/test/tap/local-args-relative-to-cwd.js65
-rw-r--r--deps/npm/test/tap/locker.js77
-rw-r--r--deps/npm/test/tap/lockfile-empty-dep-value.js68
-rw-r--r--deps/npm/test/tap/lockfile-http-deps.js90
-rw-r--r--deps/npm/test/tap/logout-scoped.js69
-rw-r--r--deps/npm/test/tap/logout.js67
-rw-r--r--deps/npm/test/tap/ls-depth-cli.js196
-rw-r--r--deps/npm/test/tap/ls-depth-unmet.js157
-rw-r--r--deps/npm/test/tap/ls-env.js120
-rw-r--r--deps/npm/test/tap/ls-l-depth-0.js100
-rw-r--r--deps/npm/test/tap/ls-no-results.js12
-rw-r--r--deps/npm/test/tap/ls-peer.js123
-rw-r--r--deps/npm/test/tap/ls-production-and-dev.js157
-rw-r--r--deps/npm/test/tap/ls-top-errors.js71
-rw-r--r--deps/npm/test/tap/ls.js222
-rw-r--r--deps/npm/test/tap/meta-test-flaky-root-ownership-test.js20
-rw-r--r--deps/npm/test/tap/nerf-dart.js32
-rw-r--r--deps/npm/test/tap/nested-extraneous.js53
-rw-r--r--deps/npm/test/tap/no-global-warns.js65
-rw-r--r--deps/npm/test/tap/no-scan-full-global-dir.js107
-rw-r--r--deps/npm/test/tap/noargs-install-config-save.js76
-rw-r--r--deps/npm/test/tap/node-modules-path-munge.js39
-rw-r--r--deps/npm/test/tap/normalize-package-explode.js26
-rw-r--r--deps/npm/test/tap/npm-api-not-loaded-error.js48
-rw-r--r--deps/npm/test/tap/onload.js39
-rw-r--r--deps/npm/test/tap/optional-metadep-rollback-collision.js188
-rw-r--r--deps/npm/test/tap/org.js136
-rw-r--r--deps/npm/test/tap/outdated-bad-read-tree.js21
-rw-r--r--deps/npm/test/tap/outdated-color.js75
-rw-r--r--deps/npm/test/tap/outdated-depth.js76
-rw-r--r--deps/npm/test/tap/outdated-git.js61
-rw-r--r--deps/npm/test/tap/outdated-json.js123
-rw-r--r--deps/npm/test/tap/outdated-latest.js109
-rw-r--r--deps/npm/test/tap/outdated-long.js93
-rw-r--r--deps/npm/test/tap/outdated-remote.js89
-rw-r--r--deps/npm/test/tap/outdated-symlink.js133
-rw-r--r--deps/npm/test/tap/outdated.js123
-rw-r--r--deps/npm/test/tap/override-bundled.js191
-rw-r--r--deps/npm/test/tap/owner.js159
-rw-r--r--deps/npm/test/tap/pack-files-and-ignores.js707
-rw-r--r--deps/npm/test/tap/pack-scoped.js81
-rw-r--r--deps/npm/test/tap/pack.js199
-rw-r--r--deps/npm/test/tap/peer-deps.js52
-rw-r--r--deps/npm/test/tap/pick-manifest-from-registry-metadata.js145
-rw-r--r--deps/npm/test/tap/ping.js95
-rw-r--r--deps/npm/test/tap/prepare.js89
-rw-r--r--deps/npm/test/tap/prepublish-only.js136
-rw-r--r--deps/npm/test/tap/prepublish.js118
-rw-r--r--deps/npm/test/tap/process-logger.js12
-rw-r--r--deps/npm/test/tap/progress-config.js87
-rw-r--r--deps/npm/test/tap/prune-dev-dep-cycle.js85
-rw-r--r--deps/npm/test/tap/prune-dev-dep-with-bins.js103
-rw-r--r--deps/npm/test/tap/prune-with-dev-dep-duplicate.js103
-rw-r--r--deps/npm/test/tap/prune-with-only-dev-deps.js114
-rw-r--r--deps/npm/test/tap/prune.js121
-rw-r--r--deps/npm/test/tap/publish-access-scoped.js65
-rw-r--r--deps/npm/test/tap/publish-access-unscoped-restricted-fails.js38
-rw-r--r--deps/npm/test/tap/publish-access-unscoped.js65
-rw-r--r--deps/npm/test/tap/publish-config.js69
-rw-r--r--deps/npm/test/tap/publish-invalid-semver-tag.js76
-rw-r--r--deps/npm/test/tap/publish-scoped.js81
-rw-r--r--deps/npm/test/tap/publish.js162
-rw-r--r--deps/npm/test/tap/pwd-prefix.js35
-rw-r--r--deps/npm/test/tap/referer.js83
-rw-r--r--deps/npm/test/tap/repo.js175
-rw-r--r--deps/npm/test/tap/retry-on-stale-cache.js195
-rw-r--r--deps/npm/test/tap/run-script-filter-private.js52
-rw-r--r--deps/npm/test/tap/run-script.js373
-rw-r--r--deps/npm/test/tap/save-optional.js81
-rw-r--r--deps/npm/test/tap/scope-header.js160
-rw-r--r--deps/npm/test/tap/scripts-whitespace-windows.js88
-rw-r--r--deps/npm/test/tap/search.all-package-search.js207
-rw-r--r--deps/npm/test/tap/search.js254
-rw-r--r--deps/npm/test/tap/semver-doc.js14
-rw-r--r--deps/npm/test/tap/shared-linked.js151
-rw-r--r--deps/npm/test/tap/shrinkwrap-_auth.js109
-rw-r--r--deps/npm/test/tap/shrinkwrap-default-dev.js93
-rw-r--r--deps/npm/test/tap/shrinkwrap-dev-dependency.js70
-rw-r--r--deps/npm/test/tap/shrinkwrap-empty-dep-value.js66
-rw-r--r--deps/npm/test/tap/shrinkwrap-empty-deps.js58
-rw-r--r--deps/npm/test/tap/shrinkwrap-extra-metadata.js60
-rw-r--r--deps/npm/test/tap/shrinkwrap-global-auth.js97
-rw-r--r--deps/npm/test/tap/shrinkwrap-lifecycle-cwd.js87
-rw-r--r--deps/npm/test/tap/shrinkwrap-lifecycle.js37
-rw-r--r--deps/npm/test/tap/shrinkwrap-local-dependency.js124
-rw-r--r--deps/npm/test/tap/shrinkwrap-nested.js165
-rw-r--r--deps/npm/test/tap/shrinkwrap-optional-dependency.js91
-rw-r--r--deps/npm/test/tap/shrinkwrap-optional-platform.js107
-rw-r--r--deps/npm/test/tap/shrinkwrap-optional-property.js87
-rw-r--r--deps/npm/test/tap/shrinkwrap-prod-dependency-also.js85
-rw-r--r--deps/npm/test/tap/shrinkwrap-prod-dependency.js76
-rw-r--r--deps/npm/test/tap/shrinkwrap-resolve-conflict.js117
-rw-r--r--deps/npm/test/tap/shrinkwrap-save-dev-with-existing-deps.js92
-rw-r--r--deps/npm/test/tap/shrinkwrap-save-with-existing-dev-deps.js79
-rw-r--r--deps/npm/test/tap/shrinkwrap-scoped-auth.js96
-rw-r--r--deps/npm/test/tap/shrinkwrap-shared-dev-dependency.js89
-rw-r--r--deps/npm/test/tap/shrinkwrap-version-match.js115
-rw-r--r--deps/npm/test/tap/sorted-package-json.js61
-rw-r--r--deps/npm/test/tap/spawn-enoent-help.js35
-rw-r--r--deps/npm/test/tap/spawn-enoent.js38
-rw-r--r--deps/npm/test/tap/spec-local-specifiers.js752
-rw-r--r--deps/npm/test/tap/splat-with-only-prerelease-to-latest.js95
-rw-r--r--deps/npm/test/tap/startstop.js61
-rw-r--r--deps/npm/test/tap/symlink-cycle.js44
-rw-r--r--deps/npm/test/tap/tag-version-prefix.js73
-rw-r--r--deps/npm/test/tap/tagged-version-matching.js151
-rw-r--r--deps/npm/test/tap/team.js189
-rw-r--r--deps/npm/test/tap/test-run-ls.js33
-rw-r--r--deps/npm/test/tap/tree-style.js127
-rw-r--r--deps/npm/test/tap/umask-lifecycle.js61
-rw-r--r--deps/npm/test/tap/uninstall-in-reverse.js38
-rw-r--r--deps/npm/test/tap/uninstall-link-clean.js113
-rw-r--r--deps/npm/test/tap/uninstall-package.js85
-rw-r--r--deps/npm/test/tap/uninstall-save.js72
-rw-r--r--deps/npm/test/tap/unit-child-path.js16
-rw-r--r--deps/npm/test/tap/unit-deps-earliestInstallable.js114
-rw-r--r--deps/npm/test/tap/unit-deps-removeObsoleteDep.js44
-rw-r--r--deps/npm/test/tap/unit-deps-replaceModule.js65
-rw-r--r--deps/npm/test/tap/unit-module-name.js40
-rw-r--r--deps/npm/test/tap/unit-package-id.js17
-rw-r--r--deps/npm/test/tap/unit-token-validate-cidr.js18
-rw-r--r--deps/npm/test/tap/unpack-foreign-tarball.js84
-rw-r--r--deps/npm/test/tap/unpublish-config.js70
-rw-r--r--deps/npm/test/tap/unsupported.js48
-rw-r--r--deps/npm/test/tap/update-examples.js221
-rw-r--r--deps/npm/test/tap/update-path.js35
-rw-r--r--deps/npm/test/tap/update-symlink.js109
-rw-r--r--deps/npm/test/tap/upgrade-lifecycles.js88
-rw-r--r--deps/npm/test/tap/url-dependencies.js61
-rw-r--r--deps/npm/test/tap/utils.funding.js657
-rw-r--r--deps/npm/test/tap/verify-no-lifecycle-on-repo.js73
-rw-r--r--deps/npm/test/tap/version-allow-same-version.js70
-rw-r--r--deps/npm/test/tap/version-commit-hooks-default.js13
-rw-r--r--deps/npm/test/tap/version-commit-hooks.js55
-rw-r--r--deps/npm/test/tap/version-consistent-newlines.js80
-rw-r--r--deps/npm/test/tap/version-from-git.js220
-rw-r--r--deps/npm/test/tap/version-git-not-clean.js79
-rw-r--r--deps/npm/test/tap/version-lifecycle.js202
-rw-r--r--deps/npm/test/tap/version-message-config.js58
-rw-r--r--deps/npm/test/tap/version-no-git.js43
-rw-r--r--deps/npm/test/tap/version-no-package.js23
-rw-r--r--deps/npm/test/tap/version-no-tags.js58
-rw-r--r--deps/npm/test/tap/version-prerelease-id.js37
-rw-r--r--deps/npm/test/tap/version-sub-directory-shrinkwrap.js65
-rw-r--r--deps/npm/test/tap/version-sub-directory.js56
-rw-r--r--deps/npm/test/tap/version-update-shrinkwrap.js127
-rw-r--r--deps/npm/test/tap/view.js381
-rw-r--r--deps/npm/test/tap/whoami.js76
322 files changed, 0 insertions, 34294 deletions
diff --git a/deps/npm/test/tap/00-check-mock-dep.js b/deps/npm/test/tap/00-check-mock-dep.js
deleted file mode 100644
index cdc7af852b..0000000000
--- a/deps/npm/test/tap/00-check-mock-dep.js
+++ /dev/null
@@ -1,17 +0,0 @@
-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')
diff --git a/deps/npm/test/tap/00-config-setup.js b/deps/npm/test/tap/00-config-setup.js
deleted file mode 100644
index 448453eded..0000000000
--- a/deps/npm/test/tap/00-config-setup.js
+++ /dev/null
@@ -1,85 +0,0 @@
-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',
- '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': path.normalize(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, function () { /*
-save-prefix = ~
-legacy-bundling = true
- */ }.toString().split('\n').slice(1, -1).join('\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')
-}
diff --git a/deps/npm/test/tap/00-verify-bundle-deps.js b/deps/npm/test/tap/00-verify-bundle-deps.js
deleted file mode 100644
index 75ea81c593..0000000000
--- a/deps/npm/test/tap/00-verify-bundle-deps.js
+++ /dev/null
@@ -1,16 +0,0 @@
-var test = require('tap').test
-
-var manifest = require('../../package.json')
-var deps = Object.keys(manifest.dependencies)
-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.end()
-})
diff --git a/deps/npm/test/tap/00-verify-ls-ok.js b/deps/npm/test/tap/00-verify-ls-ok.js
deleted file mode 100644
index edff251d76..0000000000
--- a/deps/npm/test/tap/00-verify-ls-ok.js
+++ /dev/null
@@ -1,27 +0,0 @@
-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', 'pipe', 2 ] }
- common.npm(['ls', '--json'], opt, function (err, code, stdout) {
- t.ifError(err, 'error should not exist')
- t.equal(code, 0, 'npm ls exited with code')
- const tree = JSON.parse(stdout).dependencies
- // We need to have a toplevel `node-gyp` available, but we also need to
- // make sure npm-lifecycle's version is updated in concert.
- // See https://github.com/npm/npm/issues/20163
- t.deepEqual(
- tree['npm-lifecycle'].dependencies['node-gyp'].version,
- tree['node-gyp'].version,
- 'npm-lifecycle and npm using same version of node-gyp'
- )
- t.end()
- })
-})
diff --git a/deps/npm/test/tap/00-verify-no-scoped.js b/deps/npm/test/tap/00-verify-no-scoped.js
deleted file mode 100644
index 4f14dea041..0000000000
--- a/deps/npm/test/tap/00-verify-no-scoped.js
+++ /dev/null
@@ -1,30 +0,0 @@
-'use strict'
-var common = require('../common-tap')
-var test = require('tap').test
-var path = require('path')
-var cwd = path.resolve(__dirname, '..', '..')
-var fs = require('fs')
-
-/*
-We can't include any scoped modules in bundled dependencies due to a bug in
-npm@<4.4.3 that made any module that bundled scoped dependencies
-uninstallable. While this is fixed, we can't have them in ourselves without
-making it impossible to upgrade, thus this test.
-*/
-
-test('no scoped transitive deps', function (t) {
- t.ok(fs.existsSync(cwd), 'ensure that the path we are calling ls within exists')
-
- var opt = { cwd: cwd, stdio: [ 'ignore', 'pipe', 2 ] }
- common.npm(['ls', '--parseable', '--production'], opt, function (err, code, stdout) {
- t.ifError(err, 'error should not exist')
- t.equal(code, 0, 'npm ls exited with code')
- var matchScoped = new RegExp(path.join(cwd, 'node_modules', '.*@').replace(/\\/g, '\\\\'))
- stdout.split(/\n/).forEach(function (line) {
- if (matchScoped.test(line)) {
- t.notLike(line, matchScoped, 'prod deps do not contain scoped modules')
- }
- })
- t.end()
- })
-})
diff --git a/deps/npm/test/tap/404-parent.js b/deps/npm/test/tap/404-parent.js
deleted file mode 100644
index ee9623c545..0000000000
--- a/deps/npm/test/tap/404-parent.js
+++ /dev/null
@@ -1,54 +0,0 @@
-var common = require('../common-tap.js')
-var test = require('tap').test
-var npm = require('../../')
-var path = require('path')
-var fs = require('fs')
-var rimraf = require('rimraf')
-const pkg = common.pkg
-var mr = require('npm-registry-mock')
-
-test('404-parent: if parent exists, specify parent in error message', function (t) {
- setup()
- rimraf(path.resolve(pkg, 'node_modules'), () => {
- performInstall(function (err) {
- t.ok(err instanceof Error, 'error was returned')
- t.equal(err.parent, '404-parent', "error's parent set")
- t.end()
- })
- })
-})
-
-function setup () {
- 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 performInstall (cb) {
- mr({port: common.port}, function (er, s) { // create mock registry.
- if (er) {
- return cb(er)
- }
- s.get('/test-npm-404-parent-test')
- .many().reply(404, {'error': 'version not found'})
- npm.load({
- registry: common.registry
- }, function () {
- npm.config.set('fetch-retries', 0)
- var pwd = process.cwd()
- process.chdir(pkg)
- npm.commands.install([], function (err) {
- process.chdir(pwd)
- cb(err)
- s.close() // shutdown mock npm server.
- })
- })
- })
-}
diff --git a/deps/npm/test/tap/404-private-registry-scoped.js b/deps/npm/test/tap/404-private-registry-scoped.js
deleted file mode 100644
index 0aa262f546..0000000000
--- a/deps/npm/test/tap/404-private-registry-scoped.js
+++ /dev/null
@@ -1,36 +0,0 @@
-var test = require('tap').test
-var common = require('../common-tap.js')
-var mr = common.fakeRegistry.compat
-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) {
- server.get('/@scope%2ffoo').reply(404, {})
- common.npm(
- [
- '--registry=' + common.registry,
- '--cache=' + common.cache,
- '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, /E404/, 'should notify the sort of error as a 404')
- t.match(stderr, /@scope(?:%2f|\/)foo/, 'should have package name in error')
- server.done()
- server.close()
- t.end()
- }
- )
-})
diff --git a/deps/npm/test/tap/404-private-registry.js b/deps/npm/test/tap/404-private-registry.js
deleted file mode 100644
index 0ca05105dc..0000000000
--- a/deps/npm/test/tap/404-private-registry.js
+++ /dev/null
@@ -1,37 +0,0 @@
-var test = require('tap').test
-var path = require('path')
-var common = require('../common-tap.js')
-var mr = common.fakeRegistry.compat
-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) {
- server.get('/' + packageName).reply(404, {})
- common.npm(
- [
- '--registry=' + common.registry,
- '--cache=' + common.cache,
- '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')
- server.done()
- server.close()
- t.end()
- }
- )
-})
diff --git a/deps/npm/test/tap/404.js b/deps/npm/test/tap/404.js
deleted file mode 100644
index af146371c7..0000000000
--- a/deps/npm/test/tap/404.js
+++ /dev/null
@@ -1,72 +0,0 @@
-'use strict'
-const path = require('path')
-const test = require('tap').test
-const Tacks = require('tacks')
-const File = Tacks.File
-const Dir = Tacks.Dir
-const common = require('../common-tap.js')
-
-const e404 = /test-npm-404@latest' is not in the npm registry/
-const invalidPackage = /Your package name is not valid, because[\s\S]+1\. name can only contain URL-friendly characters/
-
-const basedir = common.pkg
-const testdir = path.join(basedir, 'testdir')
-const cachedir = common.cache
-const globaldir = path.join(basedir, 'global')
-const tmpdir = path.join(basedir, 'tmp')
-
-const env = common.newEnv().extend({
- npm_config_cache: cachedir,
- npm_config_tmp: tmpdir,
- npm_config_prefix: globaldir,
- npm_config_registry: common.registry,
- npm_config_loglevel: 'error'
-})
-
-const fixture = new Tacks(Dir({
- cache: Dir(),
- global: Dir(),
- tmp: Dir(),
- testdir: Dir({
- 'package.json': File({
- name: 'test',
- version: '1.0.0'
- })
- })
-}))
-
-function setup () {
- cleanup()
- fixture.create(basedir)
-}
-
-function cleanup () {
- fixture.remove(basedir)
-}
-
-test('setup', function (t) {
- setup()
- return common.fakeRegistry.listen()
-})
-
-test('404 message for basic package', function (t) {
- return common.npm(['install', 'test-npm-404'], {cwd: testdir, env}).then(([code, stdout, stderr]) => {
- t.is(code, 1, 'error code')
- t.match(stderr, e404, 'error output')
- t.notMatch(stderr, invalidPackage, 'no invalidity error')
- })
-})
-
-test('404 message for scoped package', function (t) {
- return common.npm(['install', '@npm/test-npm-404'], {cwd: testdir, env}).then(([code, stdout, stderr]) => {
- t.is(code, 1, 'error code')
- t.match(stderr, e404, 'error output')
- t.notMatch(stderr, invalidPackage, 'no invalidity error')
- })
-})
-
-test('cleanup', function (t) {
- common.fakeRegistry.close()
- cleanup()
- t.done()
-})
diff --git a/deps/npm/test/tap/access.js b/deps/npm/test/tap/access.js
deleted file mode 100644
index f537db2586..0000000000
--- a/deps/npm/test/tap/access.js
+++ /dev/null
@@ -1,587 +0,0 @@
-'use strict'
-
-const fs = require('fs')
-const path = require('path')
-const mkdirp = require('mkdirp')
-const rimraf = require('rimraf')
-const mr = require('npm-registry-mock')
-
-const test = require('tap').test
-const common = require('../common-tap.js')
-
-const pkg = common.pkg
-
-let server
-
-const scoped = {
- name: '@scoped/pkg',
- version: '1.1.1'
-}
-
-test('setup', function (t) {
- 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(pkg, '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(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(pkg, '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(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, /only available for scoped packages/)
- t.end()
- }
- )
-})
-
-test('npm access grant read-only', function (t) {
- server.filteringRequestBody((body) => {
- const data = JSON.parse(body)
- t.deepEqual(data, {
- permissions: 'read-only',
- package: '@scoped/another'
- }, 'got the right body')
- return true
- })
- server.put('/-/team/myorg/myteam/package', true).reply(201)
- 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.filteringRequestBody((body) => {
- const data = JSON.parse(body)
- t.deepEqual(data, {
- permissions: 'read-write',
- package: '@scoped/another'
- }, 'got the right body')
- return true
- })
- server.put('/-/team/myorg/myteam/package', true).reply(201)
- 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 read-write on unscoped package', function (t) {
- server.filteringRequestBody((body) => {
- const data = JSON.parse(body)
- t.deepEqual(data, {
- permissions: 'read-write',
- package: 'another'
- }, 'got the right body')
- return true
- })
- server.put('/-/team/myorg/myteam/package', true).reply(201)
- common.npm(
- [
- 'access',
- 'grant', 'read-write',
- 'myorg:myteam',
- '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(pkg, '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(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 unscoped', function (t) {
- var serverCollaborators = {
- 'myorg:myteam': 'write',
- 'myorg:anotherteam': 'read'
- }
- var clientCollaborators = {
- 'myorg:myteam': 'read-write',
- 'myorg:anotherteam': 'read-only'
- }
- server.get(
- '/-/package/pkg/collaborators?format=cli'
- ).reply(200, serverCollaborators)
- common.npm(
- [
- 'access',
- 'ls-collaborators',
- 'pkg',
- '--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')
- server.done()
- server.close()
- t.end()
-})
diff --git a/deps/npm/test/tap/add-named-update-protocol-port.js b/deps/npm/test/tap/add-named-update-protocol-port.js
deleted file mode 100644
index 2876b6cdbc..0000000000
--- a/deps/npm/test/tap/add-named-update-protocol-port.js
+++ /dev/null
@@ -1,113 +0,0 @@
-'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:' + common.altPort + '/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:' + common.altPort + '/registry/' + iPackageName + '/-/' + iPackageName + '-0.0.0.tgz',
- shasum: '356a192b7913b04c54574d18c28d46e6395428ab'
- }
- }
- }
-}
-
-test('setup', function (t) {
- mr({
- port: common.port,
- throwOnUnmatched: true
- }, function (err, s) {
- t.ifError(err, 'registry mocked successfully')
- server1 = s
- mr({
- port: common.altPort,
- 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:' + common.port + '/registry'
- ],
- {},
- function (er, code, stdout, stderr) {
- if (er) { throw er }
- t.equal(stderr, '', 'no error output')
- 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:' + common.port + '/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()
-})
diff --git a/deps/npm/test/tap/add-remote-git-file.js b/deps/npm/test/tap/add-remote-git-file.js
deleted file mode 100644
index 483c6368c6..0000000000
--- a/deps/npm/test/tap/add-remote-git-file.js
+++ /dev/null
@@ -1,85 +0,0 @@
-'use strict'
-
-var fs = require('fs')
-var resolve = require('path').resolve
-var url = require('url')
-
-var mkdirp = require('mkdirp')
-var test = require('tap').test
-
-var npm = require('../../lib/npm.js')
-var fetchPackageMetadata = require('../../lib/fetch-package-metadata.js')
-var common = require('../common-tap.js')
-
-var pkg = resolve(common.pkg, 'package')
-var repo = resolve(common.pkg, 'repo')
-mkdirp.sync(pkg)
-
-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) {
- setup(function (er, r) {
- t.ifError(er, 'git started up successfully')
-
- t.end()
- })
-})
-
-test('cache from repo', function (t) {
- process.chdir(pkg)
- fetchPackageMetadata(cloneURL, process.cwd(), {}, (err, manifest) => {
- if (err) t.fail(err.message)
- t.equal(
- url.parse(manifest._resolved).protocol,
- 'git+file:',
- 'npm didn\'t go crazy adding git+git+git+git'
- )
- t.equal(manifest._requested.type, 'git', 'cached git')
- t.end()
- })
-})
-
-test('save install', function (t) {
- process.chdir(pkg)
- fs.writeFileSync('package.json', JSON.stringify({
- name: 'parent',
- version: '5.4.3'
- }, null, 2) + '\n')
- var prev = npm.config.get('save')
- npm.config.set('save', true)
- npm.commands.install('.', [cloneURL], function (er) {
- npm.config.set('save', prev)
- t.ifError(er, 'npm installed via git')
- var pj = JSON.parse(fs.readFileSync('package.json', 'utf-8'))
- var dep = pj.dependencies.child
- t.equal(
- url.parse(dep).protocol,
- 'git+file:',
- 'npm didn\'t strip the git+ from git+file://'
- )
-
- t.end()
- })
-})
-
-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)
- })
-}
diff --git a/deps/npm/test/tap/add-remote-git-shrinkwrap.js b/deps/npm/test/tap/add-remote-git-shrinkwrap.js
deleted file mode 100644
index 01a033e894..0000000000
--- a/deps/npm/test/tap/add-remote-git-shrinkwrap.js
+++ /dev/null
@@ -1,137 +0,0 @@
-var fs = require('fs')
-var resolve = require('path').resolve
-
-var mkdirp = require('mkdirp')
-var test = require('tap').test
-
-var npm = require('../../lib/npm.js')
-var common = require('../common-tap.js')
-
-var pkg = resolve(common.pkg, 'package')
-var repo = resolve(common.pkg, 'repo')
-
-var daemon
-var daemonPID
-var git
-
-var pjParent = JSON.stringify({
- name: 'parent',
- version: '1.2.3',
- dependencies: {
- 'child': 'git://localhost:' + common.gitPort + '/child.git#master'
- }
-}, null, 2) + '\n'
-
-var pjChild = JSON.stringify({
- name: 'child',
- version: '1.0.3'
-}, null, 2) + '\n'
-
-test('setup', function (t) {
- mkdirp.sync(pkg)
- fs.writeFileSync(resolve(pkg, 'package.json'), pjParent)
- 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)
- common.npm(['install'], {cwd: pkg, stdio: [0, 1, 2]}, function (er, code) {
- if (er) throw er
- t.is(code, 0, 'npm installed via git')
-
- t.end()
- })
-})
-
-test('shrinkwrap gets correct _from and _resolved (#7121)', function (t) {
- common.npm(
- [
- 'shrinkwrap',
- '--loglevel', 'error'
- ],
- { cwd: pkg, stdio: [0, 'pipe', 2] },
- function (er, code, stdout) {
- if (er) throw er
- t.is(code, 0, '`npm shrinkwrap` exited ok')
-
- var shrinkwrap = require(resolve(pkg, 'npm-shrinkwrap.json'))
- 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.like(shrinkwrap, {dependencies: {child: {version: 'git://localhost:' + common.gitPort + '/child.git#' + treeish}}},
- 'npm shrinkwrapped resolved correctly'
- )
-
- t.end()
- }
- )
- }
- )
-})
-
-test('clean', function (t) {
- daemon.on('close', t.end)
- process.kill(daemonPID)
-})
-
-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=' + common.gitPort
- ],
- {
- 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)
- })
-}
diff --git a/deps/npm/test/tap/add-remote-git-submodule.js b/deps/npm/test/tap/add-remote-git-submodule.js
deleted file mode 100644
index 54f2819fb3..0000000000
--- a/deps/npm/test/tap/add-remote-git-submodule.js
+++ /dev/null
@@ -1,142 +0,0 @@
-var fs = require('fs')
-var resolve = require('path').resolve
-
-var cwd = process.cwd()
-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(common.pkg, 'package')
-var repos = resolve(common.pkg, 'repos')
-var subwt = resolve(repos, 'subwt')
-var topwt = resolve(repos, 'topwt')
-var suburl = 'git://localhost:' + common.gitPort + '/sub.git'
-var topurl = 'git://localhost:' + common.gitPort + '/top.git'
-
-var daemon
-var daemonPID
-var git
-
-var pjParent = JSON.stringify({
- name: 'parent',
- version: '1.2.3',
- dependencies: {
- child: topurl
- }
-}, null, 2) + '\n'
-
-var pjChild = JSON.stringify({
- name: 'child',
- version: '1.0.3'
-}, null, 2) + '\n'
-
-test('setup', function (t) {
- setup(function (er, r) {
- t.ifError(er, 'git started up successfully')
- t.end()
- })
-})
-
-test('install from repo', function (t) {
- bootstrap(t)
- npm.commands.install('.', [], function (er) {
- t.ifError(er, 'npm installed via git')
- t.end()
- })
-})
-
-test('has file in submodule', function (t) {
- bootstrap(t)
- npm.commands.install('.', [], function (er) {
- t.ifError(er, 'npm installed via git')
- var fooPath = resolve('node_modules', 'child', 'subpath', 'foo.txt')
- fs.stat(fooPath, function (er) {
- t.ifError(er, 'file in submodule exists')
- t.end()
- })
- })
-})
-
-test('clean', function (t) {
- daemon.on('close', function () {
- t.end()
- })
- process.kill(daemonPID)
-})
-
-function bootstrap (t) {
- process.chdir(cwd)
- rimraf.sync(pkg)
- mkdirp.sync(pkg)
- process.chdir(pkg)
- fs.writeFileSync('package.json', pjParent)
-}
-
-function setup (cb) {
- rimraf.sync(pkg)
- rimraf.sync(repos)
-
- mkdirp.sync(topwt)
- fs.writeFileSync(resolve(topwt, 'package.json'), pjChild)
- mkdirp.sync(subwt)
- fs.writeFileSync(resolve(subwt, 'foo.txt'), 'This is provided by submodule')
- 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=' + common.gitPort
- ],
- {
- cwd: repos,
- 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)
- daemon = d
- daemonPID = cpid[1]
- cb(null)
- }
- }
- }
-
- var env = { PATH: process.env.PATH }
- var topopt = { cwd: topwt, env: env }
- var reposopt = { cwd: repos, env: env }
- common.makeGitRepo({
- path: subwt,
- message: 'subwt repo: ' + subwt,
- added: ['foo.txt'],
- commands: [
- git.chainableExec(['clone', '--bare', subwt, 'sub.git'], reposopt),
- startDaemon,
- [common.makeGitRepo, {
- path: topwt,
- message: 'topwt repo: ' + topwt,
- commands: [
- git.chainableExec(['submodule', 'add', suburl, 'subpath'], topopt),
- git.chainableExec(['commit', '-m', 'added submodule'], topopt),
- git.chainableExec(['clone', '--bare', topwt, 'top.git'], reposopt)
- ]
- }]
- ]
- }, cb)
- })
-}
diff --git a/deps/npm/test/tap/add-remote-git.js b/deps/npm/test/tap/add-remote-git.js
deleted file mode 100644
index 2a61963439..0000000000
--- a/deps/npm/test/tap/add-remote-git.js
+++ /dev/null
@@ -1,104 +0,0 @@
-var fs = require('fs')
-var resolve = require('path').resolve
-
-var mkdirp = require('mkdirp')
-var test = require('tap').test
-
-var npm = require('../../lib/npm.js')
-var common = require('../common-tap.js')
-
-var pkg = resolve(common.pkg, 'package')
-var repo = resolve(pkg, 'repo')
-
-var daemon
-var daemonPID
-var git
-
-var pjParent = JSON.stringify({
- name: 'parent',
- version: '1.2.3',
- dependencies: {
- child: 'git://localhost:' + common.gitPort + '/child.git'
- }
-}, null, 2) + '\n'
-
-var pjChild = JSON.stringify({
- name: 'child',
- version: '1.0.3'
-}, null, 2) + '\n'
-
-test('setup', function (t) {
- mkdirp.sync(pkg)
- fs.writeFileSync(resolve(pkg, 'package.json'), pjParent)
- 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', t.end)
- process.kill(daemonPID)
-})
-
-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=' + common.gitPort
- ],
- {
- cwd: pkg,
- env: process.env,
- stdio: ['pipe', 1, '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)
- })
-}
diff --git a/deps/npm/test/tap/adduser-always-auth.js b/deps/npm/test/tap/adduser-always-auth.js
deleted file mode 100644
index 26541eebbc..0000000000
--- a/deps/npm/test/tap/adduser-always-auth.js
+++ /dev/null
@@ -1,266 +0,0 @@
-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: common.pkg }
-var outfile = path.resolve(common.pkg, '_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'
- } else {
- return 'invalid'
- }
- })
- server.post('/-/v1/login', 'invalid').reply(404, 'not found')
- 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.equal(code, 0, '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()
-})
diff --git a/deps/npm/test/tap/adduser-legacy-auth.js b/deps/npm/test/tap/adduser-legacy-auth.js
deleted file mode 100644
index e46901c2b9..0000000000
--- a/deps/npm/test/tap/adduser-legacy-auth.js
+++ /dev/null
@@ -1,102 +0,0 @@
-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: common.pkg }
-var pkg = common.pkg
-var outfile = path.resolve(pkg, '_npmrc')
-
-var contents = '_auth=' + Buffer.from('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'
- } else {
- return 'invalid'
- }
- })
- server.post('/-/v1/login', 'invalid').reply(404, 'not found')
- 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) {
- rimraf.sync(pkg)
- 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', 'error',
- '--userconfig', outfile
- ],
- opts,
- function (err, code, stdout, stderr) {
- if (err) throw err
- t.is(stderr, '', 'no error output')
- t.is(code, 0, 'exited OK')
- 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]
- if (responses[label]) 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()
-})
diff --git a/deps/npm/test/tap/adduser-oauth.js b/deps/npm/test/tap/adduser-oauth.js
deleted file mode 100644
index 241fef2a2e..0000000000
--- a/deps/npm/test/tap/adduser-oauth.js
+++ /dev/null
@@ -1,82 +0,0 @@
-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: common.pkg }
-var pkg = common.pkg
-var fakeBrowser = path.resolve(pkg, '_script.sh')
-var configfile = path.resolve(pkg, '_npmrc')
-var outfile = path.resolve(pkg, '_outfile')
-var ssoUri = common.registry + '/-/oauth/foo'
-
-common.pendIfWindows('This is trickier to convert without opening new shells')
-
-function mocks (server) {
- server.filteringRequestBody(function (r) {
- if (r.match(/"_id":"org\.couchdb\.user:npm_oauth_auth_dummy_user"/)) {
- return 'auth'
- } else {
- return 'invalid'
- }
- })
- server.post('/-/v1/login', 'invalid').reply(404, 'not found')
- server.put('/-/user/org.couchdb.user:npm_oauth_auth_dummy_user', 'auth')
- .reply(201, { token: 'foo', sso: ssoUri })
-}
-
-test('setup', function (t) {
- mkdirp.sync(pkg)
- fs.writeFileSync(configfile, '')
- var s = '#!/usr/bin/env bash\n' +
- 'echo "$@" > ' + outfile + '\n'
- fs.writeFileSync(fakeBrowser, s, 'ascii')
- fs.chmodSync(fakeBrowser, '0755')
- t.pass('made script')
- t.end()
-})
-
-test('npm login', function (t) {
- mr({ port: common.port, plugin: mocks }, function (er, s) {
- s.get(
- '/-/whoami', { authorization: 'Bearer foo' }
- ).max(1).reply(401, {})
- common.npm(
- [
- 'login',
- '--registry', common.registry,
- '--auth-type=oauth',
- '--loglevel', 'silent',
- '--userconfig', configfile,
- '--browser', fakeBrowser
- ],
- opts,
- function (err, code, stdout, stderr) {
- t.ifError(err, 'npm ran without issue')
- t.equal(code, 0, 'exited OK')
- t.notOk(stderr, 'no error output')
- stderr && t.comment('stderr - ', stderr)
- t.matches(stdout, /Logged in as igotauthed/,
- 'successfully authenticated and output the given username')
- s.close()
- rimraf.sync(configfile)
- rimraf.sync(outfile)
- t.end()
- }
- )
-
- s.get(
- '/-/whoami', { authorization: 'Bearer foo' }
- ).reply(200, { username: 'igotauthed' })
- })
-})
-
-test('cleanup', function (t) {
- rimraf.sync(pkg)
- t.pass('cleaned up')
- t.end()
-})
diff --git a/deps/npm/test/tap/adduser-saml.js b/deps/npm/test/tap/adduser-saml.js
deleted file mode 100644
index 17a1a9f7b3..0000000000
--- a/deps/npm/test/tap/adduser-saml.js
+++ /dev/null
@@ -1,82 +0,0 @@
-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: common.pkg }
-var pkg = common.pkg
-var fakeBrowser = path.resolve(pkg, '_script.sh')
-var configfile = path.resolve(pkg, '_npmrc')
-var outfile = path.resolve(pkg, '_outfile')
-var ssoUri = common.registry + '/-/saml/foo'
-
-common.pendIfWindows('This is trickier to convert without opening new shells')
-
-function mocks (server) {
- server.filteringRequestBody(function (r) {
- if (r.match(/"_id":"org\.couchdb\.user:npm_saml_auth_dummy_user"/)) {
- return 'auth'
- } else {
- return 'invalid'
- }
- })
- server.post('/-/v1/login', 'invalid').reply(404, 'not found')
- server.put('/-/user/org.couchdb.user:npm_saml_auth_dummy_user', 'auth')
- .reply(201, { token: 'foo', sso: ssoUri })
-}
-
-test('setup', function (t) {
- mkdirp.sync(pkg)
- fs.writeFileSync(configfile, '')
- var s = '#!/usr/bin/env bash\n' +
- 'echo "$@" > ' + outfile + '\n'
- fs.writeFileSync(fakeBrowser, s, 'ascii')
- fs.chmodSync(fakeBrowser, '0755')
- t.pass('made script')
- t.end()
-})
-
-test('npm login', function (t) {
- mr({ port: common.port, plugin: mocks }, function (er, s) {
- s.get(
- '/-/whoami', { authorization: 'Bearer foo' }
- ).max(1).reply(401, {})
- common.npm(
- [
- 'login',
- '--registry', common.registry,
- '--auth-type=saml',
- '--loglevel', 'silent',
- '--userconfig', configfile,
- '--browser', fakeBrowser
- ],
- opts,
- function (err, code, stdout, stderr) {
- t.ifError(err, 'npm ran without issue')
- t.equal(code, 0, 'exited OK')
- t.notOk(stderr, 'no error output')
- stderr && t.comment('stderr - ', stderr)
- t.matches(stdout, /Logged in as igotauthed/,
- 'successfully authenticated and output the given username')
- s.close()
- rimraf.sync(configfile)
- rimraf.sync(outfile)
- t.end()
- }
- )
-
- s.get(
- '/-/whoami', { authorization: 'Bearer foo' }
- ).reply(200, { username: 'igotauthed' })
- })
-})
-
-test('cleanup', function (t) {
- rimraf.sync(pkg)
- t.pass('cleaned up')
- t.end()
-})
diff --git a/deps/npm/test/tap/aliases.js b/deps/npm/test/tap/aliases.js
deleted file mode 100644
index 21a68ac50f..0000000000
--- a/deps/npm/test/tap/aliases.js
+++ /dev/null
@@ -1,268 +0,0 @@
-'use strict'
-
-const BB = require('bluebird')
-
-const common = require('../common-tap.js')
-const fs = require('graceful-fs')
-const mockTar = require('../util/mock-tarball.js')
-const mr = common.fakeRegistry.compat
-const path = require('path')
-const rimraf = BB.promisify(require('rimraf'))
-const Tacks = require('tacks')
-const { test } = require('tap')
-
-const { Dir, File } = Tacks
-const readdirAsync = BB.promisify(fs.readdir)
-const readFileAsync = BB.promisify(fs.readFile)
-
-const testDir = common.pkg
-
-let server
-test('setup', t => {
- mr({}, (err, s) => {
- t.ifError(err, 'registry mocked successfully')
- server = s
- t.end()
- })
-})
-
-test('installs an npm: protocol alias package', t => {
- const fixture = new Tacks(Dir({
- 'package.json': File({})
- }))
- fixture.create(testDir)
- const packument = {
- name: 'foo',
- 'dist-tags': { latest: '1.2.4' },
- versions: {
- '1.2.3': {
- name: 'foo',
- version: '1.2.3',
- dist: {
- tarball: `${server.registry}/foo/-/foo-1.2.3.tgz`
- }
- },
- '1.2.4': {
- name: 'foo',
- version: '1.2.4',
- dist: {
- tarball: `${server.registry}/foo/-/foo-1.2.4.tgz`
- }
- }
- }
- }
- server.get('/foo').reply(200, packument)
- return mockTar({
- 'package.json': JSON.stringify({
- name: 'foo',
- version: '1.2.3'
- })
- }).then(tarball => {
- server.get('/foo/-/foo-1.2.3.tgz').reply(200, tarball)
- server.get('/foo/-/foo-1.2.4.tgz').reply(200, tarball)
- return common.npm([
- 'install', 'foo@1.2.3',
- '--cache', path.join(testDir, 'npmcache'),
- '--registry', server.registry
- ], { cwd: testDir })
- }).then(([code, stdout, stderr]) => {
- t.equal(code, 0)
- t.comment(stdout)
- t.comment(stderr)
- return common.npm([
- 'install', 'bar@npm:foo@1.2.3',
- '--cache', path.join(testDir, 'npmcache'),
- '--registry', server.registry
- ], { cwd: testDir })
- }).then(([code, stdout, stderr]) => {
- t.equal(code, 0)
- t.comment(stdout)
- t.comment(stderr)
- t.match(stdout, /\+ foo@1\.2\.3 \(as bar\)/, 'useful message')
- return readFileAsync(
- path.join(testDir, 'node_modules', 'bar', 'package.json'),
- 'utf8'
- )
- }).then(JSON.parse).then(pkg => {
- t.similar(pkg, {
- name: 'foo',
- version: '1.2.3'
- }, 'successfully installed foo as bar in node_modules')
- return common.npm(['ls', '--json'], { cwd: testDir })
- }).then(([code, stdout, stderr]) => {
- t.comment(stdout)
- t.comment(stderr)
- t.equal(code, 0, 'ls is clean')
- t.deepEqual(JSON.parse(stdout), {
- dependencies: {
- bar: {
- version: '1.2.3',
- from: 'bar@npm:foo@1.2.3',
- resolved: 'http://localhost:' + common.port + '/foo/-/foo-1.2.3.tgz'
- },
- foo: {
- version: '1.2.3',
- from: 'foo@1.2.3',
- resolved: 'http://localhost:' + common.port + '/foo/-/foo-1.2.3.tgz'
- }
- }
- }, 'both dependencies listed correctly')
- return common.npm([
- 'outdated', '--json',
- '--registry', server.registry
- ], { cwd: testDir })
- }).then(([code, stdout, stderr]) => {
- t.equal(code, 1, 'non-zero because some packages outdated')
- t.comment(stdout)
- t.comment(stderr)
- const parsed = JSON.parse(stdout)
- t.match(parsed, {
- foo: {
- current: '1.2.3',
- wanted: '1.2.4',
- latest: '1.2.4',
- location: /node_modules[/\\]foo/
- },
- bar: {
- current: 'npm:foo@1.2.3',
- wanted: 'npm:foo@1.2.4',
- latest: 'npm:foo@1.2.4',
- location: /node_modules[/\\]bar/
- }
- }, 'both regular and aliased dependency reported')
- return common.npm([
- 'update',
- '--registry', server.registry
- ], { cwd: testDir })
- }).then(([code, stdout, stderr]) => {
- t.equal(code, 0, 'update succeeded')
- t.comment(stdout)
- t.comment(stderr)
- return common.npm(['ls', '--json'], { cwd: testDir })
- }).then(([code, stdout, stderr]) => {
- t.equal(code, 0, 'ls succeeded')
- t.comment(stdout)
- t.comment(stderr)
- const parsed = JSON.parse(stdout)
- t.deepEqual(parsed, {
- dependencies: {
- bar: {
- version: '1.2.4',
- from: 'bar@npm:foo@1.2.4',
- resolved: 'http://localhost:' + common.port + '/foo/-/foo-1.2.4.tgz'
- },
- foo: {
- version: '1.2.4',
- from: 'foo@1.2.4',
- resolved: 'http://localhost:' + common.port + '/foo/-/foo-1.2.4.tgz'
- }
- }
- }, 'ls shows updated packages')
- return common.npm([
- 'rm', 'bar',
- '--registry', server.registry
- ], { cwd: testDir })
- }).then(([code, stdout, stderr]) => {
- t.equal(code, 0, 'rm succeeded')
- t.comment(stdout)
- t.comment(stderr)
- t.match(stdout, 'removed 1 package', 'notified of removed package')
- return readdirAsync(path.join(testDir, 'node_modules'))
- }).then(dir => {
- t.deepEqual(dir, ['foo'], 'regular foo left in place')
- }).then(() => rimraf(testDir))
-})
-
-test('installs a tarball dep as a different name than package.json', t => {
- return mockTar({
- 'package.json': JSON.stringify({
- name: 'foo',
- version: '1.2.3'
- })
- }).then(tarball => {
- const fixture = new Tacks(Dir({
- 'package.json': File({}),
- 'foo.tgz': File(tarball)
- }))
- fixture.create(testDir)
- return common.npm([
- 'install', 'file:foo.tgz',
- '--cache', path.join(testDir, 'npmcache'),
- '--registry', server.registry
- ], { cwd: testDir })
- }).then(([code, stdout, stderr]) => {
- return common.npm([
- 'install', 'bar@file:foo.tgz',
- '--cache', path.join(testDir, 'npmcache'),
- '--registry', server.registry
- ], { cwd: testDir })
- }).then(([code, stdout, stderr]) => {
- t.comment(stdout)
- t.comment(stderr)
- t.match(stdout, /^\+ foo@1\.2\.3 \(as bar\)/, 'useful message')
- return readFileAsync(
- path.join(testDir, 'node_modules', 'bar', 'package.json'),
- 'utf8'
- )
- }).then(JSON.parse).then(pkg => {
- t.similar(pkg, {
- name: 'foo',
- version: '1.2.3'
- }, 'successfully installed foo as bar in node_modules')
- return common.npm(['ls', '--json'], { cwd: testDir })
- }).then(([code, stdout, stderr]) => {
- t.comment(stdout)
- t.comment(stderr)
- t.similar(JSON.parse(stdout), {
- dependencies: {
- bar: {
- version: '1.2.3',
- from: 'file:foo.tgz'
- },
- foo: {
- version: '1.2.3',
- from: 'file:foo.tgz'
- }
- }
- }, 'both dependencies present')
- }).then(() => rimraf(testDir))
-})
-
-test('installs a symlink dep as a different name than package.json', t => {
- const fixture = new Tacks(Dir({
- 'package.json': File({}),
- 'foo': Dir({
- 'package.json': File({
- name: 'foo',
- version: '1.2.3'
- })
- })
- }))
- fixture.create(testDir)
- return common.npm([
- 'install', 'bar@file:foo',
- '--cache', path.join(testDir, 'npmcache'),
- '--registry', server.registry
- ], { cwd: testDir }).then(([code, stdout, stderr]) => {
- t.comment(stdout)
- t.comment(stderr)
- t.match(stdout, /^\+ foo@1\.2\.3 \(as bar\)/, 'useful message')
- return readFileAsync(
- path.join(testDir, 'node_modules', 'bar', 'package.json'),
- 'utf8'
- )
- }).then(JSON.parse).then(pkg => {
- t.similar(pkg, {
- name: 'foo',
- version: '1.2.3'
- }, 'successfully installed foo as bar in node_modules')
- }).then(() => rimraf(testDir))
-})
-
-test('cleanup', t => {
- server.close()
- return rimraf(testDir)
-})
-
-test('npm audit supports aliases')
-test('npm audit fix supports aliases')
diff --git a/deps/npm/test/tap/all-package-metadata-cache-stream-unit.js b/deps/npm/test/tap/all-package-metadata-cache-stream-unit.js
deleted file mode 100644
index 66b24c5e0c..0000000000
--- a/deps/npm/test/tap/all-package-metadata-cache-stream-unit.js
+++ /dev/null
@@ -1,112 +0,0 @@
-'use strict'
-
-const common = require('../common-tap.js')
-
-const getStream = require('get-stream')
-const mkdirp = require('mkdirp')
-const path = require('path')
-const Tacks = require('tacks')
-const {test} = require('tap')
-
-const {File} = Tacks
-
-const _createCacheEntryStream = require('../../lib/search/all-package-metadata.js')._createCacheEntryStream
-
-// this test uses a fresh cache for each test block
-// create them all in common.cache so that we can verify
-// them for root-owned files in sudotest
-let CACHE_DIR
-let cacheCounter = 1
-const chownr = require('chownr')
-function setup () {
- CACHE_DIR = common.cache + '/' + cacheCounter++
- mkdirp.sync(CACHE_DIR)
- fixOwner(CACHE_DIR)
-}
-
-const fixOwner = (
- process.getuid && process.getuid() === 0 &&
- process.env.SUDO_UID && process.env.SUDO_GID
-) ? (path) => chownr.sync(path, +process.env.SUDO_UID, +process.env.SUDO_GID)
- : () => {}
-
-test('createCacheEntryStream basic', t => {
- setup()
- const cachePath = path.join(CACHE_DIR, '.cache.json')
- const fixture = new Tacks(File({
- '_updated': 1234,
- bar: {
- name: 'bar',
- version: '1.0.0'
- },
- foo: {
- name: 'foo',
- version: '1.0.0'
- }
- }))
- fixture.create(cachePath)
- fixOwner(cachePath)
- return _createCacheEntryStream(cachePath, {}).then(({
- updateStream: stream,
- updatedLatest: latest
- }) => {
- t.equals(latest, 1234, '`latest` correctly extracted')
- t.ok(stream, 'returned a stream')
- return getStream.array(stream).then(results => {
- t.deepEquals(results, [{
- name: 'bar',
- version: '1.0.0'
- }, {
- name: 'foo',
- version: '1.0.0'
- }])
- })
- })
-})
-
-test('createCacheEntryStream empty cache', t => {
- setup()
- const cachePath = path.join(CACHE_DIR, '.cache.json')
- const fixture = new Tacks(File({}))
- fixture.create(cachePath)
- fixOwner(cachePath)
- return _createCacheEntryStream(cachePath, {}).then(
- () => { throw new Error('should not succeed') },
- err => {
- t.ok(err, 'returned an error because there was no _updated')
- t.match(err.message, /Empty or invalid stream/, 'useful error message')
- }
- )
-})
-
-test('createCacheEntryStream no entry cache', t => {
- setup()
- const cachePath = path.join(CACHE_DIR, '.cache.json')
- const fixture = new Tacks(File({
- '_updated': 1234
- }))
- fixture.create(cachePath)
- fixOwner(cachePath)
- return _createCacheEntryStream(cachePath, {}).then(({
- updateStream: stream,
- updatedLatest: latest
- }) => {
- t.equals(latest, 1234, '`latest` correctly extracted')
- t.ok(stream, 'returned a stream')
- return getStream.array(stream).then(results => {
- t.deepEquals(results, [], 'no results')
- })
- })
-})
-
-test('createCacheEntryStream missing cache', t => {
- setup()
- const cachePath = path.join(CACHE_DIR, '.cache.json')
- return _createCacheEntryStream(cachePath, {}).then(
- () => { throw new Error('should not succeed') },
- err => {
- t.ok(err, 'returned an error because there was no cache')
- t.equals(err.code, 'ENOENT', 'useful error message')
- }
- )
-})
diff --git a/deps/npm/test/tap/all-package-metadata-entry-stream-unit.js b/deps/npm/test/tap/all-package-metadata-entry-stream-unit.js
deleted file mode 100644
index 164a34f4c5..0000000000
--- a/deps/npm/test/tap/all-package-metadata-entry-stream-unit.js
+++ /dev/null
@@ -1,190 +0,0 @@
-'use strict'
-
-const common = require('../common-tap.js')
-const getStream = require('get-stream')
-const mkdirp = require('mkdirp')
-const mr = require('npm-registry-mock')
-const npm = require('../../')
-const path = require('path')
-const Tacks = require('tacks')
-const test = require('tap').test
-
-const {File} = Tacks
-
-const _createEntryStream = require('../../lib/search/all-package-metadata.js')._createEntryStream
-
-let server
-
-// this test uses a fresh cache for each test block
-// create them all in common.cache so that we can verify
-// them for root-owned files in sudotest
-let CACHE_DIR
-let cacheCounter = 1
-function setup () {
- CACHE_DIR = common.cache + '/' + cacheCounter++
- mkdirp.sync(CACHE_DIR)
- fixOwner(CACHE_DIR)
-}
-
-const chownr = require('chownr')
-const fixOwner = (
- process.getuid && process.getuid() === 0 &&
- process.env.SUDO_UID && process.env.SUDO_GID
-) ? (path) => chownr.sync(path, +process.env.SUDO_UID, +process.env.SUDO_GID)
- : () => {}
-
-test('setup', t => {
- mr({port: common.port, throwOnUnmatched: true}, (err, s) => {
- t.ifError(err, 'registry mocked successfully')
- npm.load({ cache: CACHE_DIR, registry: common.registry }, err => {
- t.ifError(err, 'npm loaded successfully')
- server = s
- t.pass('all set up')
- t.done()
- })
- })
-})
-
-test('createEntryStream full request', t => {
- setup()
- const cachePath = path.join(CACHE_DIR, '.cache.json')
- const dataTime = +(new Date())
- server.get('/-/all').once().reply(200, {
- '_updated': dataTime,
- 'bar': { name: 'bar', version: '1.0.0' },
- 'foo': { name: 'foo', version: '1.0.0' }
- }, {
- date: 1234 // should never be used.
- })
- return _createEntryStream(cachePath, 600, {
- registry: common.registry
- }).then(({
- entryStream: stream,
- latest,
- newEntries
- }) => {
- t.equals(latest, dataTime, '`latest` correctly extracted')
- t.ok(newEntries, 'new entries need to be written to cache')
- t.ok(stream, 'returned a stream')
- return getStream.array(stream)
- }).then(results => {
- t.deepEquals(results, [{
- name: 'bar',
- version: '1.0.0'
- }, {
- name: 'foo',
- version: '1.0.0'
- }])
- server.done()
- })
-})
-
-test('createEntryStream cache only', function (t) {
- setup()
- const now = Date.now()
- const cacheTime = now - 100000
- const cachePath = path.join(CACHE_DIR, '.cache.json')
- const fixture = new Tacks(File({
- '_updated': cacheTime,
- bar: { name: 'bar', version: '1.0.0' },
- cool: { name: 'cool', version: '1.0.0' },
- foo: { name: 'foo', version: '2.0.0' },
- other: { name: 'other', version: '1.0.0' }
- }))
- fixture.create(cachePath)
- fixOwner(cachePath)
- return _createEntryStream(cachePath, 600, {
- registry: common.registry
- }).then(({
- entryStream: stream,
- latest,
- newEntries
- }) => {
- t.equals(latest, cacheTime, '`latest` is cache time')
- t.ok(stream, 'returned a stream')
- t.notOk(newEntries, 'cache only means no need to write to cache')
- return getStream.array(stream)
- }).then(results => {
- t.deepEquals(
- results.map(function (pkg) { return pkg.name }),
- ['bar', 'cool', 'foo', 'other'],
- 'packages deduped and sorted'
- )
- server.done()
- })
-})
-
-test('createEntryStream merged stream', function (t) {
- setup()
- const now = Date.now()
- const cacheTime = now - 6000000
- server.get('/-/all/since?stale=update_after&startkey=' + cacheTime).once().reply(200, {
- 'bar': { name: 'bar', version: '2.0.0' },
- 'car': { name: 'car', version: '1.0.0' },
- 'foo': { name: 'foo', version: '1.0.0' }
- }, {
- date: (new Date(now)).toISOString()
- })
- const cachePath = path.join(CACHE_DIR, '.cache.json')
- const fixture = new Tacks(File({
- '_updated': cacheTime,
- bar: { name: 'bar', version: '1.0.0' },
- cool: { name: 'cool', version: '1.0.0' },
- foo: { name: 'foo', version: '2.0.0' },
- other: { name: 'other', version: '1.0.0' }
- }))
- fixture.create(cachePath)
- fixOwner(cachePath)
- return _createEntryStream(cachePath, 600, {
- registry: common.registry
- }).then(({
- entryStream: stream,
- latest,
- newEntries
- }) => {
- t.equals(latest, now, '`latest` correctly extracted from header')
- t.ok(stream, 'returned a stream')
- t.ok(newEntries, 'cache update means entries should be written')
- return getStream.array(stream)
- }).then(results => {
- t.deepEquals(
- results.map(function (pkg) { return pkg.name }),
- ['bar', 'car', 'cool', 'foo', 'other'],
- 'packages deduped and sorted'
- )
- t.deepEquals(results[0], {
- name: 'bar',
- version: '2.0.0'
- }, 'update stream version wins on dedupe')
- t.deepEquals(results[3], {
- name: 'foo',
- version: '1.0.0'
- }, 'update stream version wins on dedupe even when the newer one has a lower semver.')
- server.done()
- })
-})
-
-test('createEntryStream no sources', function (t) {
- setup()
- const cachePath = path.join(CACHE_DIR, '.cache.json')
- server.get('/-/all').once().reply(404, {})
- return _createEntryStream(cachePath, 600, {
- registry: common.registry
- }).then(({
- entryStream: stream,
- latest,
- newEntries
- }) => {
- throw new Error('should not succeed')
- }, err => {
- t.ok(err, 'no sources, got an error')
- t.match(err.message, /No search sources available/, 'useful error message')
- }).then(() => {
- server.done()
- })
-})
-
-test('cleanup', function (t) {
- server.close()
- t.done()
-})
diff --git a/deps/npm/test/tap/all-package-metadata-update-stream-unit.js b/deps/npm/test/tap/all-package-metadata-update-stream-unit.js
deleted file mode 100644
index 126fe9d398..0000000000
--- a/deps/npm/test/tap/all-package-metadata-update-stream-unit.js
+++ /dev/null
@@ -1,176 +0,0 @@
-'use strict'
-
-const common = require('../common-tap.js')
-const getStream = require('get-stream')
-const npm = require('../../')
-const test = require('tap').test
-const mkdirp = require('mkdirp')
-const mr = require('npm-registry-mock')
-
-var _createEntryUpdateStream = require('../../lib/search/all-package-metadata.js')._createEntryUpdateStream
-
-var server
-
-// this test uses a fresh cache for each test block
-// create them all in common.cache so that we can verify
-// them for root-owned files in sudotest
-let CACHE_DIR
-let cacheCounter = 1
-function setup () {
- CACHE_DIR = common.cache + '/' + cacheCounter++
- mkdirp.sync(CACHE_DIR)
- fixOwner(CACHE_DIR)
-}
-
-const chownr = require('chownr')
-
-const fixOwner = (
- process.getuid && process.getuid() === 0 &&
- process.env.SUDO_UID && process.env.SUDO_GID
-) ? (path) => chownr.sync(path, +process.env.SUDO_UID, +process.env.SUDO_GID)
- : () => {}
-
-test('setup', function (t) {
- mr({port: common.port, throwOnUnmatched: true}, function (err, s) {
- t.ifError(err, 'registry mocked successfully')
- npm.load({ cache: CACHE_DIR, registry: common.registry }, function (err) {
- t.ifError(err, 'npm loaded successfully')
- server = s
- t.pass('all set up')
- t.done()
- })
- })
-})
-
-test('createEntryUpdateStream full request', function (t) {
- setup()
- server.get('/-/all').once().reply(200, {
- '_updated': 1234,
- 'bar': { name: 'bar', version: '1.0.0' },
- 'foo': { name: 'foo', version: '1.0.0' }
- }, {
- date: Date.now() // should never be used.
- })
- return _createEntryUpdateStream(600, 0, {
- registry: common.registry
- }).then(({
- updateStream: stream,
- updatedLatest: latest
- }) => {
- t.equals(latest, 1234, '`latest` correctly extracted')
- t.ok(stream, 'returned a stream')
- return getStream.array(stream)
- }).then(results => {
- t.deepEquals(results, [{
- name: 'bar',
- version: '1.0.0'
- }, {
- name: 'foo',
- version: '1.0.0'
- }])
- server.done()
- })
-})
-
-test('createEntryUpdateStream partial update', function (t) {
- setup()
- var now = Date.now()
- server.get('/-/all/since?stale=update_after&startkey=1234').once().reply(200, {
- 'bar': { name: 'bar', version: '1.0.0' },
- 'foo': { name: 'foo', version: '1.0.0' }
- }, {
- date: (new Date(now)).toISOString()
- })
- return _createEntryUpdateStream(600, 1234, {
- registry: common.registry
- }).then(({
- updateStream: stream,
- updatedLatest: latest
- }) => {
- t.equals(latest, now, '`latest` correctly extracted from header')
- t.ok(stream, 'returned a stream')
- return getStream.array(stream)
- }).then(results => {
- t.deepEquals(results, [{
- name: 'bar',
- version: '1.0.0'
- }, {
- name: 'foo',
- version: '1.0.0'
- }])
- server.done()
- })
-})
-
-test('createEntryUpdateStream authed request', function (t) {
- setup()
- var token = 'thisisanauthtoken'
- server.get('/-/all', { authorization: 'Bearer ' + token }).once().reply(200, {
- '_updated': 1234,
- 'bar': { name: 'bar', version: '1.0.0' },
- 'foo': { name: 'foo', version: '1.0.0' }
- }, {
- date: Date.now() // should never be used.
- })
- return _createEntryUpdateStream(600, 0, {
- registry: common.registry,
- token
- }).then(({
- updateStream: stream,
- updatedLatest: latest
- }) => {
- t.equals(latest, 1234, '`latest` correctly extracted')
- t.ok(stream, 'returned a stream')
- return getStream.array(stream)
- }).then(results => {
- t.deepEquals(results, [{
- name: 'bar',
- version: '1.0.0'
- }, {
- name: 'foo',
- version: '1.0.0'
- }])
- server.done()
- })
-})
-
-test('createEntryUpdateStream bad auth', function (t) {
- setup()
- var token = 'thisisanauthtoken'
- server.get('/-/all', { authorization: 'Bearer ' + token }).once().reply(401, {
- error: 'unauthorized search request'
- })
- return _createEntryUpdateStream(600, 0, {
- registry: common.registry,
- token
- }).then(() => {
- throw new Error('should not succeed')
- }, err => {
- t.ok(err, 'got an error from auth failure')
- t.match(err, /unauthorized/, 'failure message from request used')
- }).then(() => {
- server.done()
- })
-})
-
-test('createEntryUpdateStream not stale', function (t) {
- setup()
- var now = Date.now()
- var staleness = 600
- return _createEntryUpdateStream(staleness, now, {
- registry: common.registry
- }).then(({
- updateStream: stream,
- updatedLatest: latest
- }) => {
- t.notOk(stream, 'no stream returned')
- t.notOk(latest, 'no latest returned')
- server.done()
- t.end()
- })
-})
-
-test('cleanup', function (t) {
- server.close()
- t.done()
-})
diff --git a/deps/npm/test/tap/all-package-metadata-write-stream-unit.js b/deps/npm/test/tap/all-package-metadata-write-stream-unit.js
deleted file mode 100644
index 8cdfe96da0..0000000000
--- a/deps/npm/test/tap/all-package-metadata-write-stream-unit.js
+++ /dev/null
@@ -1,125 +0,0 @@
-'use strict'
-
-const common = require('../common-tap.js')
-const getStream = require('get-stream')
-const npm = require('../../')
-const test = require('tap').test
-const mkdirp = require('mkdirp')
-const path = require('path')
-const fs = require('fs')
-const ms = require('mississippi')
-
-const _createCacheWriteStream = require('../../lib/search/all-package-metadata.js')._createCacheWriteStream
-
-// this test uses a fresh cache for each test block
-// create them all in common.cache so that we can verify
-// them for root-owned files in sudotest
-let CACHE_DIR
-let cacheCounter = 1
-function setup () {
- CACHE_DIR = common.cache + '/' + cacheCounter++
- mkdirp.sync(CACHE_DIR)
- fixOwner(CACHE_DIR)
-}
-
-const chownr = require('chownr')
-const fixOwner = (
- process.getuid && process.getuid() === 0 &&
- process.env.SUDO_UID && process.env.SUDO_GID
-) ? (path) => chownr.sync(path, +process.env.SUDO_UID, +process.env.SUDO_GID)
- : () => {}
-
-function fromArray (array) {
- var idx = 0
- return ms.from.obj(function (size, next) {
- next(null, array[idx++] || null)
- })
-}
-
-test('setup', function (t) {
- // This is pretty much only used for `getCacheStat` in the implementation
- npm.load({ cache: CACHE_DIR, registry: common.registry }, function (err) {
- t.ifError(err, 'npm successfully loaded')
- t.done()
- })
-})
-
-test('createCacheEntryStream basic', function (t) {
- setup()
- var cachePath = path.join(CACHE_DIR, '.cache.json')
- var latest = 12345
- var src = [
- { name: 'bar', version: '1.0.0' },
- { name: 'foo', version: '1.0.0' }
- ]
- var srcStream = fromArray(src)
- return _createCacheWriteStream(cachePath, latest, {
- cache: CACHE_DIR
- }).then(stream => {
- t.ok(stream, 'returned a stream')
- stream = ms.pipeline.obj(srcStream, stream)
- return getStream.array(stream)
- }).then(results => {
- t.deepEquals(results, [{
- name: 'bar',
- version: '1.0.0'
- }, {
- name: 'foo',
- version: '1.0.0'
- }])
- var fileData = JSON.parse(fs.readFileSync(cachePath))
- t.ok(fileData, 'cache contents written to the right file')
- t.deepEquals(fileData, {
- '_updated': latest,
- bar: {
- name: 'bar',
- version: '1.0.0'
- },
- foo: {
- name: 'foo',
- version: '1.0.0'
- }
- }, 'cache contents based on what was written')
- })
-})
-
-test('createCacheEntryStream no entries', function (t) {
- setup()
- const cachePath = path.join(CACHE_DIR, '.cache.json')
- var latest = 12345
- const src = []
- const srcStream = fromArray(src)
- return _createCacheWriteStream(cachePath, latest, {
- cache: CACHE_DIR
- }).then(stream => {
- t.ok(stream, 'returned a stream')
- stream = ms.pipeline.obj(srcStream, stream)
- stream.resume()
- return getStream(stream)
- }).then(() => {
- const fileData = JSON.parse(fs.readFileSync(cachePath))
- t.ok(fileData, 'cache file exists and has stuff in it')
- })
-})
-
-test('createCacheEntryStream missing cache dir', function (t) {
- setup()
- var cachePath = path.join(CACHE_DIR, '.cache.json')
- var latest = 12345
- var src = []
- var srcStream = fromArray(src)
- return _createCacheWriteStream(cachePath, latest, {
- cache: CACHE_DIR
- }).then(stream => {
- t.ok(stream, 'returned a stream')
- stream = ms.pipeline.obj(srcStream, stream)
- return getStream.array(stream)
- }).then(res => {
- t.deepEqual(res, [], 'no data returned')
- var fileData = JSON.parse(fs.readFileSync(cachePath))
- t.ok(fileData, 'cache contents written to the right file')
- t.deepEquals(fileData, {
- '_updated': latest
- }, 'cache still contains `_updated`')
- })
-})
diff --git a/deps/npm/test/tap/all-package-metadata.js b/deps/npm/test/tap/all-package-metadata.js
deleted file mode 100644
index 75afa9bad2..0000000000
--- a/deps/npm/test/tap/all-package-metadata.js
+++ /dev/null
@@ -1,212 +0,0 @@
-'use strict'
-
-const common = require('../common-tap.js')
-const npm = require('../../')
-const test = require('tap').test
-const mkdirp = require('mkdirp')
-const rimraf = require('rimraf')
-const path = require('path')
-const fs = require('fs')
-const cacheFile = require('npm-cache-filename')
-const mr = require('npm-registry-mock')
-const ms = require('mississippi')
-const Tacks = require('tacks')
-const File = Tacks.File
-
-const allPackageMetadata = require('../../lib/search/all-package-metadata.js')
-
-const PKG_DIR = path.resolve(common.cache, 'update-index')
-const CACHE_DIR = path.resolve(PKG_DIR, 'cache', '_cacache')
-let cacheBase
-let cachePath
-
-let server
-
-function setup () {
- mkdirp.sync(cacheBase)
-}
-
-function cleanup (cb) {
- rimraf(PKG_DIR, cb)
-}
-
-test('setup', function (t) {
- mr({port: common.port, throwOnUnmatched: true}, function (err, s) {
- t.ifError(err, 'registry mocked successfully')
- npm.load({ cache: path.dirname(CACHE_DIR), registry: common.registry }, function (err) {
- t.ifError(err, 'npm loaded successfully')
- npm.config.set('cache', path.dirname(CACHE_DIR))
- cacheBase = cacheFile(npm.config.get('cache'))(common.registry + '/-/all')
- cachePath = path.join(cacheBase, '.cache.json')
- server = s
- t.pass('all set up')
- t.done()
- })
- })
-})
-
-test('allPackageMetadata full request', function (t) {
- setup()
- var updated = Date.now()
- server.get('/-/all').once().reply(200, {
- '_updated': 1234,
- 'bar': { name: 'bar', version: '1.0.0' },
- 'foo': { name: 'foo', version: '1.0.0' }
- }, {
- date: updated
- })
- var stream = allPackageMetadata({
- cache: CACHE_DIR,
- registry: common.registry,
- staleness: 600
- })
- t.ok(stream, 'returned a stream')
- var results = []
- stream.on('data', function (pkg) {
- results.push(pkg)
- })
- ms.finished(stream, function (err) {
- if (err) throw err
- t.deepEquals(results, [{
- name: 'bar',
- version: '1.0.0'
- }, {
- name: 'foo',
- version: '1.0.0'
- }])
- var fileData = JSON.parse(fs.readFileSync(cachePath))
- t.ok(fileData, 'cache contents written to the right file')
- t.deepEquals(fileData, {
- '_updated': 1234,
- bar: {
- name: 'bar',
- version: '1.0.0'
- },
- foo: {
- name: 'foo',
- version: '1.0.0'
- }
- }, 'cache contents based on what was written')
- server.done()
- cleanup(t.end)
- })
-})
-
-test('allPackageMetadata cache only', function (t) {
- setup()
- var now = Date.now()
- var cacheContents = {
- '_updated': now,
- bar: { name: 'bar', version: '1.0.0' },
- cool: { name: 'cool', version: '1.0.0' },
- foo: { name: 'foo', version: '2.0.0' },
- other: { name: 'other', version: '1.0.0' }
- }
- var fixture = new Tacks(File(cacheContents))
- fixture.create(cachePath)
- var stream = allPackageMetadata({
- cache: CACHE_DIR,
- registry: common.registry,
- staleness: 10000000
- })
- t.ok(stream, 'returned a stream')
- var results = []
- stream.on('data', function (pkg) {
- results.push(pkg)
- })
- ms.finished(stream, function (err) {
- t.ifError(err, 'stream finished without error')
- t.deepEquals(
- results.map(function (pkg) { return pkg.name }),
- ['bar', 'cool', 'foo', 'other'],
- 'packages deduped and sorted, without _updated'
- )
- var fileData = JSON.parse(fs.readFileSync(cachePath))
- t.ok(fileData, 'cache contents written to the right file')
- t.deepEquals(fileData, cacheContents, 'cacheContents written directly')
- server.done()
- cleanup(t.end)
- })
-})
-
-test('createEntryStream merged stream', function (t) {
- setup()
- var now = Date.now()
- var cacheTime = now - 601000
- var reqTime = (new Date(now)).toISOString()
- server.get('/-/all/since?stale=update_after&startkey=' + cacheTime).once().reply(200, {
- 'bar': { name: 'bar', version: '2.0.0' },
- 'car': { name: 'car', version: '1.0.0' },
- 'foo': { name: 'foo', version: '1.0.0' }
- }, {
- date: reqTime
- })
- var fixture = new Tacks(File({
- '_updated': cacheTime,
- bar: { name: 'bar', version: '1.0.0' },
- cool: { name: 'cool', version: '1.0.0' },
- foo: { name: 'foo', version: '2.0.0' },
- other: { name: 'other', version: '1.0.0' }
- }))
- fixture.create(cachePath)
- var stream = allPackageMetadata({
- cache: CACHE_DIR,
- registry: common.registry,
- staleness: 600
- })
- t.ok(stream, 'returned a stream')
- var results = []
- stream.on('data', function (pkg) {
- results.push(pkg)
- })
- ms.finished(stream, function (err) {
- t.ifError(err, 'stream finished without error')
- t.deepEquals(
- results.map(function (pkg) { return pkg.name }),
- ['bar', 'car', 'cool', 'foo', 'other'],
- 'packages deduped and sorted'
- )
- t.deepEquals(results[0], {
- name: 'bar',
- version: '2.0.0'
- }, 'update stream version wins on dedupe')
- t.deepEquals(results[3], {
- name: 'foo',
- version: '1.0.0'
- }, 'update stream version wins on dedupe even when the newer one has a lower semver.')
- var cacheContents = {
- '_updated': Date.parse(reqTime),
- bar: { name: 'bar', version: '2.0.0' },
- car: { name: 'car', version: '1.0.0' },
- cool: { name: 'cool', version: '1.0.0' },
- foo: { name: 'foo', version: '1.0.0' },
- other: { name: 'other', version: '1.0.0' }
- }
- var fileData = JSON.parse(fs.readFileSync(cachePath))
- t.ok(fileData, 'cache contents written to the right file')
- t.deepEquals(fileData, cacheContents, 'cache updated correctly')
- server.done()
- cleanup(t.end)
- })
-})
-
-test('allPackageMetadata no sources', function (t) {
- setup()
- server.get('/-/all').once().reply(404, {})
- var stream = allPackageMetadata({
- cache: CACHE_DIR,
- registry: common.registry,
- staleness: 600
- })
- ms.finished(stream, function (err) {
- t.ok(err, 'no sources, got an error')
- t.match(err.message, /No search sources available/, 'useful error message')
- server.done()
- cleanup(t.end)
- })
-})
-
-test('cleanup', function (t) {
- server.close()
- cleanup(t.end)
-})
diff --git a/deps/npm/test/tap/anon-cli-metrics.js b/deps/npm/test/tap/anon-cli-metrics.js
deleted file mode 100644
index 729d9e607a..0000000000
--- a/deps/npm/test/tap/anon-cli-metrics.js
+++ /dev/null
@@ -1,151 +0,0 @@
-'use strict'
-var path = require('path')
-var fs = require('graceful-fs')
-var rimraf = require('rimraf')
-var test = require('tap').test
-var mr = require('npm-registry-mock')
-var Tacks = require('tacks')
-var File = Tacks.File
-var Dir = Tacks.Dir
-var common = require('../common-tap.js')
-
-var basedir = common.pkg
-var testdir = path.join(basedir, 'testdir')
-var cachedir = common.cache
-var globaldir = path.join(basedir, 'global')
-var tmpdir = path.join(basedir, 'tmp')
-var metricsFile = path.join(cachedir, 'anonymous-cli-metrics.json')
-
-var conf = {
- cwd: testdir,
- env: Object.assign({}, process.env, {
- npm_config_cache: cachedir,
- npm_config_tmp: tmpdir,
- npm_config_prefix: globaldir,
- npm_config_registry: common.registry,
- npm_config_metrics_registry: null,
- npm_config_loglevel: 'warn'
- })
-}
-
-var server
-var fixture = new Tacks(Dir({
- cache: Dir(),
- global: Dir(),
- tmp: Dir(),
- testdir: Dir({
- failure: Dir({
- 'package.json': File({
- name: 'failure',
- version: '1.0.0',
- scripts: {
- preinstall: 'false'
- }
- })
- }),
- success: Dir({
- 'package.json': File({
- name: 'success',
- version: '1.0.0'
- })
- }),
- slow: Dir({
- 'package.json': File({
- name: 'slow',
- version: '1.0.0',
- scripts: {
- preinstall: 'node -e "setTimeout(function(){}, 500)"'
- }
- })
- }),
- 'package.json': File({
- name: 'anon-cli-metrics-test',
- version: '1.0.0'
- })
- })
-}))
-
-function setup () {
- cleanup()
- fixture.create(basedir)
-}
-
-function cleanup () {
- fixture.remove(basedir)
-}
-
-function reset () {
- rimraf.sync(testdir + '/' + 'node_modules')
-}
-
-test('setup', function (t) {
- setup()
- mr({port: common.port, throwOnUnmatched: true}, function (err, s) {
- if (err) throw err
- server = s
- server.filteringPathRegEx(/([/]-[/]npm[/]anon-metrics[/]v1[/]).*/, '$1:id')
- server.filteringRequestBody(function (body) {
- var metrics = typeof body === 'string' ? JSON.parse(body) : body
- delete metrics.from
- delete metrics.to
- return JSON.stringify(metrics)
- })
- t.done()
- })
-})
-
-test('record success', function (t) {
- common.npm(['install', '--no-save', '--no-send-metrics', 'file:success'], conf, function (err, code, stdout, stderr) {
- if (err) throw err
- t.is(code, 0, 'always succeeding install succeeded')
- t.comment(stdout.trim())
- t.comment(stderr.trim())
- var data = JSON.parse(fs.readFileSync(metricsFile))
- t.is(data.metrics.successfulInstalls, 1, 'successes')
- t.is(data.metrics.failedInstalls, 0, 'failures')
- t.done()
- })
-})
-
-test('record failure', function (t) {
- reset()
- server.put('/-/npm/anon-metrics/v1/:id', {
- successfulInstalls: 1,
- failedInstalls: 0
- }).reply(500, {ok: false})
- common.npm(['install', '--no-save', '--send-metrics', 'file:failure'], conf, function (err, code, stdout, stderr) {
- if (err) throw err
- t.notEqual(code, 0, 'always failing install fails')
- t.comment(stdout.trim())
- t.comment(stderr.trim())
- var data = JSON.parse(fs.readFileSync(metricsFile))
- t.is(data.metrics.successfulInstalls, 1, 'successes')
- t.is(data.metrics.failedInstalls, 1, 'failures')
- t.done()
- })
-})
-
-test('report', function (t) {
- reset()
- server.put('/-/npm/anon-metrics/v1/:id', {
- successfulInstalls: 1,
- failedInstalls: 1
- }).reply(200, {ok: true})
- common.npm(['install', '--no-save', '--send-metrics', 'file:slow'], conf, function (err, code, stdout, stderr) {
- if (err) throw err
- t.is(code, 0, 'command ran ok')
- t.comment(stdout.trim())
- t.comment(stderr.trim())
- // todo check mock registry for post
- var data = JSON.parse(fs.readFileSync(metricsFile))
- t.is(data.metrics.successfulInstalls, 1, 'successes')
- t.is(data.metrics.failedInstalls, 0, 'failures')
- t.done()
- })
-})
-
-test('cleanup', function (t) {
- server.close()
- cleanup()
- t.done()
-})
diff --git a/deps/npm/test/tap/audit-fix.js b/deps/npm/test/tap/audit-fix.js
deleted file mode 100644
index a832078ae9..0000000000
--- a/deps/npm/test/tap/audit-fix.js
+++ /dev/null
@@ -1,829 +0,0 @@
-'use strict'
-
-const BB = require('bluebird')
-
-const common = BB.promisifyAll(require('../common-tap.js'))
-const fs = require('fs')
-const mr = common.fakeRegistry.compat
-const path = require('path')
-const rimraf = BB.promisify(require('rimraf'))
-const Tacks = require('tacks')
-const tap = require('tap')
-const test = tap.test
-
-const Dir = Tacks.Dir
-const File = Tacks.File
-const testDir = common.pkg
-
-const EXEC_OPTS = { cwd: testDir }
-
-tap.tearDown(function () {
- process.chdir(__dirname)
- try {
- rimraf.sync(testDir)
- } catch (e) {
- if (process.platform !== 'win32') {
- throw e
- }
- }
-})
-
-function tmock (t) {
- return mr({port: common.port}).then(s => {
- t.tearDown(function () {
- s.done()
- s.close()
- rimraf.sync(testDir)
- })
- return s
- })
-}
-
-test('fixes shallow vulnerabilities', t => {
- const fixture = new Tacks(new Dir({
- 'package.json': new File({
- name: 'foo',
- version: '1.0.0',
- dependencies: {
- baddep: '1.0.0'
- }
- })
- }))
- fixture.create(testDir)
- return tmock(t).then(srv => {
- srv.filteringRequestBody(req => 'ok')
- srv.post('/-/npm/v1/security/audits/quick', 'ok').reply(200, 'yeah')
- srv.get('/baddep').twice().reply(200, {
- name: 'baddep',
- 'dist-tags': {
- 'latest': '1.2.3'
- },
- versions: {
- '1.0.0': {
- name: 'baddep',
- version: '1.0.0',
- _hasShrinkwrap: false,
- dist: {
- shasum: 'deadbeef',
- tarball: common.registry + '/idk/-/idk-1.0.0.tgz'
- }
- },
- '1.2.3': {
- name: 'baddep',
- version: '1.2.3',
- _hasShrinkwrap: false,
- dist: {
- shasum: 'deadbeef',
- tarball: common.registry + '/idk/-/idk-1.2.3.tgz'
- }
- }
- }
- })
- return common.npm([
- 'install',
- '--audit',
- '--json',
- '--package-lock-only',
- '--registry', common.registry,
- '--cache', path.join(testDir, 'npm-cache')
- ], EXEC_OPTS).then(([code, stdout, stderr]) => {
- t.equal(code, 0, 'exited OK')
- t.comment(stderr)
- t.similar(JSON.parse(stdout), {
- added: [{
- action: 'add',
- name: 'baddep',
- version: '1.0.0'
- }]
- }, 'installed bad version')
- srv.filteringRequestBody(req => 'ok')
- srv.post('/-/npm/v1/security/audits', 'ok').reply(200, {
- actions: [{
- action: 'update',
- module: 'baddep',
- target: '1.2.3',
- resolves: [{path: 'baddep'}]
- }],
- metadata: {
- vulnerabilities: {
- critical: 1
- }
- }
- })
- return common.npm([
- 'audit', 'fix',
- '--package-lock-only',
- '--json',
- '--registry', common.registry,
- '--cache', path.join(testDir, 'npm-cache')
- ], EXEC_OPTS).then(([code, stdout, stderr]) => {
- t.equal(code, 0, 'exited OK')
- t.comment(stderr)
- t.similar(JSON.parse(stdout), {
- added: [{
- action: 'add',
- name: 'baddep',
- version: '1.2.3'
- }]
- }, 'reported dependency update')
- t.similar(JSON.parse(fs.readFileSync(path.join(testDir, 'package-lock.json'), 'utf8')), {
- dependencies: {
- baddep: {
- version: '1.2.3',
- resolved: common.registry + '/idk/-/idk-1.2.3.tgz',
- integrity: 'sha1-3q2+7w=='
- }
- }
- }, 'pkglock updated correctly')
- })
- })
- })
-})
-
-test('fixes nested dep vulnerabilities', t => {
- const fixture = new Tacks(new Dir({
- 'package.json': new File({
- name: 'foo',
- version: '1.0.0',
- dependencies: {
- gooddep: '^1.0.0'
- }
- })
- }))
- fixture.create(testDir)
- return tmock(t).then(srv => {
- srv.filteringRequestBody(req => 'ok')
- srv.post('/-/npm/v1/security/audits/quick', 'ok').reply(200, 'yeah')
- srv.get('/baddep').reply(200, {
- name: 'baddep',
- 'dist-tags': {
- 'latest': '1.0.0'
- },
- versions: {
- '1.0.0': {
- name: 'baddep',
- version: '1.0.0',
- _hasShrinkwrap: false,
- dist: {
- shasum: 'c0ffee',
- integrity: 'sha1-c0ffee',
- tarball: common.registry + '/baddep/-/baddep-1.0.0.tgz'
- }
- },
- '1.2.3': {
- name: 'baddep',
- version: '1.2.3',
- _hasShrinkwrap: false,
- dist: {
- shasum: 'bada55',
- integrity: 'sha1-bada55',
- tarball: common.registry + '/baddep/-/baddep-1.2.3.tgz'
- }
- }
- }
- })
-
- srv.get('/gooddep').reply(200, {
- name: 'gooddep',
- 'dist-tags': {
- 'latest': '1.0.0'
- },
- versions: {
- '1.0.0': {
- name: 'gooddep',
- version: '1.0.0',
- dependencies: {
- baddep: '^1.0.0'
- },
- _hasShrinkwrap: false,
- dist: {
- shasum: '1234',
- tarball: common.registry + '/gooddep/-/gooddep-1.0.0.tgz'
- }
- },
- '1.2.3': {
- name: 'gooddep',
- version: '1.2.3',
- _hasShrinkwrap: false,
- dependencies: {
- baddep: '^1.0.0'
- },
- dist: {
- shasum: '123456',
- tarball: common.registry + '/gooddep/-/gooddep-1.2.3.tgz'
- }
- }
- }
- })
-
- return common.npm([
- 'install',
- '--audit',
- '--json',
- '--global-style',
- '--package-lock-only',
- '--registry', common.registry,
- '--cache', path.join(testDir, 'npm-cache')
- ], EXEC_OPTS).then(([code, stdout, stderr]) => {
- t.equal(code, 0, 'exited OK')
- t.comment(stderr)
- t.similar(JSON.parse(stdout), {
- added: [{
- action: 'add',
- name: 'baddep',
- version: '1.0.0'
- }, {
- action: 'add',
- name: 'gooddep',
- version: '1.0.0'
- }]
- }, 'installed bad version')
- srv.filteringRequestBody(req => 'ok')
- srv.post('/-/npm/v1/security/audits', 'ok').reply(200, {
- actions: [{
- action: 'update',
- module: 'baddep',
- target: '1.2.3',
- resolves: [{path: 'gooddep>baddep'}]
- }],
- metadata: {
- vulnerabilities: {
- critical: 1
- }
- }
- })
- return common.npm([
- 'audit', 'fix',
- '--package-lock-only',
- '--offline',
- '--json',
- '--global-style',
- '--registry', common.registry,
- '--cache', path.join(testDir, 'npm-cache')
- ], EXEC_OPTS).then(([code, stdout, stderr]) => {
- t.equal(code, 0, 'exited OK')
- t.comment(stderr)
- t.similar(JSON.parse(stdout), {
- added: [{
- action: 'add',
- name: 'baddep',
- version: '1.2.3'
- }, {
- action: 'add',
- name: 'gooddep',
- version: '1.0.0'
- }]
- }, 'reported dependency update')
- t.similar(JSON.parse(fs.readFileSync(path.join(testDir, 'package-lock.json'), 'utf8')), {
- dependencies: {
- gooddep: {
- version: '1.0.0',
- resolved: common.registry + '/gooddep/-/gooddep-1.0.0.tgz',
- integrity: 'sha1-EjQ=',
- requires: {
- baddep: '^1.0.0'
- },
- dependencies: {
- baddep: {
- version: '1.2.3',
- resolved: common.registry + '/baddep/-/baddep-1.2.3.tgz',
- integrity: 'sha1-bada55'
- }
- }
- }
- }
- }, 'pkglock updated correctly')
- })
- })
- })
-})
-
-test('no semver-major without --force', t => {
- const fixture = new Tacks(new Dir({
- 'package.json': new File({
- name: 'foo',
- version: '1.0.0',
- dependencies: {
- baddep: '1.0.0'
- }
- })
- }))
- fixture.create(testDir)
- return tmock(t).then(srv => {
- srv.filteringRequestBody(req => 'ok')
- srv.post('/-/npm/v1/security/audits/quick', 'ok').reply(200, 'yeah')
- srv.get('/baddep').twice().reply(200, {
- name: 'baddep',
- 'dist-tags': {
- 'latest': '2.0.0'
- },
- versions: {
- '1.0.0': {
- name: 'baddep',
- version: '1.0.0',
- _hasShrinkwrap: false,
- dist: {
- shasum: 'deadbeef',
- tarball: common.registry + '/idk/-/idk-1.0.0.tgz'
- }
- },
- '2.0.0': {
- name: 'baddep',
- version: '2.0.0',
- _hasShrinkwrap: false,
- dist: {
- shasum: 'deadbeef',
- tarball: common.registry + '/idk/-/idk-2.0.0.tgz'
- }
- }
- }
- })
- return common.npm([
- 'install',
- '--audit',
- '--json',
- '--package-lock-only',
- '--registry', common.registry,
- '--cache', path.join(testDir, 'npm-cache')
- ], EXEC_OPTS).then(([code, stdout, stderr]) => {
- t.equal(code, 0, 'exited OK')
- t.comment(stderr)
- t.similar(JSON.parse(stdout), {
- added: [{
- action: 'add',
- name: 'baddep',
- version: '1.0.0'
- }]
- }, 'installed bad version')
- srv.filteringRequestBody(req => 'ok')
- srv.post('/-/npm/v1/security/audits', 'ok').reply(200, {
- actions: [{
- action: 'install',
- module: 'baddep',
- target: '2.0.0',
- isMajor: true,
- resolves: [{path: 'baddep'}]
- }],
- metadata: {
- vulnerabilities: {
- critical: 1
- }
- }
- })
- return common.npm([
- 'audit', 'fix',
- '--package-lock-only',
- '--registry', common.registry,
- '--loglevel=warn',
- '--cache', path.join(testDir, 'npm-cache')
- ], EXEC_OPTS).then(([code, stdout, stderr]) => {
- t.equal(code, 0, 'exited OK')
- t.comment(stderr)
- t.match(stdout, /breaking changes/, 'informs about semver-major')
- t.match(stdout, /npm audit fix --force/, 'recommends --force')
- t.similar(JSON.parse(fs.readFileSync(path.join(testDir, 'package-lock.json'), 'utf8')), {
- dependencies: {
- baddep: {
- version: '1.0.0'
- }
- }
- }, 'pkglock not updated')
- })
- })
- })
-})
-
-test('semver-major when --force', t => {
- const fixture = new Tacks(new Dir({
- 'package.json': new File({
- name: 'foo',
- version: '1.0.0',
- dependencies: {
- baddep: '1.0.0'
- }
- })
- }))
- fixture.create(testDir)
- return tmock(t).then(srv => {
- srv.filteringRequestBody(req => 'ok')
- srv.post('/-/npm/v1/security/audits/quick', 'ok').reply(200, 'yeah')
- srv.get('/baddep').twice().reply(200, {
- name: 'baddep',
- 'dist-tags': {
- 'latest': '2.0.0'
- },
- versions: {
- '1.0.0': {
- name: 'baddep',
- version: '1.0.0',
- _hasShrinkwrap: false,
- dist: {
- shasum: 'deadbeef',
- tarball: common.registry + '/idk/-/idk-1.0.0.tgz'
- }
- },
- '2.0.0': {
- name: 'baddep',
- version: '2.0.0',
- _hasShrinkwrap: false,
- dist: {
- shasum: 'deadbeef',
- tarball: common.registry + '/idk/-/idk-2.0.0.tgz'
- }
- }
- }
- })
- return common.npm([
- 'install',
- '--audit',
- '--json',
- '--package-lock-only',
- '--registry', common.registry,
- '--cache', path.join(testDir, 'npm-cache')
- ], EXEC_OPTS).then(([code, stdout, stderr]) => {
- t.equal(code, 0, 'exited OK')
- t.comment(stderr)
- t.similar(JSON.parse(stdout), {
- added: [{
- action: 'add',
- name: 'baddep',
- version: '1.0.0'
- }]
- }, 'installed bad version')
- srv.filteringRequestBody(req => 'ok')
- srv.post('/-/npm/v1/security/audits', 'ok').reply(200, {
- actions: [{
- action: 'install',
- module: 'baddep',
- target: '2.0.0',
- isMajor: true,
- resolves: [{path: 'baddep'}]
- }],
- metadata: {
- vulnerabilities: {
- critical: 1
- }
- }
- })
- return common.npm([
- 'audit', 'fix',
- '--package-lock-only',
- '--registry', common.registry,
- '--force',
- '--cache', path.join(testDir, 'npm-cache')
- ], EXEC_OPTS).then(([code, stdout, stderr]) => {
- t.equal(code, 0, 'exited OK')
- t.comment(stderr)
- t.match(stdout, /breaking changes/, 'informs about semver-major')
- t.similar(JSON.parse(fs.readFileSync(path.join(testDir, 'package-lock.json'), 'utf8')), {
- dependencies: {
- baddep: {
- version: '2.0.0'
- }
- }
- }, 'pkglock not updated')
- })
- })
- })
-})
-
-test('no installs for review-requires', t => {
- const fixture = new Tacks(new Dir({
- 'package.json': new File({
- name: 'foo',
- version: '1.0.0',
- dependencies: {
- baddep: '1.0.0'
- }
- })
- }))
- fixture.create(testDir)
- return tmock(t).then(srv => {
- srv.filteringRequestBody(req => 'k')
- srv.post('/-/npm/v1/security/audits/quick', 'k').reply(200, 'yeah')
- srv.get('/baddep').twice().reply(200, {
- name: 'baddep',
- 'dist-tags': {
- 'latest': '1.2.3'
- },
- versions: {
- '1.0.0': {
- name: 'baddep',
- version: '1.0.0',
- _hasShrinkwrap: false,
- dist: {
- shasum: 'deadbeef',
- tarball: common.registry + '/idk/-/idk-1.0.0.tgz'
- }
- },
- '1.2.3': {
- name: 'baddep',
- version: '1.2.3',
- _hasShrinkwrap: false,
- dist: {
- shasum: 'deadbeef',
- tarball: common.registry + '/idk/-/idk-1.2.3.tgz'
- }
- }
- }
- })
- return common.npm([
- 'install',
- '--audit',
- '--json',
- '--package-lock-only',
- '--registry', common.registry,
- '--cache', path.join(testDir, 'npm-cache')
- ], EXEC_OPTS).then(([code, stdout, stderr]) => {
- t.equal(code, 0, 'exited OK')
- t.comment(stderr)
- t.similar(JSON.parse(stdout), {
- added: [{
- action: 'add',
- name: 'baddep',
- version: '1.0.0'
- }]
- }, 'installed bad version')
- srv.filteringRequestBody(req => 'ok')
- srv.post('/-/npm/v1/security/audits', 'ok').reply(200, {
- actions: [{
- action: 'review',
- module: 'baddep',
- target: '1.2.3',
- resolves: [{path: 'baddep'}]
- }],
- metadata: {
- vulnerabilities: {
- critical: 1
- }
- }
- })
- return common.npm([
- 'audit', 'fix',
- '--package-lock-only',
- '--json',
- '--registry', common.registry,
- '--cache', path.join(testDir, 'npm-cache')
- ], EXEC_OPTS).then(([code, stdout, stderr]) => {
- t.equal(code, 0, 'exited OK')
- t.comment(stderr)
- t.similar(JSON.parse(stdout), {
- added: [{
- action: 'add',
- name: 'baddep',
- version: '1.0.0'
- }]
- }, 'no update for dependency')
- })
- })
- })
-})
-
-test('nothing to fix', t => {
- const fixture = new Tacks(new Dir({
- 'package.json': new File({
- name: 'foo',
- version: '1.0.0',
- dependencies: {
- gooddep: '1.0.0'
- }
- })
- }))
- fixture.create(testDir)
- return tmock(t).then(srv => {
- srv.filteringRequestBody(req => 'ok')
- srv.post('/-/npm/v1/security/audits/quick', 'ok').reply(200, 'yeah')
- srv.get('/gooddep').twice().reply(200, {
- name: 'gooddep',
- 'dist-tags': {
- 'latest': '1.2.3'
- },
- versions: {
- '1.0.0': {
- name: 'gooddep',
- version: '1.0.0',
- _hasShrinkwrap: false,
- dist: {
- shasum: 'deadbeef',
- tarball: common.registry + '/idk/-/idk-1.0.0.tgz'
- }
- },
- '1.2.3': {
- name: 'gooddep',
- version: '1.2.3',
- _hasShrinkwrap: false,
- dist: {
- shasum: 'deadbeef',
- tarball: common.registry + '/idk/-/idk-1.2.3.tgz'
- }
- }
- }
- })
- return common.npm([
- 'install',
- '--audit',
- '--json',
- '--package-lock-only',
- '--registry', common.registry,
- '--cache', path.join(testDir, 'npm-cache')
- ], EXEC_OPTS).then(([code, stdout, stderr]) => {
- t.equal(code, 0, 'exited OK')
- t.comment(stderr)
- t.similar(JSON.parse(stdout), {
- added: [{
- action: 'add',
- name: 'gooddep',
- version: '1.0.0'
- }]
- }, 'installed good version')
- srv.filteringRequestBody(req => 'ok')
- srv.post('/-/npm/v1/security/audits', 'ok').reply(200, {
- actions: [],
- metadata: {
- vulnerabilities: { }
- }
- })
- return common.npm([
- 'audit', 'fix',
- '--package-lock-only',
- '--json',
- '--registry', common.registry,
- '--cache', path.join(testDir, 'npm-cache')
- ], EXEC_OPTS).then(([code, stdout, stderr]) => {
- t.equal(code, 0, 'exited OK')
- t.comment(stderr)
- t.similar(JSON.parse(stdout), {
- added: [{
- action: 'add',
- name: 'gooddep',
- version: '1.0.0'
- }]
- }, 'nothing to update')
- })
- })
- })
-})
-
-test('preserves deep deps dev: true', t => {
- const fixture = new Tacks(new Dir({
- 'package.json': new File({
- name: 'foo',
- version: '1.0.0',
- devDependencies: {
- gooddep: '^1.0.0'
- }
- })
- }))
- fixture.create(testDir)
- return tmock(t).then(srv => {
- srv.filteringRequestBody(req => 'ok')
- srv.post('/-/npm/v1/security/audits/quick', 'ok').reply(200, 'yeah')
- srv.get('/baddep').reply(200, {
- name: 'baddep',
- 'dist-tags': {
- 'latest': '1.0.0'
- },
- versions: {
- '1.0.0': {
- name: 'baddep',
- version: '1.0.0',
- _hasShrinkwrap: false,
- dist: {
- shasum: 'c0ffee',
- integrity: 'sha1-c0ffee',
- tarball: common.registry + '/baddep/-/baddep-1.0.0.tgz'
- }
- },
- '1.2.3': {
- name: 'baddep',
- version: '1.2.3',
- _hasShrinkwrap: false,
- dist: {
- shasum: 'bada55',
- integrity: 'sha1-bada55',
- tarball: common.registry + '/baddep/-/baddep-1.2.3.tgz'
- }
- }
- }
- })
-
- srv.get('/gooddep').reply(200, {
- name: 'gooddep',
- 'dist-tags': {
- 'latest': '1.0.0'
- },
- versions: {
- '1.0.0': {
- name: 'gooddep',
- version: '1.0.0',
- dependencies: {
- baddep: '^1.0.0'
- },
- _hasShrinkwrap: false,
- dist: {
- shasum: '1234',
- tarball: common.registry + '/gooddep/-/gooddep-1.0.0.tgz'
- }
- },
- '1.2.3': {
- name: 'gooddep',
- version: '1.2.3',
- _hasShrinkwrap: false,
- dependencies: {
- baddep: '^1.0.0'
- },
- dist: {
- shasum: '123456',
- tarball: common.registry + '/gooddep/-/gooddep-1.2.3.tgz'
- }
- }
- }
- })
-
- return common.npm([
- 'install',
- '--audit',
- '--json',
- '--global-style',
- '--package-lock-only',
- '--registry', common.registry,
- '--cache', path.join(testDir, 'npm-cache')
- ], EXEC_OPTS).then(([code, stdout, stderr]) => {
- t.equal(code, 0, 'exited OK')
- t.comment(stderr)
- t.similar(JSON.parse(stdout), {
- added: [{
- action: 'add',
- name: 'baddep',
- version: '1.0.0'
- }, {
- action: 'add',
- name: 'gooddep',
- version: '1.0.0'
- }]
- }, 'installed bad version')
- srv.filteringRequestBody(req => 'ok')
- srv.post('/-/npm/v1/security/audits', 'ok').reply(200, {
- actions: [{
- action: 'update',
- module: 'baddep',
- target: '1.2.3',
- resolves: [{path: 'gooddep>baddep'}]
- }],
- metadata: {
- vulnerabilities: {
- critical: 1
- }
- }
- })
- return common.npm([
- 'audit', 'fix',
- '--package-lock-only',
- '--offline',
- '--json',
- '--global-style',
- '--registry', common.registry,
- '--cache', path.join(testDir, 'npm-cache')
- ], EXEC_OPTS).then(([code, stdout, stderr]) => {
- t.equal(code, 0, 'exited OK')
- t.comment(stderr)
- t.similar(JSON.parse(stdout), {
- added: [{
- action: 'add',
- name: 'baddep',
- version: '1.2.3'
- }, {
- action: 'add',
- name: 'gooddep',
- version: '1.0.0'
- }]
- }, 'reported dependency update')
- t.similar(JSON.parse(fs.readFileSync(path.join(testDir, 'package-lock.json'), 'utf8')), {
- dependencies: {
- gooddep: {
- dev: true,
- version: '1.0.0',
- resolved: common.registry + '/gooddep/-/gooddep-1.0.0.tgz',
- integrity: 'sha1-EjQ=',
- requires: {
- baddep: '^1.0.0'
- },
- dependencies: {
- baddep: {
- dev: true,
- version: '1.2.3',
- resolved: common.registry + '/baddep/-/baddep-1.2.3.tgz',
- integrity: 'sha1-bada55'
- }
- }
- }
- }
- }, 'pkglock updated correctly')
- })
- })
- })
-})
-
-test('cleanup', t => {
- return rimraf(testDir)
-})
diff --git a/deps/npm/test/tap/audit.js b/deps/npm/test/tap/audit.js
deleted file mode 100644
index ca3da87a3a..0000000000
--- a/deps/npm/test/tap/audit.js
+++ /dev/null
@@ -1,578 +0,0 @@
-'use strict'
-
-const BB = require('bluebird')
-
-const common = BB.promisifyAll(require('../common-tap.js'))
-const mr = BB.promisify(require('npm-registry-mock'))
-const path = require('path')
-const rimraf = BB.promisify(require('rimraf'))
-const Tacks = require('tacks')
-const tap = require('tap')
-const test = tap.test
-
-const Dir = Tacks.Dir
-const File = Tacks.File
-const testDir = common.pkg
-
-const EXEC_OPTS = { cwd: testDir }
-
-function tmock (t) {
- return mr({port: common.port}).then(s => {
- t.tearDown(function () {
- s.done()
- s.close()
- rimraf.sync(testDir)
- })
- return s
- })
-}
-
-const quickAuditResult = {
- actions: [],
- advisories: {
- '1316': {
- findings: [
- {
- version: '1.0.0',
- paths: [
- 'baddep'
- ]
- }
- ],
- 'id': 1316,
- 'created': '2019-11-14T15:29:41.991Z',
- 'updated': '2019-11-14T19:35:30.677Z',
- 'deleted': null,
- 'title': 'Arbitrary Code Execution',
- 'found_by': {
- 'link': '',
- 'name': 'François Lajeunesse-Robert',
- 'email': ''
- },
- 'reported_by': {
- 'link': '',
- 'name': 'François Lajeunesse-Robert',
- 'email': ''
- },
- 'module_name': 'baddep',
- 'cves': [],
- 'vulnerable_versions': '<4.5.2',
- 'patched_versions': '>=4.5.2',
- 'overview': 'a nice overview of the advisory',
- 'recommendation': 'how you should fix it',
- 'references': '',
- 'access': 'public',
- 'severity': 'high',
- 'cwe': 'CWE-79',
- 'metadata': {
- 'module_type': '',
- 'exploitability': 6,
- 'affected_components': ''
- },
- 'url': 'https://npmjs.com/advisories/1234542069'
- }
- },
- 'muted': [],
- 'metadata': {
- 'vulnerabilities': {
- 'info': 0,
- 'low': 0,
- 'moderate': 0,
- 'high': 1,
- 'critical': 0
- },
- 'dependencies': 1,
- 'devDependencies': 0,
- 'totalDependencies': 1
- }
-}
-
-test('exits with zero exit code for vulnerabilities below the `audit-level` flag', t => {
- const fixture = new Tacks(new Dir({
- 'package.json': new File({
- name: 'foo',
- version: '1.0.0',
- dependencies: {
- baddep: '1.0.0'
- }
- })
- }))
- fixture.create(testDir)
- return tmock(t).then(srv => {
- srv.filteringRequestBody(req => 'ok')
- srv.post('/-/npm/v1/security/audits/quick', 'ok').reply(200, quickAuditResult)
- srv.get('/baddep').twice().reply(200, {
- name: 'baddep',
- 'dist-tags': {
- 'latest': '1.2.3'
- },
- versions: {
- '1.0.0': {
- name: 'baddep',
- version: '1.0.0',
- _hasShrinkwrap: false,
- dist: {
- shasum: 'deadbeef',
- tarball: common.registry + '/idk/-/idk-1.0.0.tgz'
- }
- },
- '1.2.3': {
- name: 'baddep',
- version: '1.2.3',
- _hasShrinkwrap: false,
- dist: {
- shasum: 'deadbeef',
- tarball: common.registry + '/idk/-/idk-1.2.3.tgz'
- }
- }
- }
- })
- return common.npm([
- 'install',
- '--audit',
- '--json',
- '--package-lock-only',
- '--registry', common.registry,
- '--cache', path.join(testDir, 'npm-cache')
- ], EXEC_OPTS).then(([code, stdout, stderr]) => {
- const result = JSON.parse(stdout)
- t.same(result.audit, quickAuditResult, 'printed quick audit result')
- srv.filteringRequestBody(req => 'ok')
- srv.post('/-/npm/v1/security/audits', 'ok').reply(200, {
- actions: [{
- action: 'update',
- module: 'baddep',
- target: '1.2.3',
- resolves: [{path: 'baddep'}]
- }],
- metadata: {
- vulnerabilities: {
- low: 1
- }
- }
- })
- return common.npm([
- 'audit',
- '--audit-level', 'high',
- '--json',
- '--registry', common.registry,
- '--cache', path.join(testDir, 'npm-cache')
- ], EXEC_OPTS).then(([code, stdout, stderr]) => {
- t.equal(code, 0, 'exited OK')
- })
- })
- })
-})
-
-test('shows quick audit results summary for human', t => {
- const fixture = new Tacks(new Dir({
- 'package.json': new File({
- name: 'foo',
- version: '1.0.0',
- dependencies: {
- baddep: '1.0.0'
- }
- })
- }))
- fixture.create(testDir)
- return tmock(t).then(srv => {
- srv.filteringRequestBody(req => 'ok')
- srv.post('/-/npm/v1/security/audits/quick', 'ok').reply(200, quickAuditResult)
- srv.get('/baddep').twice().reply(200, {
- name: 'baddep',
- 'dist-tags': {
- 'latest': '1.2.3'
- },
- versions: {
- '1.0.0': {
- name: 'baddep',
- version: '1.0.0',
- _hasShrinkwrap: false,
- dist: {
- shasum: 'deadbeef',
- tarball: common.registry + '/idk/-/idk-1.0.0.tgz'
- }
- },
- '1.2.3': {
- name: 'baddep',
- version: '1.2.3',
- _hasShrinkwrap: false,
- dist: {
- shasum: 'deadbeef',
- tarball: common.registry + '/idk/-/idk-1.2.3.tgz'
- }
- }
- }
- })
- return common.npm([
- 'install',
- '--audit',
- '--no-json',
- '--package-lock-only',
- '--registry', common.registry,
- '--cache', path.join(testDir, 'npm-cache')
- ], EXEC_OPTS).then(([code, stdout, stderr]) => {
- t.match(stdout, new RegExp('added 1 package and audited 1 package in .*\\n' +
- 'found 1 high severity vulnerability\\n' +
- ' run `npm audit fix` to fix them, or `npm audit` for details\\n'),
- 'shows quick audit result')
- })
- })
-})
-
-test('exits with non-zero exit code for vulnerabilities at the `audit-level` flag', t => {
- const fixture = new Tacks(new Dir({
- 'package.json': new File({
- name: 'foo',
- version: '1.0.0',
- dependencies: {
- baddep: '1.0.0'
- }
- })
- }))
- fixture.create(testDir)
- return tmock(t).then(srv => {
- srv.filteringRequestBody(req => 'ok')
- srv.post('/-/npm/v1/security/audits/quick', 'ok').reply(200, 'yeah')
- srv.get('/baddep').twice().reply(200, {
- name: 'baddep',
- 'dist-tags': {
- 'latest': '1.2.3'
- },
- versions: {
- '1.0.0': {
- name: 'baddep',
- version: '1.0.0',
- _hasShrinkwrap: false,
- dist: {
- shasum: 'deadbeef',
- tarball: common.registry + '/idk/-/idk-1.0.0.tgz'
- }
- },
- '1.2.3': {
- name: 'baddep',
- version: '1.2.3',
- _hasShrinkwrap: false,
- dist: {
- shasum: 'deadbeef',
- tarball: common.registry + '/idk/-/idk-1.2.3.tgz'
- }
- }
- }
- })
- return common.npm([
- 'install',
- '--audit',
- '--json',
- '--package-lock-only',
- '--registry', common.registry,
- '--cache', path.join(testDir, 'npm-cache')
- ], EXEC_OPTS).then(([code, stdout, stderr]) => {
- srv.filteringRequestBody(req => 'ok')
- srv.post('/-/npm/v1/security/audits', 'ok').reply(200, {
- actions: [{
- action: 'update',
- module: 'baddep',
- target: '1.2.3',
- resolves: [{path: 'baddep'}]
- }],
- metadata: {
- vulnerabilities: {
- high: 1
- }
- }
- })
- return common.npm([
- 'audit',
- '--audit-level', 'high',
- '--json',
- '--registry', common.registry,
- '--cache', path.join(testDir, 'npm-cache')
- ], EXEC_OPTS).then(([code, stdout, stderr]) => {
- t.equal(code, 1, 'exited OK')
- })
- })
- })
-})
-
-test('exits with non-zero exit code for vulnerabilities at the `audit-level` flag', t => {
- const fixture = new Tacks(new Dir({
- 'package.json': new File({
- name: 'foo',
- version: '1.0.0',
- dependencies: {
- baddep: '1.0.0'
- }
- })
- }))
- fixture.create(testDir)
- return tmock(t).then(srv => {
- srv.filteringRequestBody(req => 'ok')
- srv.post('/-/npm/v1/security/audits/quick', 'ok').reply(200, 'yeah')
- srv.get('/baddep').twice().reply(200, {
- name: 'baddep',
- 'dist-tags': {
- 'latest': '1.2.3'
- },
- versions: {
- '1.0.0': {
- name: 'baddep',
- version: '1.0.0',
- _hasShrinkwrap: false,
- dist: {
- shasum: 'deadbeef',
- tarball: common.registry + '/idk/-/idk-1.0.0.tgz'
- }
- },
- '1.2.3': {
- name: 'baddep',
- version: '1.2.3',
- _hasShrinkwrap: false,
- dist: {
- shasum: 'deadbeef',
- tarball: common.registry + '/idk/-/idk-1.2.3.tgz'
- }
- }
- }
- })
- return common.npm([
- 'install',
- '--audit',
- '--json',
- '--package-lock-only',
- '--registry', common.registry,
- '--cache', path.join(testDir, 'npm-cache')
- ], EXEC_OPTS).then(([code, stdout, stderr]) => {
- srv.filteringRequestBody(req => 'ok')
- srv.post('/-/npm/v1/security/audits', 'ok').reply(200, {
- actions: [{
- action: 'update',
- module: 'baddep',
- target: '1.2.3',
- resolves: [{path: 'baddep'}]
- }],
- metadata: {
- vulnerabilities: {
- high: 1
- }
- }
- })
- return common.npm([
- 'audit',
- '--audit-level', 'moderate',
- '--json',
- '--registry', common.registry,
- '--cache', path.join(testDir, 'npm-cache')
- ], EXEC_OPTS).then(([code, stdout, stderr]) => {
- t.equal(code, 1, 'exited OK')
- })
- })
- })
-})
-
-test('exits with zero exit code for vulnerabilities in devDependencies when running with production flag', t => {
- const fixture = new Tacks(new Dir({
- 'package.json': new File({
- name: 'foo',
- version: '1.0.0',
- dependencies: {
- gooddep: '1.0.0'
- },
- devDependencies: {
- baddep: '1.0.0'
- }
- })
- }))
- fixture.create(testDir)
- return tmock(t).then(srv => {
- srv.filteringRequestBody(req => 'ok')
- srv.post('/-/npm/v1/security/audits/quick', 'ok').reply(200, 'yeah')
- srv.get('/gooddep').twice().reply(200, {
- name: 'gooddep',
- 'dist-tags': {
- 'latest': '1.2.3'
- },
- versions: {
- '1.0.0': {
- name: 'gooddep',
- version: '1.0.0',
- _hasShrinkwrap: false,
- dist: {
- shasum: 'deadbeef',
- tarball: common.registry + '/idk/-/idk-1.0.0.tgz'
- }
- },
- '1.2.3': {
- name: 'gooddep',
- version: '1.2.3',
- _hasShrinkwrap: false,
- dist: {
- shasum: 'deadbeef',
- tarball: common.registry + '/idk/-/idk-1.2.3.tgz'
- }
- }
- }
- })
- srv.get('/baddep').twice().reply(200, {
- name: 'baddep',
- 'dist-tags': {
- 'latest': '1.2.3'
- },
- versions: {
- '1.0.0': {
- name: 'baddep',
- version: '1.0.0',
- _hasShrinkwrap: false,
- dist: {
- shasum: 'deadbeef',
- tarball: common.registry + '/idk/-/idk-1.0.0.tgz'
- }
- },
- '1.2.3': {
- name: 'baddep',
- version: '1.2.3',
- _hasShrinkwrap: false,
- dist: {
- shasum: 'deadbeef',
- tarball: common.registry + '/idk/-/idk-1.2.3.tgz'
- }
- }
- }
- })
- return common.npm([
- 'install',
- '--audit',
- '--json',
- '--production',
- '--package-lock-only',
- '--registry', common.registry,
- '--cache', path.join(testDir, 'npm-cache')
- ], EXEC_OPTS).then(([code, stdout, stderr]) => {
- srv.filteringRequestBody(req => 'ok')
- srv.post('/-/npm/v1/security/audits', 'ok').reply(200, {
- actions: [],
- metadata: {
- vulnerabilities: {}
- }
- })
- return common.npm([
- 'audit',
- '--json',
- '--production',
- '--registry', common.registry,
- '--cache', path.join(testDir, 'npm-cache')
- ], EXEC_OPTS).then(([code, stdout, stderr]) => {
- t.equal(code, 0, 'exited OK')
- })
- })
- })
-})
-
-test('exits with non-zero exit code for vulnerabilities in dependencies when running with production flag', t => {
- const fixture = new Tacks(new Dir({
- 'package.json': new File({
- name: 'foo',
- version: '1.0.0',
- dependencies: {
- baddep: '1.0.0'
- },
- devDependencies: {
- gooddep: '1.0.0'
- }
- })
- }))
- fixture.create(testDir)
- return tmock(t).then(srv => {
- srv.filteringRequestBody(req => 'ok')
- srv.post('/-/npm/v1/security/audits/quick', 'ok').reply(200, 'yeah')
- srv.get('/baddep').twice().reply(200, {
- name: 'baddep',
- 'dist-tags': {
- 'latest': '1.2.3'
- },
- versions: {
- '1.0.0': {
- name: 'baddep',
- version: '1.0.0',
- _hasShrinkwrap: false,
- dist: {
- shasum: 'deadbeef',
- tarball: common.registry + '/idk/-/idk-1.0.0.tgz'
- }
- },
- '1.2.3': {
- name: 'baddep',
- version: '1.2.3',
- _hasShrinkwrap: false,
- dist: {
- shasum: 'deadbeef',
- tarball: common.registry + '/idk/-/idk-1.2.3.tgz'
- }
- }
- }
- })
- srv.get('/gooddep').twice().reply(200, {
- name: 'gooddep',
- 'dist-tags': {
- 'latest': '1.2.3'
- },
- versions: {
- '1.0.0': {
- name: 'gooddep',
- version: '1.0.0',
- _hasShrinkwrap: false,
- dist: {
- shasum: 'deadbeef',
- tarball: common.registry + '/idk/-/idk-1.0.0.tgz'
- }
- },
- '1.2.3': {
- name: 'gooddep',
- version: '1.2.3',
- _hasShrinkwrap: false,
- dist: {
- shasum: 'deadbeef',
- tarball: common.registry + '/idk/-/idk-1.2.3.tgz'
- }
- }
- }
- })
- return common.npm([
- 'install',
- '--audit',
- '--json',
- '--production',
- '--package-lock-only',
- '--registry', common.registry,
- '--cache', path.join(testDir, 'npm-cache')
- ], EXEC_OPTS).then(([code, stdout, stderr]) => {
- srv.filteringRequestBody(req => 'ok')
- srv.post('/-/npm/v1/security/audits', 'ok').reply(200, {
- actions: [{
- action: 'update',
- module: 'baddep',
- target: '1.2.3',
- resolves: [{path: 'baddep'}]
- }],
- metadata: {
- vulnerabilities: {
- low: 1
- }
- }
- })
- return common.npm([
- 'audit',
- '--json',
- '--production',
- '--registry', common.registry,
- '--cache', path.join(testDir, 'npm-cache')
- ], EXEC_OPTS).then(([code, stdout, stderr]) => {
- t.equal(code, 1, 'exited OK')
- })
- })
- })
-})
-
-test('cleanup', t => {
- return rimraf(testDir)
-})
diff --git a/deps/npm/test/tap/auto-prune.js b/deps/npm/test/tap/auto-prune.js
deleted file mode 100644
index aab3692a3b..0000000000
--- a/deps/npm/test/tap/auto-prune.js
+++ /dev/null
@@ -1,147 +0,0 @@
-'use strict'
-const path = require('path')
-const test = require('tap').test
-const mr = require('npm-registry-mock')
-const Tacks = require('tacks')
-const File = Tacks.File
-const Dir = Tacks.Dir
-const common = require('../common-tap.js')
-
-const basedir = common.pkg
-const testdir = path.join(basedir, 'testdir')
-const cachedir = common.cache
-const globaldir = path.join(basedir, 'global')
-const tmpdir = path.join(basedir, 'tmp')
-
-const conf = {
- cwd: testdir,
- env: Object.assign({}, process.env, {
- npm_config_cache: cachedir,
- npm_config_tmp: tmpdir,
- npm_config_prefix: globaldir,
- npm_config_registry: common.registry,
- npm_config_loglevel: 'warn'
- })
-}
-
-let server
-const fixture = new Tacks(Dir({
- cache: Dir(),
- global: Dir(),
- tmp: Dir(),
- testdir: Dir({
- node_modules: Dir({
- minimist: Dir({
- 'package.json': File({
- _integrity: 'sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=',
- _resolved: 'https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz',
- name: 'minimist',
- version: '0.0.8'
- })
- }),
- mkdirp: Dir({
- 'package.json': File({
- _integrity: 'sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=',
- _resolved: 'https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz',
- dependencies: {
- minimist: '0.0.8'
- },
- name: 'mkdirp',
- version: '0.5.1'
- })
- }),
- null: Dir({
- 'package.json': File({
- _integrity: 'sha1-WoIdUnAxMlyG06AasQFzKgkfoew=',
- _resolved: 'https://registry.npmjs.org/null/-/null-1.0.1.tgz',
- _spec: 'null',
- name: 'null',
- version: '1.0.1'
- })
- })
- }),
- 'package-lock.json': File({
- name: 'with-lock',
- version: '1.0.0',
- lockfileVersion: 1,
- requires: true,
- dependencies: {
- minimist: {
- version: '0.0.8',
- resolved: 'https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz',
- integrity: 'sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0='
- },
- mkdirp: {
- version: '0.5.1',
- resolved: 'https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz',
- integrity: 'sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=',
- requires: {
- minimist: '0.0.8'
- }
- }
- }
- }),
- 'package.json': File({
- name: 'with-lock',
- version: '1.0.0',
- dependencies: {
- mkdirp: '^0.5.1'
- }
- })
- })
-}))
-
-function setup () {
- cleanup()
- fixture.create(basedir)
-}
-
-function cleanup () {
- fixture.remove(basedir)
-}
-
-test('setup', function (t) {
- setup()
- mr({port: common.port, throwOnUnmatched: true}, function (err, s) {
- if (err) throw err
- server = s
- t.done()
- })
-})
-
-test('auto-prune w/ package-lock', function (t) {
- common.npm(['install', '--dry-run', '--json'], conf, function (err, code, stdout, stderr) {
- if (err) throw err
- t.is(code, 0, 'command ran ok')
- t.comment(stderr.trim())
- const result = JSON.parse(stdout)
- t.is(result.added.length, 0, 'nothing added')
- t.is(result.updated.length, 0, 'nothing updated')
- t.is(result.moved.length, 0, 'nothing moved')
- t.is(result.failed.length, 0, 'nothing failed')
- t.is(result.removed.length, 1, 'pruned 1')
- t.like(result, {'removed': [{'name': 'null'}]}, 'pruned the right one')
- t.done()
- })
-})
-
-test('auto-prune w/ --no-package-lock', function (t) {
- common.npm(['install', '--dry-run', '--json', '--no-package-lock'], conf, function (err, code, stdout, stderr) {
- if (err) throw err
- t.is(code, 0, 'command ran ok')
- t.comment(stderr.trim())
- const result = JSON.parse(stdout)
- t.is(result.added.length, 0, 'nothing added')
- t.is(result.updated.length, 0, 'nothing updated')
- t.is(result.moved.length, 0, 'nothing moved')
- t.is(result.failed.length, 0, 'nothing failed')
- t.is(result.removed.length, 0, 'nothing pruned')
- t.done()
- })
-})
-
-test('cleanup', function (t) {
- server.close()
- cleanup()
- t.done()
-})
diff --git a/deps/npm/test/tap/bearer-token-check.js b/deps/npm/test/tap/bearer-token-check.js
deleted file mode 100644
index 86602b303c..0000000000
--- a/deps/npm/test/tap/bearer-token-check.js
+++ /dev/null
@@ -1,109 +0,0 @@
-var resolve = require('path').resolve
-var writeFileSync = require('graceful-fs').writeFileSync
-
-var fs = require('fs')
-var mkdirp = require('mkdirp')
-var http = require('http')
-const t = require('tap')
-
-var common = require('../common-tap.js')
-var toNerfDart = require('../../lib/config/nerf-dart.js')
-
-var pkg = common.pkg
-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://127.0.0.1:' + common.port + tarballPath
-var tarball = resolve(__dirname, '../fixtures/scoped-underscore-1.3.1.tgz')
-
-var EXEC_OPTS = { cwd: pkg, stdio: [0, 'pipe', 2] }
-
-var auth = 'Bearer 0xabad1dea'
-var server = http.createServer()
-server.on('request', (req, res) => {
- if (req.method === 'GET' && req.url === tarballPath) {
- if (req.headers.authorization === auth) {
- res.writeHead(403, 'this token should not be sent')
- res.end()
- } else {
- res.writeHead(200, 'ok')
- res.end(fs.readFileSync(tarball))
- }
- } else {
- res.writeHead(500)
- res.end()
- }
-})
-
-var contents = '@scoped:registry=' + common.registry + '\n' +
- toNerfDart(common.registry) + ':_authToken=0xabad1dea\n'
-
-var json = {
- name: 'test-package-install',
- version: '1.0.0',
- dependencies: {
- '@scoped/underscore': '1.3.1'
- }
-}
-
-var shrinkwrap = {
- name: 'test-package-install',
- version: '1.0.0',
- dependencies: {
- '@scoped/underscore': {
- resolved: tarballURL,
- version: '1.3.1'
- }
- }
-}
-
-t.teardown(() => server.close())
-
-t.test('setup', function (t) {
- 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'
- )
- server.listen(common.port, t.end)
-})
-
-t.test('authed npm install with tarball not on registry', function (t) {
- common.npm(
- [
- 'install',
- '--json',
- '--fetch-retries', 0,
- '--registry', common.registry,
- '--userconfig', outfile
- ],
- EXEC_OPTS,
- function (err, code, stdout, stderr) {
- if (err) throw err
- t.equal(code, 0, 'npm install exited OK')
- t.comment(stdout.trim())
- t.comment(stderr.trim())
- t.notOk(stderr, 'no output on stderr')
- try {
- var results = JSON.parse(stdout)
- } catch (ex) {
- t.ifError(ex, 'stdout was valid JSON')
- }
-
- if (results) {
- var installedversion = [
- {
- 'name': '@scoped/underscore',
- 'version': '1.3.1'
- }
- ]
- t.match(results.added, installedversion, '@scoped/underscore installed')
- }
-
- t.end()
- }
- )
-})
diff --git a/deps/npm/test/tap/bin-overwriting.js b/deps/npm/test/tap/bin-overwriting.js
deleted file mode 100644
index faaa78745a..0000000000
--- a/deps/npm/test/tap/bin-overwriting.js
+++ /dev/null
@@ -1,108 +0,0 @@
-const t = require('tap')
-const common = require('../common-tap.js')
-const pkg = common.pkg
-
-const { writeFileSync, readFileSync, readlink } = require('fs')
-const readCmdShim = require('read-cmd-shim')
-const path = require('path')
-const readBinCb = process.platform === 'win32' ? readCmdShim : readlink
-const readBin = bin => new Promise((resolve, reject) => {
- readBinCb(bin, (er, target) => {
- if (er) {
- reject(er)
- } else {
- resolve(path.resolve(path.dirname(bin), target))
- }
- })
-})
-
-// verify that we can't overwrite bins that we shouldn't be able to
-
-const mkdirp = require('mkdirp').sync
-
-process.env.npm_config_prefix = pkg + '/global'
-process.env.npm_config_global = true
-
-const globalBin = process.platform === 'win32'
- ? path.resolve(pkg, 'global')
- : path.resolve(pkg, 'global/bin')
-
-const globalDir = process.platform === 'win32'
- ? path.resolve(pkg, 'global/node_modules')
- : path.resolve(pkg, 'global/lib/node_modules')
-
-const beep = path.resolve(globalBin, 'beep')
-const firstBin = path.resolve(globalDir, 'first/first.js')
-const secondBin = path.resolve(globalDir, 'second/second.js')
-
-t.test('setup', { bail: true }, t => {
- // set up non-link bin in place
- mkdirp(globalBin)
- writeFileSync(beep, 'beep boop')
-
- // create first package
- mkdirp(pkg + '/first')
- writeFileSync(pkg + '/first/package.json', JSON.stringify({
- name: 'first',
- version: '1.0.0',
- bin: { beep: 'first.js' }
- }))
- writeFileSync(pkg + '/first/first.js', `#!/usr/bin/env node
- console.log('first')`)
-
- // create second package
- mkdirp(pkg + '/second')
- writeFileSync(pkg + '/second/package.json', JSON.stringify({
- name: 'second',
- version: '1.0.0',
- bin: { beep: 'second.js' }
- }))
- writeFileSync(pkg + '/second/second.js', `#!/usr/bin/env node
- console.log('second')`)
-
- // pack both to install globally
- return common.npm(['pack'], { cwd: pkg + '/first' })
- .then(() => common.npm(['pack'], { cwd: pkg + '/second' }))
-})
-
-t.test('installing first fails, because pre-existing bin in place', t => {
- return common.npm([
- 'install',
- pkg + '/first/first-1.0.0.tgz'
- ]).then(([code, stdout, stderr]) => {
- t.notEqual(code, 0)
- t.match(stderr, 'EEXIST')
- t.equal(readFileSync(beep, 'utf8'), 'beep boop')
- })
-})
-
-t.test('installing first with --force succeeds', t => {
- return common.npm([
- 'install',
- pkg + '/first/first-1.0.0.tgz',
- '--force'
- ]).then(() => {
- return t.resolveMatch(readBin(beep), firstBin, 'bin written to first.js')
- })
-})
-
-t.test('installing second fails, because bin links to other package', t => {
- return common.npm([
- 'install',
- pkg + '/second/second-1.0.0.tgz'
- ]).then(([code, stdout, stderr]) => {
- t.notEqual(code, 0)
- t.match(stderr, 'EEXIST')
- return t.resolveMatch(readBin(beep), firstBin, 'bin still linked to first')
- })
-})
-
-t.test('installing second with --force succeeds', t => {
- return common.npm([
- 'install',
- pkg + '/second/second-1.0.0.tgz',
- '--force'
- ]).then(() => {
- return t.resolveMatch(readBin(beep), secondBin, 'bin written to second.js')
- })
-})
diff --git a/deps/npm/test/tap/bin.js b/deps/npm/test/tap/bin.js
deleted file mode 100644
index bf2397777c..0000000000
--- a/deps/npm/test/tap/bin.js
+++ /dev/null
@@ -1,23 +0,0 @@
-var path = require('path')
-var test = require('tap').test
-var rimraf = require('rimraf')
-var common = require('../common-tap.js')
-var opts = { cwd: common.pkg }
-var binDir = '../../../node_modules/.bin'
-var fixture = path.resolve(common.pkg, binDir)
-
-test('setup', function (t) {
- rimraf.sync(path.join(common.pkg, 'node_modules'))
- t.end()
-})
-
-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()
- })
-})
diff --git a/deps/npm/test/tap/bitbucket-https-url-with-creds-package.js b/deps/npm/test/tap/bitbucket-https-url-with-creds-package.js
deleted file mode 100644
index f0f14dcb34..0000000000
--- a/deps/npm/test/tap/bitbucket-https-url-with-creds-package.js
+++ /dev/null
@@ -1,70 +0,0 @@
-'use strict'
-
-const BB = require('bluebird')
-
-var fs = require('graceful-fs')
-var path = require('path')
-
-var requireInject = require('require-inject')
-var test = require('tap').test
-
-var common = require('../common-tap.js')
-
-var pkg = common.pkg
-
-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', {
- 'pacote/lib/util/git': {
- 'revs': (repo, opts) => {
- return BB.resolve().then(() => {
- var cloneUrl = cloneUrls.shift()
- if (cloneUrl) {
- t.is(repo, cloneUrl[0], cloneUrl[1])
- } else {
- t.fail('too many attempts to clone')
- }
- throw new Error('git.revs mock fails on purpose')
- })
- }
- }
- })
-
- var opts = {
- cache: common.cache,
- prefix: pkg,
- registry: common.registry,
- loglevel: 'silent'
- }
- npm.load(opts, function (er) {
- t.ifError(er, 'npm loaded without error')
- npm.commands.install([], function (err) {
- t.match(err.message, /mock fails on purpose/, 'mocked install failed as expected')
- t.end()
- })
- })
-})
-
-function setup () {
- fs.writeFileSync(
- path.join(pkg, 'package.json'),
- JSON.stringify(json, null, 2)
- )
- process.chdir(pkg)
-}
diff --git a/deps/npm/test/tap/bitbucket-https-url-with-creds.js b/deps/npm/test/tap/bitbucket-https-url-with-creds.js
deleted file mode 100644
index 703d0d9a6a..0000000000
--- a/deps/npm/test/tap/bitbucket-https-url-with-creds.js
+++ /dev/null
@@ -1,69 +0,0 @@
-'use strict'
-
-const BB = require('bluebird')
-
-var fs = require('graceful-fs')
-var path = require('path')
-
-var mkdirp = require('mkdirp')
-var requireInject = require('require-inject')
-var test = require('tap').test
-
-var common = require('../common-tap.js')
-
-var pkg = common.pkg
-
-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', {
- 'pacote/lib/util/git': {
- 'revs': (repo, opts) => {
- return BB.resolve().then(() => {
- var cloneUrl = cloneUrls.shift()
- if (cloneUrl) {
- t.is(repo, cloneUrl[0], cloneUrl[1])
- } else {
- t.fail('too many attempts to clone')
- }
- throw new Error('git.revs mock fails on purpose')
- })
- }
- }
- })
-
- var opts = {
- cache: common.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 (err) {
- t.match(err, /mock fails on purpose/, 'mocked install failed as expected')
- t.end()
- })
- })
-})
-
-function setup () {
- mkdirp.sync(pkg)
- fs.writeFileSync(
- path.join(pkg, 'package.json'),
- JSON.stringify(json, null, 2)
- )
- process.chdir(pkg)
-}
diff --git a/deps/npm/test/tap/bitbucket-shortcut-package.js b/deps/npm/test/tap/bitbucket-shortcut-package.js
deleted file mode 100644
index a148c598c6..0000000000
--- a/deps/npm/test/tap/bitbucket-shortcut-package.js
+++ /dev/null
@@ -1,73 +0,0 @@
-'use strict'
-
-const BB = require('bluebird')
-
-var fs = require('graceful-fs')
-var path = require('path')
-
-var mkdirp = require('mkdirp')
-var requireInject = require('require-inject')
-var test = require('tap').test
-
-var common = require('../common-tap.js')
-
-var pkg = common.pkg
-
-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 = [
- ['https://bitbucket.org/foo/private.git', 'Bitbucket shortcuts try HTTPS URLs first'],
- ['ssh://git@bitbucket.org/foo/private.git', 'Bitbucket shortcuts try SSH second']
- ]
-
- var npm = requireInject.installGlobally('../../lib/npm.js', {
- 'pacote/lib/util/git': {
- 'revs': (repo, opts) => {
- return BB.resolve().then(() => {
- var cloneUrl = cloneUrls.shift()
- if (cloneUrl) {
- t.is(repo, cloneUrl[0], cloneUrl[1])
- } else {
- t.fail('too many attempts to clone')
- }
- throw new Error('git.revs mock fails on purpose')
- })
- }
- }
- })
-
- var opts = {
- cache: common.cache,
- prefix: pkg,
- registry: common.registry,
- loglevel: 'silent'
- }
- npm.load(opts, function (er) {
- t.ifError(er, 'npm loaded without error')
- npm.commands.install([], function (err) {
- t.match(err.message, /fails on purpose/, 'mocked install failed as expected')
- t.end()
- })
- })
-})
-
-function setup () {
- mkdirp.sync(pkg)
- fs.writeFileSync(
- path.join(pkg, 'package.json'),
- JSON.stringify(json, null, 2)
- )
- process.chdir(pkg)
-}
diff --git a/deps/npm/test/tap/bitbucket-shortcut.js b/deps/npm/test/tap/bitbucket-shortcut.js
deleted file mode 100644
index 6d750f869a..0000000000
--- a/deps/npm/test/tap/bitbucket-shortcut.js
+++ /dev/null
@@ -1,70 +0,0 @@
-'use strict'
-
-const BB = require('bluebird')
-
-var fs = require('graceful-fs')
-var path = require('path')
-
-var mkdirp = require('mkdirp')
-var requireInject = require('require-inject')
-var test = require('tap').test
-
-var common = require('../common-tap.js')
-
-var pkg = common.pkg
-
-var json = {
- name: 'bitbucket-shortcut',
- version: '0.0.0'
-}
-
-test('setup', function (t) {
- setup()
- t.end()
-})
-
-test('bitbucket-shortcut', function (t) {
- var cloneUrls = [
- ['https://bitbucket.org/foo/private.git', 'Bitbucket shortcuts try HTTPS URLs first'],
- ['ssh://git@bitbucket.org/foo/private.git', 'Bitbucket shortcuts try SSH second']
- ]
-
- var npm = requireInject.installGlobally('../../lib/npm.js', {
- 'pacote/lib/util/git': {
- 'revs': (repo, opts) => {
- return BB.resolve().then(() => {
- var cloneUrl = cloneUrls.shift()
- if (cloneUrl) {
- t.is(repo, cloneUrl[0], cloneUrl[1])
- } else {
- t.fail('too many attempts to clone')
- }
- throw new Error('git.revs mock fails on purpose')
- })
- }
- }
- })
-
- var opts = {
- cache: common.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 (err) {
- t.match(err.message, /mock fails on purpose/, 'mocked install failed as expected')
- t.end()
- })
- })
-})
-
-function setup () {
- mkdirp.sync(pkg)
- fs.writeFileSync(
- path.join(pkg, 'package.json'),
- JSON.stringify(json, null, 2)
- )
- process.chdir(pkg)
-}
diff --git a/deps/npm/test/tap/bugs.js b/deps/npm/test/tap/bugs.js
deleted file mode 100644
index 8e2685220d..0000000000
--- a/deps/npm/test/tap/bugs.js
+++ /dev/null
@@ -1,172 +0,0 @@
-var common = require('../common-tap.js')
-common.pendIfWindows('not working because Windows and shebangs')
-
-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(common.pkg, '/_output')
-
-var opts = { cwd: common.pkg }
-
-test('setup', function (t) {
- var s = '#!/usr/bin/env bash\n' +
- 'echo "$@" > ' + JSON.stringify(common.pkg) + '/_output\n'
- fs.writeFileSync(join(common.pkg, '/_script.sh'), s, 'ascii')
- fs.chmodSync(join(common.pkg, '/_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(common.pkg, '/_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(common.pkg, '/_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(common.pkg, '/_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(common.pkg, '/_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 - gitlab (https://)', function (t) {
- mr({ port: common.port }, function (er, s) {
- common.npm(
- [
- 'bugs', 'test-repo-url-https',
- '--registry=' + common.registry,
- '--loglevel=silent',
- '--browser=' + join(common.pkg, '/_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://gitlab.com/evanlucas/test-repo-url-https/issues\n')
- rimraf.sync(outFile)
- t.end()
- }
- )
- })
-})
-
-test('npm bugs test-repo-url-ssh - gitlab (ssh://)', function (t) {
- mr({ port: common.port }, function (er, s) {
- common.npm(
- [
- 'bugs', 'test-repo-url-ssh',
- '--registry=' + common.registry,
- '--loglevel=silent',
- '--browser=' + join(common.pkg, '/_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://gitlab.com/evanlucas/test-repo-url-ssh/issues\n')
- rimraf.sync(outFile)
- t.end()
- }
- )
- })
-})
-
-test('cleanup', function (t) {
- rimraf.sync(common.pkg)
- t.pass('cleaned up')
- t.end()
-})
diff --git a/deps/npm/test/tap/build-already-built.js b/deps/npm/test/tap/build-already-built.js
deleted file mode 100644
index 3410432ab2..0000000000
--- a/deps/npm/test/tap/build-already-built.js
+++ /dev/null
@@ -1,60 +0,0 @@
-// 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 npmlog = require('npmlog')
-var mkdirp = require('mkdirp')
-var requireInject = require('require-inject')
-
-var npm = require('../../lib/npm.js')
-
-const common = require('../common-tap.js')
-var PKG_DIR = common.pkg
-var fakePkg = path.resolve(PKG_DIR, 'foo')
-
-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()
- })
-})
diff --git a/deps/npm/test/tap/builtin-config.js b/deps/npm/test/tap/builtin-config.js
deleted file mode 100644
index dddd405651..0000000000
--- a/deps/npm/test/tap/builtin-config.js
+++ /dev/null
@@ -1,136 +0,0 @@
-var fs = require('fs')
-
-if (process.argv[2] === 'write-builtin') {
- var pid = process.argv[3]
- fs.writeFileSync('npmrc', 'foo=bar\npid=' + pid + '\n')
- process.exit(0)
-}
-
-var common = require('../common-tap.js')
-var path = require('path')
-var rimraf = require('rimraf')
-var mkdirp = require('mkdirp')
-var folder = common.pkg
-var test = require('tap').test
-var npm = path.resolve(__dirname, '../..')
-var spawn = require('child_process').spawn
-var node = common.nodeBin
-
-test('setup', function (t) {
- t.plan(1)
- 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) {
- t.plan(1)
- var args = ['install', npm, '-g',
- '--prefix=' + folder + '/first',
- '--ignore-scripts',
- '--cache=' + folder + '/cache',
- '--tmp=' + folder + '/tmp',
- '--loglevel=warn',
- '--progress']
- common.npm(args, {}, function (er, code) {
- if (er) throw er
- t.equal(code, 0)
- t.end()
- })
-})
-
-test('write npmrc file', function (t) {
- t.plan(1)
- common.npm(['explore', 'npm', '-g',
- '--prefix=' + folder + '/first',
- '--cache=' + folder + '/cache',
- '--tmp=' + folder + '/tmp',
- '--', 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) {
- t.plan(3)
- // get the root location
- 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, 'got npm root')
- var root = so.trim()
- t.ok(fs.statSync(root).isDirectory(), 'npm root is dir')
-
- var bin = path.resolve(root, 'npm/bin/npm-cli.js')
- spawn(
- node,
- [
- bin,
- 'install', npm,
- '-g',
- '--ignore-scripts',
- '--prefix=' + folder + '/second',
- '--cache=' + folder + '/cache',
- '--tmp=' + folder + '/tmp'
- ],
- {}
- )
- .on('error', function (er) { throw er })
- .on('close', function (code) {
- t.equal(code, 0, 'second npm install')
- t.end()
- })
- }
- )
-})
-
-test('verify that the builtin config matches', function (t) {
- t.plan(3)
- 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').split(/\r?\n/)
- var secondData = fs.readFileSync(secondRc, 'utf8').split(/\r?\n/)
- t.isDeeply(firstData, secondData)
- t.end()
- })
- })
-})
-
-test('clean', function (t) {
- rimraf.sync(folder)
- t.end()
-})
diff --git a/deps/npm/test/tap/bundled-dependencies-nonarray.js b/deps/npm/test/tap/bundled-dependencies-nonarray.js
deleted file mode 100644
index fdc32c2883..0000000000
--- a/deps/npm/test/tap/bundled-dependencies-nonarray.js
+++ /dev/null
@@ -1,71 +0,0 @@
-'use strict'
-var Bluebird = require('bluebird')
-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.js')
-
-var dir = common.pkg
-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-2.0.0.tgz'
- },
- bundledDependencies: {
- 'a-bundled-dep': 'file:../a-bundled-dep-2.0.0.tgz'
- }
-}, 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('handles non-array bundleddependencies', function (t) {
- return Bluebird.try(() => {
- return common.npm(['pack', 'a-bundled-dep/'], {cwd: dir, stdio: [0, 1, 2]})
- }).spread((code) => {
- t.is(code, 0, 'built a-bundled-dep')
- return common.npm(['install'], {cwd: pkg, stdio: [0, 1, 2]})
- }).spread((code) => {
- t.is(code, 0, 'prepared pkg-with-bundled')
- return common.npm(['pack', 'pkg-with-bundled/'], {cwd: dir, stdio: [0, 1, 'pipe']})
- }).spread((code, _, stderr) => {
- t.equal(code, 0, 'exited with a error code')
- t.equal(stderr, '')
- })
-})
-
-test('cleanup', function (t) {
- cleanup()
- t.end()
-})
-
-function bootstrap () {
- cleanup()
- mkdirp.sync(dir)
- mkdirp.sync(path.join(dir, 'node_modules'))
-
- mkdirp.sync(pkg)
- fs.writeFileSync(path.resolve(pkg, 'package.json'), pj)
-
- mkdirp.sync(dep)
- fs.writeFileSync(path.resolve(dep, 'package.json'), pjDep)
-}
-
-function cleanup () {
- rimraf.sync(dir)
-}
diff --git a/deps/npm/test/tap/bundled-dependencies.js b/deps/npm/test/tap/bundled-dependencies.js
deleted file mode 100644
index 6dbfa8cb08..0000000000
--- a/deps/npm/test/tap/bundled-dependencies.js
+++ /dev/null
@@ -1,109 +0,0 @@
-'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 tar = require('tar')
-var basepath = common.pkg
-var fixturepath = path.resolve(basepath, 'npm-test-bundled-deps')
-var targetpath = path.resolve(basepath, 'target')
-var Tacks = require('tacks')
-var File = Tacks.File
-var Dir = Tacks.Dir
-
-test('basic bundling', function (t) {
- var fixture = new Tacks(
- Dir({
- 'package.json': File({
- name: 'npm-test-files',
- version: '1.2.5',
- bundledDependencies: [
- 'addme'
- ]
- }),
- node_modules: Dir({
- addme: Dir({
- 'index.js': File('')
- }),
- iggyme: Dir({
- 'index.js': File('')
- })
- })
- })
- )
- withFixture(t, fixture, function (done) {
- t.ok(fileExists('node_modules/addme'), 'bundled dep included')
- t.notOk(fileExists('node_modules/iggyme'), 'unspecified dep not included')
- done()
- })
-})
-
-test('scoped dep bundling', function (t) {
- var fixture = new Tacks(
- Dir({
- 'package.json': File({
- name: 'npm-test-files',
- version: '1.2.5',
- bundledDependencies: [
- '@foo/addme'
- ]
- }),
- node_modules: Dir({
- '@foo': Dir({
- addme: Dir({
- 'index.js': File('')
- }),
- iggyme: Dir({
- 'index.js': File('')
- })
- })
- })
- })
- )
- withFixture(t, fixture, function (done) {
- t.ok(fileExists('node_modules/@foo/addme'), 'bundled dep included')
- t.notOk(
- fileExists('node_modules/@foo/iggyme'),
- 'unspecified dep not included')
- done()
- })
-})
-
-function fileExists (file) {
- try {
- return !!fs.statSync(path.resolve(targetpath, 'package', file))
- } catch (_) {
- return false
- }
-}
-
-function withFixture (t, fixture, tester) {
- fixture.create(fixturepath)
- mkdirp.sync(targetpath)
- common.npm(['pack', fixturepath], {cwd: basepath}, extractAndCheck)
- function extractAndCheck (err, code) {
- if (err) throw err
- t.is(code, 0, 'pack went ok')
- extractTarball(checkTests)
- }
- function checkTests (err) {
- if (err) throw err
- tester(removeAndDone)
- }
- function removeAndDone (err) {
- if (err) throw err
- fixture.remove(fixturepath)
- rimraf.sync(basepath)
- t.done()
- }
-}
-
-function extractTarball (cb) {
- // Unpack to disk so case-insensitive filesystems are consistent
- tar.extract({
- file: path.join(basepath, 'npm-test-files-1.2.5.tgz'),
- cwd: targetpath
- }).then(cb, cb)
-}
diff --git a/deps/npm/test/tap/bundled-no-add-to-move.js b/deps/npm/test/tap/bundled-no-add-to-move.js
deleted file mode 100644
index f9146c0e01..0000000000
--- a/deps/npm/test/tap/bundled-no-add-to-move.js
+++ /dev/null
@@ -1,50 +0,0 @@
-'use strict'
-var test = require('tap').test
-var Node = require('../../lib/install/node.js').create
-var npm = require('../../lib/npm.js')
-
-var oldTree = Node({
- path: '/',
- location: '/',
- children: [
- Node({
- package: {name: 'one', version: '1.0.0'},
- path: '/node_modules/one',
- location: '/one'
- })
- ]
-})
-oldTree.children[0].requiredBy.push(oldTree)
-
-var newTree = Node({
- path: '/',
- location: '/',
- children: [
- Node({
- package: {name: 'abc', version: '1.0.0'},
- path: '/node_modules/abc',
- location: '/abc',
- children: [
- Node({
- package: {name: 'one', version: '1.0.0'},
- fromBundle: true,
- path: '/node_modules/abc/node_modules/one',
- location: '/abc/one'
- })
- ]
- })
- ]
-})
-newTree.children[0].requiredBy.push(newTree)
-newTree.children[0].children[0].requiredBy.push(newTree.children[0])
-
-test('test', function (t) {
- npm.load({}, (err) => {
- if (err) throw err
- var diffTrees = require('../../lib/install/diff-trees.js')._diffTrees
- var sortActions = require('../../lib/install/diff-trees.js').sortActions
- var differences = sortActions(diffTrees(oldTree, newTree)).map(function (diff) { return diff[0] + diff[1].location })
- t.isDeeply(differences, ['add/abc/one', 'remove/one', 'add/abc'], 'bundled add/remove stays add/remove')
- t.end()
- })
-})
diff --git a/deps/npm/test/tap/bundled-transitive-deps.js b/deps/npm/test/tap/bundled-transitive-deps.js
deleted file mode 100644
index d3f296ab16..0000000000
--- a/deps/npm/test/tap/bundled-transitive-deps.js
+++ /dev/null
@@ -1,108 +0,0 @@
-'use strict'
-var fs = require('fs')
-var path = require('path')
-var test = require('tap').test
-var Tacks = require('tacks')
-var File = Tacks.File
-var Dir = Tacks.Dir
-var common = require('../common-tap.js')
-var npm = require('../../lib/npm.js')
-var tar = require('tar')
-var mkdirp = require('mkdirp')
-var testdir = common.pkg
-var packed = path.join(testdir, 'packed')
-
-var fixture = new Tacks(
- Dir({
- 'package.json': File({
- name: 'bundled-transitive-deps',
- version: '1.0.0',
- dependencies: {
- 'a': '1.0.0',
- '@c/d': '1.0.0'
- },
- bundleDependencies: [
- 'a',
- '@c/d'
- ]
- }),
- node_modules: Dir({
- 'a': Dir({
- 'package.json': File({
- name: 'a',
- version: '1.0.0',
- dependencies: {
- 'b': '1.0.0'
- }
- })
- }),
- 'b': Dir({
- 'package.json': File({
- name: 'b',
- version: '1.0.0'
- })
- }),
- '@c/d': Dir({
- 'package.json': File({
- name: '@c/d',
- version: '1.0.0'
- }),
- 'node_modules': Dir({
- 'e': Dir({
- 'package.json': File({
- name: 'e',
- version: '1.0.0'
- })
- })
- })
- })
- })
- })
-)
-
-function setup () {
- cleanup()
- fixture.create(testdir)
-}
-
-function cleanup () {
- fixture.remove(testdir)
-}
-
-test('setup', function (t) {
- setup()
- npm.load({}, t.end)
-})
-
-function exists (t, filename) {
- t.doesNotThrow(filename + ' exists', function () {
- fs.statSync(filename)
- })
-}
-
-test('bundled-transitive-deps', function (t) {
- common.npm(['pack'], {cwd: testdir}, thenCheckPack)
- function thenCheckPack (err, code, stdout, stderr) {
- if (err) throw err
- var tarball = stdout.trim()
- t.comment(stderr.trim())
- t.is(code, 0, 'pack successful')
- mkdirp.sync(packed)
- tar.extract({
- file: path.join(testdir, tarball),
- cwd: packed,
- strip: 1,
- sync: true
- })
- var transitivePackedDep = path.join(packed, 'node_modules', 'b')
- exists(t, transitivePackedDep)
- var nestedScopedDep = path.join(packed, 'node_modules', '@c', 'd', 'node_modules', 'e')
- exists(t, nestedScopedDep)
- t.end()
- }
-})
-
-test('cleanup', function (t) {
- cleanup()
- t.end()
-})
diff --git a/deps/npm/test/tap/cache-add-unpublished.js b/deps/npm/test/tap/cache-add-unpublished.js
deleted file mode 100644
index 08592a50de..0000000000
--- a/deps/npm/test/tap/cache-add-unpublished.js
+++ /dev/null
@@ -1,37 +0,0 @@
-var common = require('../common-tap.js')
-var test = require('tap').test
-
-test('cache add', function (t) {
- setup(function (er, s) {
- if (er) {
- throw er
- }
- common.npm(
- [
- 'cache',
- 'add',
- 'superfoo',
- '--registry=http://localhost:' + common.port + '/'
- ],
- {},
- 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(common.port, function () {
- cb(null, s)
- })
-}
diff --git a/deps/npm/test/tap/cache-eacces-error-message.js b/deps/npm/test/tap/cache-eacces-error-message.js
deleted file mode 100644
index fe76875c3e..0000000000
--- a/deps/npm/test/tap/cache-eacces-error-message.js
+++ /dev/null
@@ -1,35 +0,0 @@
-const npm = require('../../lib/npm.js')
-const t = require('tap')
-
-const common = require('../common-tap.js')
-
-common.skipIfWindows('this is a unix-only thing')
-
-const errorMessage = require('../../lib/utils/error-message.js')
-
-t.plan(1)
-
-npm.load({ cache: common.cache }, () => {
- npm.config.set('cache', common.cache)
- const er = new Error('access is e, i am afraid')
- er.code = 'EACCES'
- er.errno = -13
- er.path = common.cache + '/src'
- er.dest = common.cache + '/to'
-
- t.match(errorMessage(er), {
- summary: [
- [
- '',
- new RegExp('\n' +
- 'Your cache folder contains root-owned files, due to a bug in\n' +
- 'previous versions of npm which has since been addressed.\n' +
- '\n' +
- 'To permanently fix this problem, please run:\n' +
- ' sudo chown -R [0-9]+:[0-9]+ ".*npm_cache_cache-eacces-error-message"'
- )
- ]
- ],
- detail: []
- }, 'get the helpful error message')
-})
diff --git a/deps/npm/test/tap/cache-shasum-fork.js b/deps/npm/test/tap/cache-shasum-fork.js
deleted file mode 100644
index fade5ffb64..0000000000
--- a/deps/npm/test/tap/cache-shasum-fork.js
+++ /dev/null
@@ -1,92 +0,0 @@
-var fs = require('graceful-fs')
-var path = require('path')
-
-var mkdirp = require('mkdirp')
-var mr = require('npm-registry-mock')
-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 = common.pkg
-var cache = common.cache
-var server
-
-test('setup', function (t) {
- mkdirp.sync(path.join(pkg, 'node_modules'))
- process.chdir(pkg)
- 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) {
- common.npm(
- [
- '--loglevel', 'silent',
- '--json',
- '--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.equal(stderr, '', 'Should not get data on stderr')
- t.equal(code, 0, 'install finished successfully')
-
- var deps = {}
- JSON.parse(stdout).added.forEach(function (dep) { deps[dep.name] = dep })
- t.equal(deps.underscore && deps.underscore.version, '1.5.1')
- 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) {
- common.npm(
- [
- '--loglevel', 'silent',
- '--json',
- '--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)
- var deps = {}
- JSON.parse(stdout).updated.forEach(function (dep) { deps[dep.name] = dep })
- t.equal(deps.underscore && deps.underscore.version, '1.5.1')
- 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()
- t.end()
-})
diff --git a/deps/npm/test/tap/check-cpu-reqs.js b/deps/npm/test/tap/check-cpu-reqs.js
deleted file mode 100644
index d70660b058..0000000000
--- a/deps/npm/test/tap/check-cpu-reqs.js
+++ /dev/null
@@ -1,50 +0,0 @@
-'use strict'
-var path = require('path')
-var fs = require('fs')
-var test = require('tap').test
-var mkdirp = require('mkdirp')
-var common = require('../common-tap.js')
-
-var base = common.pkg
-var installFrom = path.join(base, 'from')
-var installIn = path.join(base, 'in')
-
-var json = {
- name: 'check-cpu-reqs',
- version: '0.0.1',
- description: 'fixture',
- cpu: ['fake-cpu']
-}
-
-test('setup', function (t) {
- setup()
- t.end()
-})
-
-var INSTALL_OPTS = ['--loglevel', 'silly']
-var EXEC_OPTS = {cwd: installIn}
-
-test('install bad cpu', function (t) {
- common.npm(['install', installFrom].concat(INSTALL_OPTS), EXEC_OPTS, function (err, code) {
- t.ifError(err, 'npm ran without issue')
- t.is(code, 1, 'npm install refused to install a package in itself')
- t.end()
- })
-})
-test('force install bad cpu', function (t) {
- common.npm(['install', '--force', installFrom].concat(INSTALL_OPTS), EXEC_OPTS, function (err, code) {
- t.ifError(err, 'npm ran without issue')
- t.is(code, 0, 'npm install happily installed a package in itself with --force')
- t.end()
- })
-})
-
-function setup () {
- mkdirp.sync(path.resolve(installFrom, 'node_modules'))
- fs.writeFileSync(
- path.join(installFrom, 'package.json'),
- JSON.stringify(json, null, 2)
- )
- mkdirp.sync(path.resolve(installIn, 'node_modules'))
- process.chdir(base)
-}
diff --git a/deps/npm/test/tap/check-engine-reqs.js b/deps/npm/test/tap/check-engine-reqs.js
deleted file mode 100644
index eec0756288..0000000000
--- a/deps/npm/test/tap/check-engine-reqs.js
+++ /dev/null
@@ -1,63 +0,0 @@
-'use strict'
-var path = require('path')
-var fs = require('fs')
-var test = require('tap').test
-var mkdirp = require('mkdirp')
-var common = require('../common-tap.js')
-
-var base = common.pkg
-var installFrom = path.join(base, 'from')
-var installIn = path.join(base, 'in')
-
-var json = {
- name: 'check-engine-reqs',
- version: '0.0.1',
- description: 'fixture',
- engines: {
- node: '1.0.0-not-a-real-version'
- }
-}
-
-test('setup', function (t) {
- setup()
- t.end()
-})
-
-var INSTALL_OPTS = ['--loglevel', 'silly']
-var EXEC_OPTS = {cwd: installIn}
-test('install bad engine', function (t) {
- common.npm(['install', '--engine-strict', installFrom].concat(INSTALL_OPTS), EXEC_OPTS, function (err, code) {
- t.ifError(err, 'npm ran without issue')
- t.is(code, 1, 'npm install refused to install a package in itself')
- t.end()
- })
-})
-test('force install bad engine', function (t) {
- common.npm(['install', '--engine-strict', '--force', installFrom].concat(INSTALL_OPTS), EXEC_OPTS, function (err, code) {
- t.ifError(err, 'npm ran without issue')
- t.is(code, 0, 'npm install happily installed a package in itself with --force')
- t.end()
- })
-})
-
-test('warns on bad engine not strict', function (t) {
- common.npm(['install', '--json', installFrom], EXEC_OPTS, function (err, code, stdout, stderr) {
- t.ifError(err, 'npm ran without issue')
- t.is(code, 0, 'result code')
- var result = JSON.parse(stdout)
- t.match(result.warnings[0], /Unsupported engine/, 'reason for optional failure in JSON')
- t.match(result.warnings[0], /1.0.0-not-a-real-version/, 'should print mismatch version info')
- t.match(result.warnings[0], /Not compatible with your version of node/, 'incompatibility message')
- t.done()
- })
-})
-
-function setup () {
- mkdirp.sync(path.resolve(installFrom, 'node_modules'))
- fs.writeFileSync(
- path.join(installFrom, 'package.json'),
- JSON.stringify(json, null, 2)
- )
- mkdirp.sync(path.resolve(installIn, 'node_modules'))
- process.chdir(base)
-}
diff --git a/deps/npm/test/tap/check-install-self.js b/deps/npm/test/tap/check-install-self.js
deleted file mode 100644
index 63901a12df..0000000000
--- a/deps/npm/test/tap/check-install-self.js
+++ /dev/null
@@ -1,56 +0,0 @@
-'use strict'
-var path = require('path')
-var fs = require('fs')
-var test = require('tap').test
-var mkdirp = require('mkdirp')
-var common = require('../common-tap.js')
-
-var base = common.pkg
-var installFrom = path.join(base, 'from')
-var installIn = path.join(base, 'in')
-
-var json = {
- name: 'check-install-self',
- version: '0.0.1',
- description: 'fixture'
-}
-
-test('setup', function (t) {
- setup()
- t.end()
-})
-
-var EXEC_OPTS = {cwd: installIn}
-
-test('install self', function (t) {
- common.npm(['install', installFrom], EXEC_OPTS, function (err, code, stdout, stderr) {
- if (err) throw err
- t.comment(stdout.trim())
- t.comment(stderr.trim())
- t.is(code, 1, 'npm install refused to install a package in itself')
- t.end()
- })
-})
-test('force install self', function (t) {
- common.npm(['install', '--force', installFrom], EXEC_OPTS, function (err, code, stdout, stderr) {
- if (err) throw err
- t.comment(stdout.trim())
- t.comment(stderr.trim())
- t.is(code, 0, 'npm install happily installed a package in itself with --force')
- t.end()
- })
-})
-
-function setup () {
- mkdirp.sync(path.resolve(installFrom, 'node_modules'))
- fs.writeFileSync(
- path.join(installFrom, 'package.json'),
- JSON.stringify(json, null, 2)
- )
- mkdirp.sync(path.resolve(installIn, 'node_modules'))
- fs.writeFileSync(
- path.join(installIn, 'package.json'),
- JSON.stringify(json, null, 2)
- )
- process.chdir(base)
-}
diff --git a/deps/npm/test/tap/check-os-reqs.js b/deps/npm/test/tap/check-os-reqs.js
deleted file mode 100644
index 66dcbd5328..0000000000
--- a/deps/npm/test/tap/check-os-reqs.js
+++ /dev/null
@@ -1,50 +0,0 @@
-'use strict'
-var path = require('path')
-var fs = require('fs')
-var test = require('tap').test
-var mkdirp = require('mkdirp')
-var common = require('../common-tap.js')
-
-var base = common.pkg
-var installFrom = path.join(base, 'from')
-var installIn = path.join(base, 'in')
-
-var json = {
- name: 'check-os-reqs',
- version: '0.0.1',
- description: 'fixture',
- os: ['fake-os']
-}
-
-test('setup', function (t) {
- setup()
- t.end()
-})
-
-var INSTALL_OPTS = ['--loglevel', 'silly']
-var EXEC_OPTS = {cwd: installIn}
-
-test('install bad os', function (t) {
- common.npm(['install', installFrom].concat(INSTALL_OPTS), EXEC_OPTS, function (err, code) {
- t.ifError(err, 'npm ran without issue')
- t.is(code, 1, 'npm install refused to install a package in itself')
- t.end()
- })
-})
-test('force install bad os', function (t) {
- common.npm(['install', '--force', installFrom].concat(INSTALL_OPTS), EXEC_OPTS, function (err, code) {
- t.ifError(err, 'npm ran without issue')
- t.is(code, 0, 'npm install happily installed a package in itself with --force')
- t.end()
- })
-})
-
-function setup () {
- mkdirp.sync(path.resolve(installFrom, 'node_modules'))
- fs.writeFileSync(
- path.join(installFrom, 'package.json'),
- JSON.stringify(json, null, 2)
- )
- mkdirp.sync(path.resolve(installIn, 'node_modules'))
- process.chdir(base)
-}
diff --git a/deps/npm/test/tap/check-permissions.js b/deps/npm/test/tap/check-permissions.js
deleted file mode 100644
index b8238891d9..0000000000
--- a/deps/npm/test/tap/check-permissions.js
+++ /dev/null
@@ -1,95 +0,0 @@
-'use strict'
-var fs = require('fs')
-var path = require('path')
-var test = require('tap').test
-var rimraf = require('rimraf')
-var writable = require('../../lib/install/writable.js').fsAccessImplementation
-var writableFallback = require('../../lib/install/writable.js').fsOpenImplementation
-var exists = require('../../lib/install/exists.js').fsAccessImplementation
-var existsFallback = require('../../lib/install/exists.js').fsStatImplementation
-
-const common = require('../common-tap.js')
-var testBase = common.pkg
-var existingDir = path.resolve(testBase, 'exists')
-var nonExistingDir = path.resolve(testBase, 'does-not-exist')
-var writableDir = path.resolve(testBase, 'writable')
-var nonWritableDir = path.resolve(testBase, 'non-writable')
-
-test('setup', function (t) {
- cleanup()
- setup()
- t.end()
-})
-
-test('exists', function (t) {
- t.plan(2)
- // fs.access first introduced in node 0.12 / io.js
- if (fs.access) {
- existsTests(t, exists)
- } else {
- t.pass('# skip fs.access not available in this version')
- t.pass('# skip fs.access not available in this version')
- }
-})
-
-test('exists-fallback', function (t) {
- t.plan(2)
- existsTests(t, existsFallback)
-})
-
-test('writable', function (t) {
- t.plan(2)
- // fs.access first introduced in node 0.12 / io.js
- if (fs.access) {
- writableTests(t, writable)
- } else {
- t.pass('# skip fs.access not available in this version')
- t.pass('# skip fs.access not available in this version')
- }
-})
-
-test('writable-fallback', function (t) {
- t.plan(2)
- writableTests(t, writableFallback)
-})
-
-test('cleanup', function (t) {
- cleanup()
- t.end()
-})
-
-function setup () {
- fs.mkdirSync(testBase)
- fs.mkdirSync(existingDir)
- fs.mkdirSync(writableDir)
- fs.mkdirSync(nonWritableDir)
- fs.chmodSync(nonWritableDir, '555')
-}
-
-function existsTests (t, exists) {
- exists(existingDir, function (er) {
- t.error(er, 'exists dir is exists')
- })
- exists(nonExistingDir, function (er) {
- t.ok(er, 'non-existing dir resulted in an error')
- })
-}
-
-function writableTests (t, writable) {
- writable(writableDir, function (er) {
- t.error(er, 'writable dir is writable')
- })
- if (process.platform === 'win32') {
- t.pass('windows folders cannot be read-only')
- } else if (process.getuid && process.getuid() === 0) {
- t.pass('root is not blocked by read-only dirs')
- } else {
- writable(nonWritableDir, function (er) {
- t.ok(er, 'non-writable dir resulted in an error')
- })
- }
-}
-
-function cleanup () {
- rimraf.sync(testBase)
-}
diff --git a/deps/npm/test/tap/ci-header.js b/deps/npm/test/tap/ci-header.js
deleted file mode 100644
index fc791c6e67..0000000000
--- a/deps/npm/test/tap/ci-header.js
+++ /dev/null
@@ -1,139 +0,0 @@
-'use strict'
-var path = require('path')
-var test = require('tap').test
-var mr = require('npm-registry-mock')
-var Tacks = require('tacks')
-var File = Tacks.File
-var Dir = Tacks.Dir
-var chain = require('slide').chain
-var common = require('../common-tap.js')
-
-var basedir = common.pkg
-var testdir = path.join(basedir, 'testdir')
-var cachedir = common.cache
-var globaldir = path.join(basedir, 'global')
-var tmpdir = path.join(basedir, 'tmp')
-
-var ciKeys = ['CI', 'TDDIUM', 'JENKINS_URL', 'bamboo.buildKey']
-
-var filteredEnv = common.newEnv().delete(ciKeys)
-
-var conf = function (extraEnv) {
- return {
- cwd: testdir,
- env: filteredEnv.clone().extend(extraEnv, {
- npm_config_cache: cachedir,
- npm_config_tmp: tmpdir,
- npm_config_prefix: globaldir,
- npm_config_registry: common.registry,
- npm_config_loglevel: 'warn'
- })
- }
-}
-
-var server
-var fixture = new Tacks(Dir({
- cache: Dir(),
- global: Dir(),
- tmp: Dir(),
- testdir: Dir({
- 'package.json': File({
- name: 'example',
- version: '1.0.0'
- })
- })
-}))
-
-function setup () {
- cleanup()
- fixture.create(basedir)
-}
-
-function cleanup () {
- fixture.remove(basedir)
-}
-
-var ciHeaderTestCI = {
- 'time': {'1.0.0': ''},
- 'dist-tags': {'latest': '1.0.0'},
- 'versions': {
- '1.0.0': {
- name: 'ci-header-test',
- version: '1.0.0',
- gotCI: true
- }
- }
-}
-var ciHeaderTestNotCI = {
- 'time': {'1.0.0': ''},
- 'dist-tags': {'latest': '1.0.0'},
- 'versions': {
- '1.0.0': {
- name: 'ci-header-test',
- version: '1.0.0',
- gotCI: false
- }
- }
-}
-
-var ciHeaderTestNoCI = {
- 'time': {'1.0.0': ''},
- 'dist-tags': {'latest': '1.0.0'},
- 'versions': {
- '1.0.0': {
- name: 'ci-header-test',
- version: '1.0.0',
- gotCI: null
- }
- }
-}
-
-test('setup', function (t) {
- setup()
- mr({port: common.port, throwOnUnmatched: true}, function (err, s) {
- if (err) throw err
- server = s
- server.get('/ci-header-test', {
- 'NPM-In-CI': 'true'
- }).many().reply('200', ciHeaderTestCI)
- server.get('/ci-header-test', {
- 'NPM-In-CI': 'false'
- }).many().reply('200', ciHeaderTestNotCI)
- server.get('/ci-header-test', {}).many().reply('200', ciHeaderTestNoCI)
- t.done()
- })
-})
-
-test('various-ci', function (t) {
- var todo = ciKeys.map(function (key) { return [checkKey, key] })
- return chain(todo, t.done)
-
- function checkKey (key, next) {
- var env = {}
- env[key] = 'true'
-
- common.npm(['view', '--cache-min=0', 'ci-header-test', 'gotCI'], conf(env), function (err, code, stdout, stderr) {
- if (err) throw err
- t.is(code, 0, key + ' command ran ok')
- if (stderr.trim()) t.comment(stderr.trim())
- t.is(stdout.trim(), 'true', key + ' set results in CI header')
- next()
- })
- }
-})
-
-test('no-ci', function (t) {
- common.npm(['view', '--cache-min=0', 'ci-header-test', 'gotCI'], conf(), function (err, code, stdout, stderr) {
- if (err) throw err
- t.is(code, 0, 'No CI env, command ran ok')
- if (stderr.trim()) t.comment(stderr.trim())
- t.is(stdout.trim(), 'false', 'No CI env, not in CI')
- t.done()
- })
-})
-
-test('cleanup', function (t) {
- server.close()
- cleanup()
- t.done()
-})
diff --git a/deps/npm/test/tap/ci-permissions.js b/deps/npm/test/tap/ci-permissions.js
deleted file mode 100644
index c73d464236..0000000000
--- a/deps/npm/test/tap/ci-permissions.js
+++ /dev/null
@@ -1,53 +0,0 @@
-const t = require('tap')
-const tar = require('tar')
-const common = require('../common-tap.js')
-const pkg = common.pkg
-const rimraf = require('rimraf')
-const { writeFileSync, statSync, chmodSync } = require('fs')
-const { resolve } = require('path')
-const mkdirp = require('mkdirp')
-
-t.test('setup', t => {
- mkdirp.sync(resolve(pkg, 'package'))
- const pj = resolve(pkg, 'package', 'package.json')
- writeFileSync(pj, JSON.stringify({
- name: 'foo',
- version: '1.2.3'
- }))
- chmodSync(pj, 0o640)
- tar.c({
- sync: true,
- file: resolve(pkg, 'foo.tgz'),
- gzip: true,
- cwd: pkg
- }, ['package'])
- writeFileSync(resolve(pkg, 'package.json'), JSON.stringify({
- name: 'root',
- version: '1.2.3',
- dependencies: {
- foo: 'file:foo.tgz'
- }
- }))
- t.end()
-})
-
-t.test('run install to generate package-lock', t =>
- common.npm(['install'], { cwd: pkg }).then(([code]) => t.equal(code, 0)))
-
-t.test('remove node_modules', t => rimraf(resolve(pkg, 'node_modules'), t.end))
-
-t.test('run ci and check modes', t =>
- common.npm(['ci'], { cwd: pkg, stdio: 'inherit' }).then(([code]) => {
- t.equal(code, 0)
- const file = resolve(pkg, 'node_modules', 'foo', 'package.json')
- // bitwise AND against 0o705 so that we can detect whether
- // the file is world-readable.
- // Typical unix systems would leave the file 0o644
- // Travis-ci and some other Linux systems will be 0o664
- // Windows is 0o666
- // The regression this is detecting (ie, the default in the tarball)
- // leaves the file as 0o640.
- // Bitwise-AND 0o705 should always result in 0o604, and never 0o600
- const mode = statSync(file).mode & 0o705
- t.equal(mode, 0o604)
- }))
diff --git a/deps/npm/test/tap/ci-with-local-dependency.js b/deps/npm/test/tap/ci-with-local-dependency.js
deleted file mode 100644
index 376dc97818..0000000000
--- a/deps/npm/test/tap/ci-with-local-dependency.js
+++ /dev/null
@@ -1,82 +0,0 @@
-const fs = require('graceful-fs')
-const path = require('path')
-
-const mkdirp = require('mkdirp')
-const t = require('tap')
-
-const common = require('../common-tap.js')
-
-const pkg = common.pkg + '/package'
-
-const EXEC_OPTS = {
- cwd: pkg,
- stdio: [0, 1, 2],
- env: common.newEnv().extend({
- npm_config_registry: common.registry
- })
-}
-
-const localDependencyJson = {
- name: 'local-dependency',
- version: '0.0.0',
- dependencies: {
- 'test-package': '0.0.0'
- }
-}
-
-const dependentJson = {
- name: 'dependent',
- version: '0.0.0',
- dependencies: {
- 'local-dependency': '../local-dependency'
- }
-}
-
-const target = path.resolve(pkg, '../local-dependency')
-const mr = require('npm-registry-mock')
-let server
-t.teardown(() => {
- if (server) {
- server.close()
- }
-})
-
-t.test('setup', function (t) {
- mkdirp.sync(target)
- fs.writeFileSync(
- path.join(target, 'package.json'),
- JSON.stringify(localDependencyJson, null, 2)
- )
- mkdirp.sync(pkg)
- fs.writeFileSync(
- path.join(pkg, 'package.json'),
- JSON.stringify(dependentJson, null, 2)
- )
- mr({ port: common.port }, (er, s) => {
- if (er) {
- throw er
- }
- server = s
- t.end()
- })
-})
-
-t.test('\'npm install\' should install local pkg from sub path', function (t) {
- common.npm(['install', '--loglevel=silent'], EXEC_OPTS, function (err, code) {
- if (err) throw err
- t.equal(code, 0, 'npm install exited with code')
- t.ok(fs.statSync(path.resolve(pkg, 'node_modules/local-dependency/package.json')).isFile(), 'local dependency package.json exists')
- t.ok(fs.statSync(path.resolve(pkg, 'node_modules/local-dependency/node_modules/test-package')).isDirectory(), 'transitive dependency installed')
- t.end()
- })
-})
-
-t.test('\'npm ci\' should work', function (t) {
- common.npm(['ci', '--loglevel=silent'], EXEC_OPTS, function (err, code) {
- if (err) throw err
- t.equal(code, 0, 'npm install exited with code')
- t.ok(fs.statSync(path.resolve(pkg, 'node_modules/local-dependency/package.json')).isFile(), 'local dependency package.json exists')
- t.ok(fs.statSync(path.resolve(pkg, 'node_modules/local-dependency/node_modules/test-package')).isDirectory(), 'transitive dependency installed')
- t.end()
- })
-})
diff --git a/deps/npm/test/tap/ci.js b/deps/npm/test/tap/ci.js
deleted file mode 100644
index e1c2d73b7a..0000000000
--- a/deps/npm/test/tap/ci.js
+++ /dev/null
@@ -1,344 +0,0 @@
-'use strict'
-
-const BB = require('bluebird')
-
-const common = BB.promisifyAll(require('../common-tap.js'))
-const fs = BB.promisifyAll(require('fs'))
-const mr = BB.promisify(require('npm-registry-mock'))
-const path = require('path')
-const rimraf = BB.promisify(require('rimraf'))
-const Tacks = require('tacks')
-const test = require('tap').test
-
-const Dir = Tacks.Dir
-const File = Tacks.File
-const cacheDir = common.cache
-const testDir = common.pkg
-
-const EXEC_OPTS = {
- cwd: testDir,
- nodeExecPath: process.execPath
-}
-
-const PKG = {
- name: 'top',
- version: '1.2.3',
- scripts: {
- install: 'node -p process.env.npm_config_foo'
- },
- dependencies: {
- optimist: '0.6.0',
- clean: '2.1.6'
- }
-}
-let RAW_LOCKFILE
-let SERVER
-let TREE
-
-function scrubFrom (tree) {
- // npm ci and npm i write different `from` fields for dependency deps. This
- // is fine any ok, but it messes with `t.deepEqual` comparisons.
- function _scrubFrom (deps) {
- Object.keys(deps).forEach((k) => {
- deps[k].from = ''
- if (deps[k].dependencies) { _scrubFrom(deps[k].dependencies) }
- })
- }
- tree.dependencies && _scrubFrom(tree.dependencies)
-}
-
-test('setup', () => {
- const fixture = new Tacks(Dir({
- 'package.json': File(PKG)
- }))
- return Promise.all([rimraf(cacheDir), rimraf(testDir)]).then(() => {
- fixture.create(testDir)
- return mr({port: common.port})
- })
- .then((server) => {
- SERVER = server
- return common.npm([
- 'install',
- '--registry', common.registry
- ], EXEC_OPTS)
- })
- .then(() => fs.readFileAsync(
- path.join(testDir, 'package-lock.json'),
- 'utf8')
- )
- .then((lock) => {
- RAW_LOCKFILE = lock
- })
- .then(() => common.npm(['ls', '--json'], EXEC_OPTS))
- .then((ret) => {
- TREE = scrubFrom(JSON.parse(ret[1]))
- })
-})
-
-test('basic installation', (t) => {
- const fixture = new Tacks(Dir({
- 'package.json': File(PKG),
- 'package-lock.json': File(RAW_LOCKFILE)
- }))
- return rimraf(testDir)
- .then(() => fixture.create(testDir))
- .then(() => common.npm([
- 'ci',
- '--foo=asdf',
- '--registry', common.registry,
- '--loglevel', 'warn'
- ], EXEC_OPTS))
- .then((ret) => {
- const code = ret[0]
- const stdout = ret[1]
- const stderr = ret[2]
- t.equal(code, 0, 'command completed without error')
- t.equal(stderr.trim(), '', 'no output on stderr')
- t.match(
- stdout.trim(),
- /\nasdf\nadded 6 packages in \d+(?:\.\d+)?s$/,
- 'no warnings on stderr, and final output has right number of packages'
- )
- return fs.readdirAsync(path.join(testDir, 'node_modules'))
- })
- .then((modules) => {
- t.deepEqual(modules.sort(), [
- 'async', 'checker', 'clean', 'minimist', 'optimist', 'wordwrap'
- ], 'packages installed')
- return BB.all(modules.map((mod) => {
- return fs.readFileAsync(
- path.join(testDir, 'node_modules', mod, 'package.json')
- )
- .then((f) => JSON.parse(f))
- .then((pkgjson) => {
- t.equal(pkgjson.name, mod, `${mod} package name correct`)
- t.match(
- pkgjson._integrity,
- /sha\d+-[a-z0-9=+/]+$/i,
- `${mod} pkgjson has _integrity`
- )
- t.match(
- pkgjson._resolved,
- new RegExp(`http.*/-/${mod}-${pkgjson.version}.tgz`),
- `${mod} pkgjson has correct _resolved`
- )
- t.match(
- pkgjson._from,
- new RegExp(`${mod}@.*`),
- `${mod} pkgjson has _from field`
- )
- })
- }))
- })
- .then(() => fs.readFileAsync(
- path.join(testDir, 'package-lock.json'),
- 'utf8')
- )
- .then((lock) => t.equal(lock, RAW_LOCKFILE, 'package-lock.json unchanged'))
- .then(() => common.npm(['ls', '--json'], EXEC_OPTS))
- .then((ret) => {
- const lsResult = JSON.parse(ret[1])
- t.equal(ret[0], 0, 'ls exited successfully')
- t.deepEqual(scrubFrom(lsResult), TREE, 'tree matches one from `install`')
- })
-})
-
-test('supports npm-shrinkwrap.json as well', (t) => {
- const fixture = new Tacks(Dir({
- 'package.json': File(PKG),
- 'npm-shrinkwrap.json': File(RAW_LOCKFILE)
- }))
- return rimraf(testDir)
- .then(() => fixture.create(testDir))
- .then(() => common.npm([
- 'ci',
- '--foo=asdf',
- '--registry', common.registry,
- '--loglevel', 'warn'
- ], EXEC_OPTS))
- .then((ret) => {
- const code = ret[0]
- const stdout = ret[1]
- const stderr = ret[2]
- t.equal(code, 0, 'command completed without error')
- t.equal(stderr.trim(), '', 'no output on stderr')
- t.match(
- stdout.trim(),
- /\nasdf\nadded 6 packages in \d+(?:\.\d+)?s$/,
- 'no warnings on stderr, and final output has right number of packages'
- )
- })
- .then(() => common.npm(['ls', '--json'], EXEC_OPTS))
- .then((ret) => {
- t.equal(ret[0], 0, 'ls exited successfully')
- t.deepEqual(
- scrubFrom(JSON.parse(ret[1])),
- TREE,
- 'tree matches one from `install`'
- )
- })
- .then(() => fs.readFileAsync(
- path.join(testDir, 'npm-shrinkwrap.json'),
- 'utf8')
- )
- .then((lock) => t.equal(lock, RAW_LOCKFILE, 'npm-shrinkwrap.json unchanged'))
- .then(() => fs.readdirAsync(path.join(testDir)))
- .then((files) => t.notOk(
- files.some((f) => f === 'package-lock.json'),
- 'no package-lock.json created'
- ))
-})
-
-test('removes existing node_modules/ before installing', (t) => {
- const fixture = new Tacks(Dir({
- 'package.json': File(PKG),
- 'package-lock.json': File(RAW_LOCKFILE),
- 'node_modules': Dir({
- foo: Dir({
- 'index.js': File('"hello world"')
- })
- })
- }))
- return rimraf(testDir)
- .then(() => fixture.create(testDir))
- .then(() => common.npm([
- 'ci',
- '--foo=asdf',
- '--registry', common.registry,
- '--loglevel', 'warn'
- ], EXEC_OPTS))
- .then((ret) => {
- const code = ret[0]
- const stderr = ret[2]
- t.equal(code, 0, 'command completed without error')
- t.match(
- stderr.trim(),
- /^npm.*WARN.*removing existing node_modules/,
- 'user warned that existing node_modules were removed'
- )
- return fs.readdirAsync(path.join(testDir, 'node_modules'))
- })
- .then((modules) => {
- t.deepEqual(modules.sort(), [
- 'async', 'checker', 'clean', 'minimist', 'optimist', 'wordwrap'
- ], 'packages installed, with old node_modules dir gone')
- })
- .then(() => common.npm(['ls'], EXEC_OPTS))
- .then((ret) => t.equal(ret[0], 0, 'ls exited successfully'))
- .then(() => fs.readFileAsync(
- path.join(testDir, 'package-lock.json'),
- 'utf8')
- )
- .then((lock) => t.equal(lock, RAW_LOCKFILE, 'package-lock.json unchanged'))
-})
-
-test('installs all package types correctly')
-
-test('errors if package-lock.json missing', (t) => {
- const fixture = new Tacks(Dir({
- 'package.json': File(PKG)
- }))
- return rimraf(testDir)
- .then(() => fixture.create(testDir))
- .then(() => common.npm([
- 'ci',
- '--foo=asdf',
- '--registry', common.registry,
- '--loglevel', 'warn'
- ], EXEC_OPTS))
- .then((ret) => {
- const code = ret[0]
- const stdout = ret[1]
- const stderr = ret[2]
- t.equal(code, 1, 'command errored')
- t.equal(stdout.trim(), '', 'no output on stdout')
- t.match(
- stderr.trim(),
- /can only install packages with an existing package-lock/i,
- 'user informed about the issue'
- )
- return fs.readdirAsync(path.join(testDir))
- })
- .then((dir) => {
- t.notOk(dir.some((f) => f === 'node_modules'), 'no node_modules installed')
- t.notOk(
- dir.some((f) => f === 'package-lock.json'),
- 'no package-lock.json created'
- )
- })
-})
-
-test('errors if package-lock.json invalid', (t) => {
- const badJson = JSON.parse(RAW_LOCKFILE)
- delete badJson.dependencies.optimist
- const fixture = new Tacks(Dir({
- 'package.json': File(PKG),
- 'package-lock.json': File(badJson)
- }))
- return rimraf(testDir)
- .then(() => fixture.create(testDir))
- .then(() => common.npm([
- 'ci',
- '--foo=asdf',
- '--registry', common.registry,
- '--loglevel', 'warn'
- ], EXEC_OPTS))
- .then((ret) => {
- const code = ret[0]
- const stdout = ret[1]
- const stderr = ret[2]
- t.equal(code, 1, 'command errored')
- t.equal(stdout.trim(), '', 'no output on stdout')
- t.match(
- stderr.trim(),
- /can only install packages when your package.json/i,
- 'user informed about the issue'
- )
- return fs.readdirAsync(path.join(testDir))
- })
- .then((dir) => {
- t.notOk(dir.some((f) => f === 'node_modules'), 'no node_modules installed')
- })
- .then(() => fs.readFileAsync(
- path.join(testDir, 'package-lock.json'),
- 'utf8')
- )
- .then((lock) => t.deepEqual(
- JSON.parse(lock),
- badJson,
- 'bad package-lock.json left unchanged')
- )
-})
-
-test('correct cache location when using cache config', (t) => {
- const fixture = new Tacks(Dir({
- 'package.json': File(PKG),
- 'package-lock.json': File(RAW_LOCKFILE)
- }))
- return Promise.all([rimraf(cacheDir), rimraf(testDir)])
- .then(() => fixture.create(cacheDir))
- .then(() => fixture.create(testDir))
- .then(() => common.npm([
- 'ci',
- `--cache=${cacheDir}`,
- '--foo=asdf',
- '--registry', common.registry,
- '--loglevel', 'warn'
- ], EXEC_OPTS))
- .then((ret) => {
- const code = ret[0]
- const stderr = ret[2]
- t.equal(code, 0, 'command completed without error')
- t.equal(stderr.trim(), '', 'no output on stderr')
- return fs.readdirAsync(path.join(cacheDir, '_cacache'))
- })
- .then((modules) => {
- t.ok(modules, 'should create _cacache folder')
- t.end()
- })
-})
-
-test('cleanup', () => {
- SERVER.close()
- return Promise.all([rimraf(cacheDir), rimraf(testDir)])
-})
diff --git a/deps/npm/test/tap/circular-dep.js b/deps/npm/test/tap/circular-dep.js
deleted file mode 100644
index f7e018d023..0000000000
--- a/deps/npm/test/tap/circular-dep.js
+++ /dev/null
@@ -1,93 +0,0 @@
-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 test = require('tap').test
-
-var common = require('../common-tap.js')
-var server
-
-var pkg = common.pkg
-var minimist = path.join(pkg, 'minimist')
-
-var EXEC_OPTS = {
- cwd: path.join(pkg, 'minimist/node_modules'),
- npm_config_cache: common.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'
- )), 'optimist in place')
- t.ok(existsSync(path.resolve(
- minimist,
- 'node_modules', 'minimist'
- )), 'circular dependency uncircled')
- t.end()
- }
- )
- }
- )
-})
-
-test('cleanup', function (t) {
- server.close()
- t.end()
-})
-
-function setup (cb) {
- 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()
- })
-}
diff --git a/deps/npm/test/tap/config-basic.js b/deps/npm/test/tap/config-basic.js
deleted file mode 100644
index a95e94db29..0000000000
--- a/deps/npm/test/tap/config-basic.js
+++ /dev/null
@@ -1,79 +0,0 @@
-var test = require('tap').test
-var common = require('../common-config.js')
-var npmconf = require('../../lib/config/core.js')
-var path = require('path')
-
-var projectData = {
-}
-
-var ucData = common.ucData
-var envData = common.envData
-
-var gcData = { 'package-config:foo': 'boo' }
-
-var biData = {}
-
-var cli = { foo: 'bar', umask: parseInt('022', 8) }
-
-var expectNames = [
- 'cli',
- 'envData',
- 'projectData',
- 'ucData',
- 'gcData',
- 'biData'
-]
-var expectList = [
- cli,
- envData,
- projectData,
- ucData,
- gcData,
- biData
-]
-
-var expectSources = {
- cli: { data: cli },
- env: {
- data: envData,
- 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 }
-}
-
-function isDeeplyDetails (t, aa, bb, msg, seen) {
- return t.same(aa, bb, msg)
-}
-
-test('no builtin', function (t) {
- t.comment(process.env)
- npmconf.load(cli, function (er, conf) {
- if (er) throw er
- expectNames.forEach(function (name, ii) {
- isDeeplyDetails(t, conf.list[ii], expectList[ii], 'config properties list: ' + name)
- })
- isDeeplyDetails(t, conf.sources, expectSources, 'config by source')
- t.same(npmconf.rootConf.list, [], 'root configuration is empty')
- isDeeplyDetails(t, npmconf.rootConf.root, npmconf.defs.defaults, 'defaults')
- isDeeplyDetails(t, conf.root, npmconf.defs.defaults, 'current root config is defaults')
- t.is(conf.get('umask'), parseInt('022', 8), 'umask is as expected')
- t.is(conf.get('heading'), 'npm', 'config name is as expected')
- t.end()
- })
-})
diff --git a/deps/npm/test/tap/config-builtin.js b/deps/npm/test/tap/config-builtin.js
deleted file mode 100644
index 713522d6cc..0000000000
--- a/deps/npm/test/tap/config-builtin.js
+++ /dev/null
@@ -1,66 +0,0 @@
-var test = require('tap').test
-var npmconf = require('../../lib/config/core.js')
-var common = require('../common-config.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 = {
-}
-
-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()
- })
-})
diff --git a/deps/npm/test/tap/config-certfile.js b/deps/npm/test/tap/config-certfile.js
deleted file mode 100644
index 904a8c0147..0000000000
--- a/deps/npm/test/tap/config-certfile.js
+++ /dev/null
@@ -1,19 +0,0 @@
-require('../common-config.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)
- var ca = fs.readFileSync(cafile, 'utf8').trim()
- t.same(conf.get('ca').join(ca.match(/\r/g) ? '\r\n' : '\n'), ca)
- t.end()
- })
-})
diff --git a/deps/npm/test/tap/config-credentials.js b/deps/npm/test/tap/config-credentials.js
deleted file mode 100644
index d8f6770666..0000000000
--- a/deps/npm/test/tap/config-credentials.js
+++ /dev/null
@@ -1,350 +0,0 @@
-var test = require('tap').test
-
-var npmconf = require('../../lib/config/core.js')
-var common = require('../common-config.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()
- })
-})
diff --git a/deps/npm/test/tap/config-edit.js b/deps/npm/test/tap/config-edit.js
deleted file mode 100644
index a4f78a262c..0000000000
--- a/deps/npm/test/tap/config-edit.js
+++ /dev/null
@@ -1,74 +0,0 @@
-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 = common.pkg
-
-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,
- // We rely on the cwd + relative path combo here because otherwise,
- // this test will break if there's spaces in the editorPath
- EDITOR: 'node editor'
- }
- }
- 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)
-}
diff --git a/deps/npm/test/tap/config-envReplace.js b/deps/npm/test/tap/config-envReplace.js
deleted file mode 100644
index f65609f050..0000000000
--- a/deps/npm/test/tap/config-envReplace.js
+++ /dev/null
@@ -1,58 +0,0 @@
-/* eslint-disable no-template-curly-in-string */
-
-const fs = require('fs')
-const mkdirp = require('mkdirp')
-const rimraf = require('rimraf')
-const path = require('path')
-const ini = require('ini')
-const test = require('tap').test
-const npmconf = require('../../lib/config/core.js')
-
-const common = require('../common-tap.js')
-const packagePath = common.pkg
-
-const packageJsonFile = JSON.stringify({
- name: 'config-envReplace'
-})
-
-const inputConfigFile = [
- 'registry=${NPM_REGISTRY_URL}',
- '//${NPM_REGISTRY_HOST}/:_authToken=${NPM_AUTH_TOKEN}',
- 'always-auth=true',
- ''
-].join('\n')
-
-const expectConfigFile = [
- 'registry=http://my.registry.com/',
- '//my.registry.com/:_authToken=xxxxxxxxxxxxxxx',
- 'always-auth=true',
- ''
-].join('\n')
-
-test('environment variables replacing in configs', function (t) {
- process.env = Object.assign(process.env, {
- NPM_REGISTRY_URL: 'http://my.registry.com/',
- NPM_REGISTRY_HOST: 'my.registry.com',
- NPM_AUTH_TOKEN: 'xxxxxxxxxxxxxxx'
- })
- mkdirp.sync(packagePath)
- const packageJsonPath = path.resolve(packagePath, 'package.json')
- const configPath = path.resolve(packagePath, '.npmrc')
- fs.writeFileSync(packageJsonPath, packageJsonFile)
- fs.writeFileSync(configPath, inputConfigFile)
-
- const originalCwdPath = process.cwd()
- process.chdir(packagePath)
- npmconf.load(function (error, conf) {
- if (error) throw error
-
- const foundConfigFile = ini.stringify(conf.sources.project.data)
- t.same(ini.parse(foundConfigFile), ini.parse(expectConfigFile))
-
- fs.unlinkSync(packageJsonPath)
- fs.unlinkSync(configPath)
- rimraf.sync(packagePath)
- process.chdir(originalCwdPath)
- t.end()
- })
-})
diff --git a/deps/npm/test/tap/config-list.js b/deps/npm/test/tap/config-list.js
deleted file mode 100644
index 7559214a72..0000000000
--- a/deps/npm/test/tap/config-list.js
+++ /dev/null
@@ -1,69 +0,0 @@
-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 = common.pkg
-var opts = { cwd: pkg, env: common.emptyEnv() }
-var npmrc = path.resolve(pkg, '.npmrc')
-var npmrcContents = `
-_private=private;
-registry/:_pwd=pwd;
-foo=1234
-`
-
-test('setup', function (t) {
- rimraf.sync(pkg)
- mkdirp.sync(pkg)
-
- // Write per-project conf file
- fs.writeFileSync(npmrc, npmrcContents, 'utf8')
-
- // Create empty package.json to indicate project root
- fs.writeFileSync(path.resolve(pkg, 'package.json'), '{}', 'utf8')
- t.end()
-})
-
-test('config list includes project config', function (t) {
- common.npm(
- ['config', 'list'],
- opts,
- function (err, code, stdout, stderr) {
- t.ifError(err)
- t.equal(stderr, '', 'stderr is empty')
-
- var expected = '; project config ' + npmrc + '\nfoo = "1234"'
- t.match(stdout, expected, 'contains project config')
- t.notMatch(stdout, '_private', 'excludes private config')
- t.notMatch(stdout, '_pwd', 'excludes private segmented config')
- t.end()
- }
- )
-})
-
-test('config list --json outputs json', function (t) {
- common.npm(
- ['config', 'list', '--json'],
- opts,
- function (err, code, stdout, stderr) {
- t.ifError(err)
- t.equal(stderr, '', 'stderr is empty')
-
- var json = JSON.parse(stdout)
- t.equal(json.foo, '1234', 'contains project config')
- t.equal(json.argv, undefined, 'excludes argv')
- t.equal(json._private, undefined, 'excludes private config')
- t.equal(json['registry/:_pwd'], undefined, 'excludes private config')
- t.end()
- }
- )
-})
-
-// TODO: test cases for other configuration types (cli, env, user, global)
-
-test('clean', function (t) {
- rimraf.sync(pkg)
- t.end()
-})
diff --git a/deps/npm/test/tap/config-malformed.js b/deps/npm/test/tap/config-malformed.js
deleted file mode 100644
index 0d859e0034..0000000000
--- a/deps/npm/test/tap/config-malformed.js
+++ /dev/null
@@ -1,14 +0,0 @@
-var test = require('tap').test
-
-var npmconf = require('../../lib/config/core.js')
-var common = require('../common-config.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()
- })
-})
diff --git a/deps/npm/test/tap/config-meta.js b/deps/npm/test/tap/config-meta.js
deleted file mode 100644
index a98d5e6c4d..0000000000
--- a/deps/npm/test/tap/config-meta.js
+++ /dev/null
@@ -1,137 +0,0 @@
-// 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 bin = path.resolve(root, 'bin')
-var nm = path.resolve(root, 'node_modules')
-var doc = path.resolve(root, 'docs/content/using-npm/config.md')
-var FILES = []
-var CONFS = {}
-var DOC = {}
-
-var exceptions = [
- path.resolve(lib, 'adduser.js'),
- path.resolve(lib, 'config.js'),
- path.resolve(lib, 'config', 'pacote.js'),
- path.resolve(lib, 'pack.js'),
- path.resolve(lib, 'publish.js'),
- path.resolve(lib, 'install', 'inflate-shrinkwrap.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)
- walk(bin)
- 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 && f.indexOf('.cache') === -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)
- }
- }
-
- // TODO - needs better figgy-pudding introspection
- // for (var c2 in DOC) {
- // if (c2 !== 'versions' && c2 !== 'version' && c2 !== 'init.version' && c2 !== 'ham-it-up') {
- // 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?$/) && c !== 'ham-it-up') {
- 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?$/) && c !== 'ham-it-up') {
- t.ok(DOC[c], 'defaulted type should be documented ' + c)
- // t.ok(CONFS[c], 'defaulted type should be used ' + c)
- }
- })
-
- t.end()
-})
diff --git a/deps/npm/test/tap/config-new-cafile.js b/deps/npm/test/tap/config-new-cafile.js
deleted file mode 100644
index e4cc65ec74..0000000000
--- a/deps/npm/test/tap/config-new-cafile.js
+++ /dev/null
@@ -1,37 +0,0 @@
-const common = require('../common-tap.js')
-
-var path = require('path')
-var fs = require('graceful-fs')
-var test = require('tap').test
-var rimraf = require('rimraf')
-var npmconf = require('../../lib/config/core.js')
-
-var dir = common.pkg
-var beep = path.resolve(dir, 'beep.pem')
-var npmrc = path.resolve(dir, 'npmrc')
-
-test('can set new cafile when old is gone', function (t) {
- t.plan(5)
- fs.writeFileSync(npmrc, '')
- fs.writeFileSync(beep, '')
- npmconf.load({ userconfig: npmrc }, 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({ userconfig: npmrc }, function (error, conf) {
- if (error) {
- throw error
- }
- t.equal(conf.get('cafile'), beep)
- conf.del('cafile')
- conf.save('user', function (error) {
- t.ifError(error)
- })
- })
- })
- })
-})
diff --git a/deps/npm/test/tap/config-private.js b/deps/npm/test/tap/config-private.js
deleted file mode 100644
index e6bf9d2e83..0000000000
--- a/deps/npm/test/tap/config-private.js
+++ /dev/null
@@ -1,83 +0,0 @@
-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 = common.pkg
-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()
-})
diff --git a/deps/npm/test/tap/config-project.js b/deps/npm/test/tap/config-project.js
deleted file mode 100644
index 0f7be913c0..0000000000
--- a/deps/npm/test/tap/config-project.js
+++ /dev/null
@@ -1,66 +0,0 @@
-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('../common-config.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: parseInt('022', 8), 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'), parseInt('022', 8))
- t.equal(conf.get('heading'), 'npm')
- t.end()
- })
-})
diff --git a/deps/npm/test/tap/config-save.js b/deps/npm/test/tap/config-save.js
deleted file mode 100644
index 23dc7b5960..0000000000
--- a/deps/npm/test/tap/config-save.js
+++ /dev/null
@@ -1,91 +0,0 @@
-var fs = require('fs')
-var ini = require('ini')
-var t = require('tap')
-const test = t.test
-var common = require('../common-config.js')
-var commonTap = require('../common-tap.js')
-var npmconf = require('../../lib/config/core.js')
-
-var expectConf = [
- 'globalconfig = ' + common.globalconfig,
- 'email = i@izs.me',
- 'env-thing = foo',
- 'init.author.name = Isaac Z. Schlueter',
- 'init.author.email = i@izs.me',
- 'init.author.url = http://blog.izs.me/',
- 'init.version = 1.2.3',
- '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 = foo',
- 'init.author.name = Isaac Z. Schlueter',
- 'init.author.email = i@izs.me',
- 'init.author.url = http://blog.izs.me/',
- 'init.version = 1.2.3',
- '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')
-
-const userconfig = commonTap.pkg + '/userconfig'
-fs.writeFileSync(userconfig, fs.readFileSync(common.userconfig))
-process.env.npm_config_userconfig = userconfig
-
-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()
- })
-})
diff --git a/deps/npm/test/tap/correct-mkdir.js b/deps/npm/test/tap/correct-mkdir.js
deleted file mode 100644
index 175fb34a00..0000000000
--- a/deps/npm/test/tap/correct-mkdir.js
+++ /dev/null
@@ -1,167 +0,0 @@
-/* eslint-disable camelcase */
-var t = require('tap')
-var test = t.test
-var assert = require('assert')
-var requireInject = require('require-inject')
-const common = require('../common-tap.js')
-var cache_dir = common.pkg
-common.skipIfWindows('windows does not use correct-mkdir behavior')
-
-test('correct-mkdir: no race conditions', function (t) {
- var mock_fs = {}
- var did_hook = false
- mock_fs.lstat = function (path, cb) {
- if (path === cache_dir) {
- // Return a non-matching owner
- cb(null, {
- uid: +process.getuid() + 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,
- 'infer-owner': requireInject('infer-owner', { fs: mock_fs })
- }
- 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.lstat = 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(Object.assign(new Error(), {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.lstat = 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.lstat = 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(new Error('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)
-})
diff --git a/deps/npm/test/tap/cruft-test.js b/deps/npm/test/tap/cruft-test.js
deleted file mode 100644
index 4f2ed6c0d0..0000000000
--- a/deps/npm/test/tap/cruft-test.js
+++ /dev/null
@@ -1,43 +0,0 @@
-'use strict'
-var fs = require('graceful-fs')
-var path = require('path')
-var mkdirpSync = require('mkdirp').sync
-var rimraf = require('rimraf')
-var test = require('tap').test
-var common = require('../common-tap.js')
-
-var base = common.pkg
-var cruft = path.join(base, 'node_modules', 'cruuuft')
-var pkg = {
- name: 'example',
- version: '1.0.0',
- dependencies: {}
-}
-
-function setup () {
- mkdirpSync(path.dirname(cruft))
- fs.writeFileSync(cruft, 'this is some cruft for sure')
- fs.writeFileSync(path.join(base, 'package.json'), JSON.stringify(pkg))
-}
-
-function cleanup () {
- rimraf.sync(base)
-}
-
-test('setup', function (t) {
- cleanup()
- setup()
- t.done()
-})
-
-test('cruft', function (t) {
- common.npm(['ls'], {cwd: base}, function (er, code, stdout, stderr) {
- t.is(stderr, '', 'no warnings or errors from ls')
- t.done()
- })
-})
-
-test('cleanup', function (t) {
- cleanup()
- t.done()
-})
diff --git a/deps/npm/test/tap/debug-logs.js b/deps/npm/test/tap/debug-logs.js
deleted file mode 100644
index 4da52bfcee..0000000000
--- a/deps/npm/test/tap/debug-logs.js
+++ /dev/null
@@ -1,97 +0,0 @@
-'use strict'
-var path = require('path')
-var test = require('tap').test
-var Tacks = require('tacks')
-var glob = require('glob')
-var asyncMap = require('slide').asyncMap
-var File = Tacks.File
-var Dir = Tacks.Dir
-var common = require('../common-tap.js')
-
-var basedir = common.pkg
-var testdir = path.join(basedir, 'testdir')
-var cachedir = common.cache
-var globaldir = path.join(basedir, 'global')
-var tmpdir = path.join(basedir, 'tmp')
-
-var conf = {
- cwd: testdir,
- env: Object.assign({}, process.env, {
- npm_config_tmp: tmpdir,
- npm_config_prefix: globaldir,
- npm_config_registry: common.registry,
- npm_config_loglevel: 'warn'
- })
-}
-
-var fixture = new Tacks(Dir({
- global: Dir(),
- tmp: Dir(),
- testdir: Dir({
- 'package.json': File({
- name: 'debug-logs',
- version: '1.0.0',
- scripts: {
- true: 'node -e "process.exit(0)"',
- false: 'node -e "process.exit(1)"'
- }
- })
- })
-}))
-
-test('setup', function (t) {
- fixture.create(basedir)
- t.done()
-})
-
-test('example', function (t) {
- common.npm(['run', 'false'], conf, function (err, code, stdout, stderr) {
- if (err) throw err
- t.is(code, 1, 'command errored')
- const re = /A complete log of this run can be found in:.*\nnpm ERR! {5,5}(.*)/
- const matches = stderr.match(re)
- t.match(stderr, re, 'debug log mentioned in error message')
- if (matches) {
- var logfile = matches[1]
- t.matches(path.relative(cachedir, logfile), /^_logs/, 'debug log is inside the cache in _logs')
- }
-
- // we run a bunch concurrently, this will actually create > than our limit
- // as the check is done when the command starts
- //
- // It has to be > the log count (10) but also significantly higher than
- // the number of cores on the machine, or else some might be able to get
- // to the log folder pruning logic in parallel, resulting in FEWER files
- // than we expect being present at the end.
- var procCount = Math.max(require('os').cpus().length * 2, 12)
- var todo = new Array(procCount).join(',').split(',').map((v, k) => k)
- asyncMap(todo, function (num, next) {
- // another way would be to just simulate this?
- // var f = path.join(cachedir, '_logs', num + '-debug.log')
- // require('fs').writeFile(f, 'log ' + num, next)
- common.npm(['run', '--logs-max=10', 'false'], conf, function (err, code) {
- if (err) throw err
- t.is(code, 1, 'run #' + num + ' errored as expected')
- next()
- })
- }, function () {
- var files = glob.sync(path.join(cachedir, '_logs', '*'))
- t.ok(files.length > 10, 'there should be more than 10 log files')
-
- // now we do one more and that should clean up the list
- common.npm(['run', '--logs-max=10', 'false'], conf, function (err, code) {
- if (err) throw err
- t.is(code, 1, 'final run errored as expected')
- var files = glob.sync(path.join(cachedir, '_logs', '*'))
- t.is(files.length, 10, 'there should never be more than 10 log files')
- common.npm(['run', '--logs-max=5', 'true'], conf, function (err, code) {
- if (err) throw err
- t.is(code, 0, 'success run is ok')
- var files = glob.sync(path.join(cachedir, '_logs', '*'))
- t.is(files.length, 4, 'after success there should be logs-max - 1 log files')
- t.done()
- })
- })
- })
- })
-})
diff --git a/deps/npm/test/tap/dedupe-git-semver.js b/deps/npm/test/tap/dedupe-git-semver.js
deleted file mode 100644
index b7e31b0861..0000000000
--- a/deps/npm/test/tap/dedupe-git-semver.js
+++ /dev/null
@@ -1,138 +0,0 @@
-'use strict'
-const fs = require('fs')
-const path = require('path')
-const test = require('tap').test
-const requireInject = require('require-inject')
-const Tacks = require('tacks')
-const File = Tacks.File
-const Dir = Tacks.Dir
-
-const manifests = {
- 'git-wrap': {
- name: 'git-wrap',
- version: '1.0.0',
- dependencies: {
- git: 'git+https://example.com/git#semver:1.0'
- }
- },
- git: {
- name: 'git',
- version: '1.0.0'
- }
-}
-
-const npm = requireInject.installGlobally('../../lib/npm.js', {
- pacote: {
- manifest: function (spec) {
- const manifest = manifests[spec.name]
- manifest._requested = spec
- manifest._resolved = spec.saveSpec.replace(/^file:/, '').replace(/(:?#.*)$/, '#0000000000000000000000000000000000000000')
- manifest._from = spec.rawSpec
- return Promise.resolve(manifest)
- }
- },
- '../../lib/utils/output.js': function () {
- // do not output to stdout
- }
-})
-
-const common = require('../common-tap.js')
-const basedir = common.pkg
-const testdir = path.join(basedir, 'testdir')
-const cachedir = common.cache
-const tmpdir = path.join(basedir, 'tmp')
-
-const cwd = process.cwd()
-
-const conf = {
- cache: cachedir,
- tmp: tmpdir,
- loglevel: 'silent',
- 'package-lock-only': true
-}
-
-const fixture = new Tacks(Dir({
- cache: Dir(),
- global: Dir(),
- tmp: Dir(),
- testdir: Dir({
- 'package.json': File({
- name: 'fixture',
- version: '1.0.0',
- dependencies: {
- git: 'git+https://example.com/git#semver:1',
- 'git-wrap': 'file:git-wrap-1.0.0.tgz'
- }
- }),
- // Tarball source:
- // 'git-wrap': Dir({
- // 'package.json': File({
- // name: 'git-wrap',
- // version: '1.0.0',
- // dependencies: {
- // git: 'git+https://example.com/git#semver:1.0'
- // }
- // })
- // }),
- 'git-wrap-1.0.0.tgz': File(Buffer.from(
- '1f8b0800000000000003ed8fcd0ac23010843df729423caaf9c13642df26' +
- 'b44bad9a3434f107a4efeec68aa7de2c8898ef32cb0c3bec3a5d1d7503dc' +
- '8dca0ebeb38b991142a83c27537e44ee30db164a48a994c01987a210a873' +
- '1f32c5d907dde3299ff68cbf90b7fe08f78c106ab5015a12dab46173edb5' +
- 'a3ebe85ea0f76d676320996062746b70606bb0550b1ea3b84f9e9baf82d5' +
- '3e04e74bcee1a68d3b01ab3ac3d15f7a30d8586215c59d211bb26fff9e48' +
- '2412ffcc034458283d00080000',
- 'hex'
- ))
- })
-}))
-
-function setup () {
- cleanup()
- fixture.create(basedir)
-}
-
-function cleanup () {
- fixture.remove(basedir)
-}
-
-test('setup', function (t) {
- setup()
- process.chdir(testdir)
- npm.load(conf, function (err) {
- if (err) throw err
- t.done()
- })
-})
-
-test('dedupe matching git semver ranges', function (t) {
- npm.commands.install(function (err) {
- if (err) throw err
- const packageLock = JSON.parse(fs.readFileSync('package-lock.json'))
- t.same(packageLock, {
- name: 'fixture',
- version: '1.0.0',
- lockfileVersion: 1,
- requires: true,
- dependencies: {
- git: {
- from: 'git+https://example.com/git#semver:1',
- version: 'git+https://example.com/git#0000000000000000000000000000000000000000'
- },
- 'git-wrap': {
- version: 'file:git-wrap-1.0.0.tgz',
- requires: {
- git: 'git+https://example.com/git#semver:1'
- }
- }
- }
- })
- t.done()
- })
-})
-
-test('cleanup', function (t) {
- process.chdir(cwd)
- cleanup()
- t.done()
-})
diff --git a/deps/npm/test/tap/dedupe-scoped.js b/deps/npm/test/tap/dedupe-scoped.js
deleted file mode 100644
index 957f67e141..0000000000
--- a/deps/npm/test/tap/dedupe-scoped.js
+++ /dev/null
@@ -1,155 +0,0 @@
-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 = common.pkg
-var modules = join(pkg, 'node_modules')
-
-var EXEC_OPTS = { cwd: pkg }
-
-var body = [
- 'move\t@scope/shared\t2.1.6\tnode_modules/@scope/shared\t\tnode_modules/first/node_modules/@scope/shared',
- 'move\tfirstUnique\t0.6.0\tnode_modules/firstUnique\t\tnode_modules/first/node_modules/firstUnique',
- 'remove\t@scope/shared\t2.1.6\tnode_modules/second/node_modules/@scope/shared',
- 'move\tsecondUnique\t1.2.0\tnode_modules/secondUnique\t\tnode_modules/second/node_modules/secondUnique'
-]
-
-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'
- },
- '_resolved': 'foo',
- '_integrity': 'sha1-deadbeef'
-}
-
-var second = {
- 'name': 'second',
- 'version': '2.0.0',
- 'dependencies': {
- 'secondUnique': '1.2.0',
- '@scope/shared': '2.1.6'
- },
- '_resolved': 'foo',
- '_integrity': 'sha1-deadbeef'
-}
-
-var shared = {
- 'name': '@scope/shared',
- 'version': '2.1.6',
- '_resolved': 'foo',
- '_integrity': 'sha1-deadbeef'
-}
-
-var firstUnique = {
- 'name': 'firstUnique',
- 'version': '0.6.0',
- '_resolved': 'foo',
- '_integrity': 'sha1-deadbeef'
-}
-
-var secondUnique = {
- 'name': 'secondUnique',
- 'version': '1.2.0',
- '_resolved': 'foo',
- '_integrity': 'sha1-deadbeef'
-}
-
-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().replace(/\\/g, '/').split('\n').map(ltrimm),
- 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)
-}
diff --git a/deps/npm/test/tap/dedupe.js b/deps/npm/test/tap/dedupe.js
deleted file mode 100644
index 109f816562..0000000000
--- a/deps/npm/test/tap/dedupe.js
+++ /dev/null
@@ -1,122 +0,0 @@
-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 = common.pkg
-
-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'
- }
-}
-
-var shrinkwrap = {
- name: 'dedupe',
- version: '0.0.0',
- dependencies: {
- clean: {
- version: '2.1.6',
- dependencies: {
- checker: {
- version: '0.5.2',
- dependencies: {
- async: { version: '0.2.10' }
- }
- },
- minimist: { version: '0.0.5' }
- }
- },
- optimist: {
- version: '0.6.0',
- dependencies: {
- wordwrap: { version: '0.0.2' },
- minimist: { version: '0.0.5' }
- }
- }
- }
-}
-
-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,
- '--no-save',
- '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')), 'minimist module exists')
- t.notOk(
- existsSync(path.join(pkg, 'node_modules', 'clean', 'node_modules', 'minimist')),
- 'no clean/minimist'
- )
- t.notOk(
- existsSync(path.join(pkg, 'node_modules', 'optimist', 'node_modules', 'minimist')),
- 'no optmist/minimist'
- )
- t.end()
- }
- )
- })
-})
-
-test('cleanup', function (t) {
- server.close()
- cleanup()
-
- t.end()
-})
-
-function cleanup () {
- rimraf.sync(pkg)
-}
-
-function setup (cb) {
- 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)
-
- mr({ port: common.port }, function (er, s) {
- server = s
- cb()
- })
-}
diff --git a/deps/npm/test/tap/deprecate.js b/deps/npm/test/tap/deprecate.js
deleted file mode 100644
index 987acb80af..0000000000
--- a/deps/npm/test/tap/deprecate.js
+++ /dev/null
@@ -1,157 +0,0 @@
-var mr = require('npm-registry-mock')
-
-var test = require('tap').test
-var common = require('../common-tap.js')
-
-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()
-})
diff --git a/deps/npm/test/tap/dist-tag.js b/deps/npm/test/tap/dist-tag.js
deleted file mode 100644
index a5cce5d2a0..0000000000
--- a/deps/npm/test/tap/dist-tag.js
+++ /dev/null
@@ -1,271 +0,0 @@
-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 = common.pkg
-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' })
-
- 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' })
-
- 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' })
-
- // using a scoped registry
- server.get('/-/package/@scoped%2ffoo/dist-tags')
- .reply(200, { latest: '2.0.0', a: '0.0.2', b: '0.6.0' })
- server.delete('/-/package/@scoped%2ffoo/dist-tags/b')
- .reply(200, { b: '0.6.0' })
-
- // 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 default in current package', function (t) {
- common.npm(
- [
- 'dist-tags',
- '--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 ls default, named package', function (t) {
- common.npm(
- [
- 'dist-tags',
- '@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('npm dist-tags rm with registry assigned to scope', function (t) {
- fs.writeFileSync(path.resolve(pkg, '.npmrc'), `
-@scoped:registry=${common.registry}
-${common.registry.replace(/^https?:/, '')}:_authToken=taken
-`)
-
- common.npm(
- [
- 'dist-tags',
- 'rm', '@scoped/foo', 'b',
- '--loglevel', 'silent',
- '--userconfig', path.resolve(pkg, '.npmrc')
- ],
- { 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, '-b: @scoped/foo@0.6.0\n')
-
- t.end()
- }
- )
-})
-
-test('cleanup', function (t) {
- t.pass('cleaned up')
- rimraf.sync(pkg)
- server.close()
- t.end()
-})
diff --git a/deps/npm/test/tap/do-not-remove-other-bins.js b/deps/npm/test/tap/do-not-remove-other-bins.js
deleted file mode 100644
index a614043221..0000000000
--- a/deps/npm/test/tap/do-not-remove-other-bins.js
+++ /dev/null
@@ -1,117 +0,0 @@
-'use strict'
-var fs = require('fs')
-var path = require('path')
-
-var mkdirp = require('mkdirp')
-var test = require('tap').test
-
-var common = require('../common-tap')
-
-var base = common.pkg
-var installPath = path.resolve(base, 'install')
-var installBin = path.resolve(installPath, 'node_modules', '.bin')
-var packageApath = path.resolve(base, 'packageA')
-var packageBpath = path.resolve(base, 'packageB')
-
-var packageA = {
- name: 'a',
- version: '1.0.0',
- description: 'x',
- repository: 'x',
- license: 'MIT',
- bin: {
- testbin: './testbin.js'
- }
-}
-var packageB = {
- name: 'b',
- version: '1.0.0',
- description: 'x',
- repository: 'x',
- license: 'MIT',
- bin: {
- testbin: './testbin.js'
- }
-}
-
-var EXEC_OPTS = {
- cwd: installPath
-}
-
-test('setup', function (t) {
- mkdirp.sync(path.join(installPath, 'node_modules'))
- mkdirp.sync(packageApath)
- fs.writeFileSync(
- path.join(packageApath, 'package.json'),
- JSON.stringify(packageA, null, 2)
- )
- fs.writeFileSync(
- path.join(packageApath, packageA.bin.testbin),
- ''
- )
- mkdirp.sync(packageBpath)
- fs.writeFileSync(
- path.join(packageBpath, 'package.json'),
- JSON.stringify(packageB, null, 2)
- )
- fs.writeFileSync(
- path.join(packageBpath, packageB.bin.testbin),
- ''
- )
- t.end()
-})
-
-test('npm install A', function (t) {
- process.chdir(installPath)
- common.npm([
- 'install', packageApath
- ], EXEC_OPTS, function (err, code, stdout, stderr) {
- console.log(stdout, stderr)
- t.ifErr(err, 'install finished successfully')
- t.notOk(code, 'exit ok')
- t.notOk(stderr, 'Should not get data on stderr: ' + stderr)
- t.end()
- })
-})
-
-test('npm install B', function (t) {
- process.chdir(installPath)
- common.npm([
- 'install', packageBpath
- ], EXEC_OPTS, function (err, code, stdout, stderr) {
- t.ifErr(err, 'install finished successfully')
- t.notOk(code, 'exit ok')
- t.notOk(stderr, 'Should not get data on stderr: ' + stderr)
- t.end()
- })
-})
-
-test('verify bins', function (t) {
- var bin = path.dirname(
- path.resolve(
- installBin,
- common.readBinLink(path.join(installBin, 'testbin'))))
- t.is(bin, path.join(installPath, 'node_modules', 'b'))
- t.end()
-})
-
-test('rm install A', function (t) {
- process.chdir(installPath)
- common.npm([
- 'rm', packageApath
- ], EXEC_OPTS, function (err, code, stdout, stderr) {
- t.ifErr(err, 'install finished successfully')
- t.notOk(code, 'exit ok')
- t.notOk(stderr, 'Should not get data on stderr: ' + stderr)
- t.end()
- })
-})
-
-test('verify postremoval bins', function (t) {
- var bin = path.dirname(
- path.resolve(
- installBin,
- common.readBinLink(path.join(installBin, 'testbin'))))
- t.is(bin, path.join(installPath, 'node_modules', 'b'))
- t.end()
-})
diff --git a/deps/npm/test/tap/doctor-ping-registry-404.js b/deps/npm/test/tap/doctor-ping-registry-404.js
deleted file mode 100644
index 00a772a7c0..0000000000
--- a/deps/npm/test/tap/doctor-ping-registry-404.js
+++ /dev/null
@@ -1,108 +0,0 @@
-'use strict'
-/* eslint-disable camelcase */
-const common = require('../common-tap.js')
-const http = require('http')
-const mr = require('npm-registry-mock')
-const npm = require('../../lib/npm.js')
-const path = require('path')
-const Tacks = require('tacks')
-const t = require('tap')
-const which = require('which')
-
-const Dir = Tacks.Dir
-const File = Tacks.File
-
-const ROOT = common.pkg
-const CACHE = common.cache
-const TMP = path.join(ROOT, 'tmp')
-const PREFIX = path.join(ROOT, 'global-prefix')
-const PKG = path.join(ROOT, 'pkg')
-
-let server, nodeServer
-let node_url
-
-t.teardown(() => {
- if (server) {
- server.close()
- }
- if (nodeServer) {
- nodeServer.close()
- }
-})
-
-t.test('setup', (t) => {
- const port = common.port + 2
- nodeServer = http.createServer(function (q, s) {
- s.end(JSON.stringify([{ lts: true, version: '0.0.0' }]))
- })
- nodeServer.listen(port, () => {
- node_url = 'http://localhost:' + port
- mr({ port: common.port }, (err, s) => {
- t.ifError(err, 'registry mocked successfully')
- server = s
- server.get('/-/ping?write=true').reply(404)
- server.get('/npm').reply(
- 200,
- JSON.stringify({
- name: 'npm',
- 'dist-tags': { latest: '0.0.0' },
- versions: {
- '0.0.0': {
- name: 'npm',
- version: '0.0.0',
- _shrinkwrap: null,
- _hasShrinkwrap: false,
- dist: {
- shasum: 'deadbeef',
- tarball: 'https://reg.eh/npm-0.0.0.tgz'
- }
- }
- }
- })
- )
- const fixture = new Tacks(
- Dir({
- [path.basename(PKG)]: Dir({
- 'package.json': File({ name: 'npm', version: '0.0.0' })
- }),
- [path.basename(PREFIX)]: Dir({})
- })
- )
- fixture.create(ROOT)
- npm.load(
- {
- registry: common.registry,
- loglevel: 'silent',
- cache: CACHE,
- tmp: TMP,
- prefix: PREFIX
- },
- (err) => {
- t.ifError(err, 'npm loaded successfully')
- t.pass('all set up')
- t.done()
- }
- )
- })
- })
-})
-
-t.test('npm doctor ping returns 404 (or any other error)', function (t) {
- npm.commands.doctor({ 'node-url': node_url }, true, function (e, list) {
- t.ifError(e, 'npm loaded successfully')
- t.same(list.length, 9, 'list should have 9 prop')
- t.same(list[0][1], 'failed', 'npm ping')
- t.same(list[1][1], 'v' + npm.version, 'npm -v')
- t.same(list[2][1], process.version, 'node -v')
- t.same(list[3][1], common.registry + '/', 'npm config get registry')
- t.same(list[5][1], 'ok', 'Perms check on cached files')
- t.same(list[6][1], 'ok', 'Perms check on global node_modules')
- t.same(list[7][1], 'ok', 'Perms check on local node_modules')
- t.match(list[8][1], /^verified \d+ tarballs?$/, 'Cache verified')
- which('git', function (e, resolvedPath) {
- t.ifError(e, 'git command is installed')
- t.same(list[4][1], resolvedPath, 'which git')
- t.done()
- })
- })
-})
diff --git a/deps/npm/test/tap/doctor.js b/deps/npm/test/tap/doctor.js
deleted file mode 100644
index 9a1b42cdd5..0000000000
--- a/deps/npm/test/tap/doctor.js
+++ /dev/null
@@ -1,131 +0,0 @@
-'use strict'
-/* eslint-disable camelcase */
-const common = require('../common-tap.js')
-const http = require('http')
-const mr = require('npm-registry-mock')
-const npm = require('../../lib/npm.js')
-const path = require('path')
-const Tacks = require('tacks')
-const t = require('tap')
-const which = require('which')
-
-const Dir = Tacks.Dir
-const File = Tacks.File
-
-const ROOT = common.pkg
-const CACHE = common.cache
-const TMP = path.join(ROOT, 'tmp')
-const PREFIX = path.join(ROOT, 'global-prefix')
-const PKG = path.join(ROOT, 'pkg')
-
-let server
-let node_url
-const pingResponse = {
- host: 'registry.npmjs.org',
- ok: true,
- username: null,
- peer: 'example.com'
-}
-const npmResponse = {
- name: 'npm',
- 'dist-tags': {latest: '0.0.0'},
- 'versions': {
- '0.0.0': {
- name: 'npm',
- version: '0.0.0',
- _shrinkwrap: null,
- _hasShrinkwrap: false,
- dist: {
- shasum: 'deadbeef',
- tarball: 'https://reg.eh/npm-0.0.0.tgz'
- }
- }
- }
-}
-
-let nodeServer
-
-t.teardown(() => {
- if (server) {
- server.close()
- }
- if (nodeServer) {
- nodeServer.close()
- }
-})
-
-t.test('setup', (t) => {
- const port = common.port + 1
- nodeServer = http.createServer(function (q, s) {
- s.end(JSON.stringify([{lts: true, version: '0.0.0'}]))
- })
- nodeServer.listen(port, () => {
- node_url = 'http://localhost:' + port
- mr({port: common.port}, (err, s) => {
- t.ifError(err, 'registry mocked successfully')
- server = s
- server.get('/-/ping?write=true').reply(200, JSON.stringify(pingResponse))
- server.get('/npm').reply(200, JSON.stringify(npmResponse))
- const fixture = new Tacks(Dir({
- [path.basename(PKG)]: Dir({
- 'package.json': File({name: 'foo', version: '1.0.0'})
- }),
- [path.basename(PREFIX)]: Dir({})
- }))
- fixture.create(ROOT)
- npm.load({
- registry: common.registry,
- loglevel: 'silent',
- cache: CACHE,
- tmp: TMP,
- prefix: PREFIX
- }, (err) => {
- t.ifError(err, 'npm loaded successfully')
- t.pass('all set up')
- t.done()
- })
- })
- })
-})
-
-t.test('npm doctor', function (t) {
- npm.commands.doctor({'node-url': node_url}, true, function (e, list) {
- t.ifError(e, 'npm loaded successfully')
- t.same(list.length, 9, 'list should have 9 prop')
- t.same(list[0][1], 'ok', 'npm ping')
- t.same(list[1][1], 'v' + npm.version, 'npm -v')
- t.same(list[2][1], process.version, 'node -v')
- t.same(list[3][1], common.registry + '/', 'npm config get registry')
- t.same(list[5][1], 'ok', 'Perms check on cached files')
- t.same(list[6][1], 'ok', 'Perms check on global node_modules')
- t.same(list[7][1], 'ok', 'Perms check on local node_modules')
- t.match(list[8][1], /^verified \d+ tarballs?$/, 'Cache verified')
- which('git', function (e, resolvedPath) {
- t.ifError(e, 'git command is installed')
- t.same(list[4][1], resolvedPath, 'which git')
- t.done()
- })
- })
-})
-
-t.test('npm doctor works without registry', function (t) {
- npm.config.set('registry', false)
- npm.commands.doctor({'node-url': node_url}, true, function (e, list) {
- t.ifError(e, 'npm loaded successfully')
- t.same(list.length, 9, 'list should have 9 prop')
- t.same(list[0][1], 'ok', 'npm ping')
- t.same(list[1][1], 'v' + npm.version, 'npm -v')
- t.same(list[2][1], process.version, 'node -v')
- t.same(list[3][1], '', 'no registry, but no crash')
- t.same(list[5][1], 'ok', 'Perms check on cached files')
- t.same(list[6][1], 'ok', 'Perms check on global node_modules')
- t.same(list[7][1], 'ok', 'Perms check on local node_modules')
- t.match(list[8][1], /^verified \d+ tarballs?$/, 'Cache verified')
- which('git', function (e, resolvedPath) {
- t.ifError(e, 'git command is installed')
- t.same(list[4][1], resolvedPath, 'which git')
- server.close()
- t.done()
- })
- })
-})
diff --git a/deps/npm/test/tap/extraneous-dep-cycle-ls-ok.js b/deps/npm/test/tap/extraneous-dep-cycle-ls-ok.js
deleted file mode 100644
index 11f52209ed..0000000000
--- a/deps/npm/test/tap/extraneous-dep-cycle-ls-ok.js
+++ /dev/null
@@ -1,71 +0,0 @@
-'use strict'
-var fs = require('fs')
-var path = require('path')
-
-var test = require('tap').test
-var mkdirp = require('mkdirp')
-var rimraf = require('rimraf')
-
-var common = require('../common-tap')
-
-var pkg = common.pkg
-var pathModA = path.join(pkg, 'node_modules', 'moduleA')
-var pathModB = path.join(pkg, 'node_modules', 'moduleB')
-
-var modA = {
- name: 'moduleA',
- version: '1.0.0',
- _requiredBy: [ '#USER', '/moduleB' ],
- dependencies: {
- moduleB: '1.0.0'
- }
-}
-var modB = {
- name: 'moduleB',
- version: '1.0.0',
- _requiredBy: [ '/moduleA' ],
- dependencies: {
- moduleA: '1.0.0'
- }
-}
-
-function setup () {
- mkdirp.sync(pathModA)
- fs.writeFileSync(
- path.join(pathModA, 'package.json'),
- JSON.stringify(modA, null, 2)
- )
- mkdirp.sync(pathModB)
- fs.writeFileSync(
- path.join(pathModB, 'package.json'),
- JSON.stringify(modB, null, 2)
- )
-}
-
-function cleanup () {
- rimraf.sync(pkg)
-}
-
-test('setup', function (t) {
- cleanup()
- setup()
- t.end()
-})
-
-var expected = pkg + '\n' +
- '└─┬ moduleA@1.0.0\n' +
- ' └─┬ moduleB@1.0.0\n' +
- ' └── moduleA@1.0.0 deduped\n\n'
-
-test('extraneous-dep-cycle', function (t) {
- common.npm(['ls', '--unicode=true'], {cwd: pkg}, function (er, code, stdout, stderr) {
- t.ifErr(er, 'install finished successfully')
- t.is(stdout, expected, 'ls output shows module')
- t.end()
- })
-})
-
-test('cleanup', function (t) {
- cleanup()
- t.end()
-})
diff --git a/deps/npm/test/tap/false-name.js b/deps/npm/test/tap/false-name.js
deleted file mode 100644
index 57d2a2ad2f..0000000000
--- a/deps/npm/test/tap/false-name.js
+++ /dev/null
@@ -1,79 +0,0 @@
-// 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 mr = require('npm-registry-mock')
-var test = require('tap').test
-
-var common = require('../common-tap.js')
-
-var pkg = common.pkg
-var cache = common.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')),
- 'test-package-with-one-dep installed OK'
- )
- t.ok(
- existsSync(path.join(pkg, 'node_modules', 'test-package')),
- 'test-package subdep installed OK'
- )
- t.end()
- }
- )
-})
-
-test('cleanup', function (t) {
- server.close()
- t.end()
-})
-
-function setup () {
- fs.writeFileSync(
- path.join(pkg, 'package.json'),
- JSON.stringify(json, null, 2)
- )
- fs.writeFileSync(path.join(pkg, 'index.js'), indexContent)
-}
diff --git a/deps/npm/test/tap/fetch-package-metadata.js b/deps/npm/test/tap/fetch-package-metadata.js
deleted file mode 100644
index 2e666772ed..0000000000
--- a/deps/npm/test/tap/fetch-package-metadata.js
+++ /dev/null
@@ -1,48 +0,0 @@
-'use strict'
-var mr = require('npm-registry-mock')
-var npa = require('npm-package-arg')
-var test = require('tap').test
-
-var common = require('../common-tap.js')
-var npm = require('../../lib/npm.js')
-
-var pkg = common.pkg
-
-test('setup', function (t) {
- process.chdir(pkg)
-
- var opts = {
- cache: common.cache,
- registry: common.registry,
- // important to make sure devDependencies don't get stripped
- dev: true
- }
- npm.load(opts, t.end)
-})
-
-test('fetch-package-metadata provides resolved metadata', function (t) {
- t.plan(4)
-
- var fetchPackageMetadata = require('../../lib/fetch-package-metadata')
-
- var testPackage = npa('test-package@>=0.0.0')
-
- mr({ port: common.port }, thenFetchMetadata)
-
- var server
- function thenFetchMetadata (err, s) {
- t.ifError(err, 'setup mock registry')
- server = s
-
- fetchPackageMetadata(testPackage, __dirname, thenVerifyMetadata)
- }
-
- function thenVerifyMetadata (err, pkg) {
- t.ifError(err, 'fetched metadata')
-
- t.equals(pkg._resolved, 'http://localhost:' + common.port + '/test-package/-/test-package-0.0.0.tgz', '_resolved')
- t.equals(pkg._integrity, 'sha1-sNMrbEXCWcV4uiADdisgUTG9+9E=', '_integrity')
- server.close()
- t.end()
- }
-})
diff --git a/deps/npm/test/tap/format-package-lock.js b/deps/npm/test/tap/format-package-lock.js
deleted file mode 100644
index ddf40915d9..0000000000
--- a/deps/npm/test/tap/format-package-lock.js
+++ /dev/null
@@ -1,116 +0,0 @@
-'use strict'
-const fs = require('fs')
-const path = require('path')
-const test = require('tap').test
-const mr = require('npm-registry-mock')
-const Tacks = require('tacks')
-const File = Tacks.File
-const Dir = Tacks.Dir
-const common = require('../common-tap.js')
-
-const basedir = common.pkg
-const testdir = path.join(basedir, 'testdir')
-const cachedir = common.cache
-const globaldir = path.join(basedir, 'global')
-const tmpdir = path.join(basedir, 'tmp')
-
-const pkgPath = path.join(testdir, 'package.json')
-const pkgLockPath = path.join(testdir, 'package-lock.json')
-const shrinkwrapPath = path.join(testdir, 'npm-shrinkwrap.json')
-const CRLFreg = /\r\n|\r|\n/
-
-const env = common.newEnv().extend({
- npm_config_cache: cachedir,
- npm_config_tmp: tmpdir,
- npm_config_prefix: globaldir,
- npm_config_registry: common.registry,
- npm_config_loglevel: 'warn',
- npm_config_format_package_lock: false
-})
-
-var server
-var fixture = new Tacks(Dir({
- cache: Dir(),
- global: Dir(),
- tmp: Dir(),
- testdir: Dir({
- 'package.json': File({
- name: 'install-package-lock-only',
- version: '1.0.0',
- dependencies: {
- mkdirp: '^0.3.4'
- }
- })
- })
-}))
-
-function setup () {
- cleanup()
- fixture.create(basedir)
-}
-
-function cleanup () {
- fixture.remove(basedir)
-}
-
-test('setup', function (t) {
- mr({port: common.port, throwOnUnmatched: true}, function (err, s) {
- if (err) throw err
- server = s
- t.done()
- })
-})
-
-test('package-lock.json unformatted, package.json formatted when config has `format-package-lock: false`', function (t) {
- setup()
- common.npm(['install'], {cwd: testdir, env}).spread((code, stdout, stderr) => {
- t.is(code, 0, 'ok')
- t.ok(fs.existsSync(pkgLockPath), 'ensure that package-lock.json was created')
- const pkgLockUtf8 = fs.readFileSync(pkgLockPath, 'utf-8')
- t.equal(pkgLockUtf8.split(CRLFreg).length, 2, 'package-lock.json is unformatted')
- const pkgUtf8 = fs.readFileSync(pkgPath, 'utf-8')
- t.notEqual(pkgUtf8.split(CRLFreg).length, 2, 'package.json is formatted')
- t.done()
- })
-})
-
-test('npm-shrinkwrap.json unformatted when config has `format-package-lock: false`', function (t) {
- setup()
- common.npm(['shrinkwrap'], {cwd: testdir, env}).spread((code, stdout, stderr) => {
- t.is(code, 0, 'ok')
- t.ok(fs.existsSync(shrinkwrapPath), 'ensure that npm-shrinkwrap.json was created')
- const shrinkwrapUtf8 = fs.readFileSync(shrinkwrapPath, 'utf-8')
- t.equal(shrinkwrapUtf8.split(CRLFreg).length, 2, 'npm-shrinkwrap.json is unformatted')
- t.done()
- })
-})
-
-test('package-lock.json and package.json formatted when config has `format-package-lock: true`', function (t) {
- setup()
- common.npm(['install'], {cwd: testdir}).spread((code, stdout, stderr) => {
- t.is(code, 0, 'ok')
- t.ok(fs.existsSync(pkgLockPath), 'ensure that package-lock.json was created')
- const pkgLockUtf8 = fs.readFileSync(pkgLockPath, 'utf-8')
- t.notEqual(pkgLockUtf8.split(CRLFreg).length, 2, 'package-lock.json is formatted')
- const pkgUtf8 = fs.readFileSync(pkgPath, 'utf-8')
- t.notEqual(pkgUtf8.split(CRLFreg).length, 2, 'package.json is formatted')
- t.done()
- })
-})
-
-test('npm-shrinkwrap.json formatted when config has `format-package-lock: true`', function (t) {
- setup()
- common.npm(['shrinkwrap'], {cwd: testdir}).spread((code, stdout, stderr) => {
- t.is(code, 0, 'ok')
- t.ok(fs.existsSync(shrinkwrapPath), 'ensure that npm-shrinkwrap.json was created')
- const shrinkwrapUtf8 = fs.readFileSync(shrinkwrapPath, 'utf-8')
- t.notEqual(shrinkwrapUtf8.split(CRLFreg).length, 2, 'npm-shrinkwrap.json is unformatted')
- t.done()
- })
-})
-
-test('cleanup', function (t) {
- server.close()
- cleanup()
- t.done()
-})
diff --git a/deps/npm/test/tap/full-warning-messages.js b/deps/npm/test/tap/full-warning-messages.js
deleted file mode 100644
index 945cf66a62..0000000000
--- a/deps/npm/test/tap/full-warning-messages.js
+++ /dev/null
@@ -1,112 +0,0 @@
-'use strict'
-var test = require('tap').test
-var path = require('path')
-var mkdirp = require('mkdirp')
-var rimraf = require('rimraf')
-var fs = require('graceful-fs')
-var common = require('../common-tap')
-
-var base = common.pkg
-var modA = path.resolve(base, 'modA')
-var modB = path.resolve(base, 'modB')
-
-var json = {
- 'name': 'test-full-warning-messages',
- 'version': '1.0.0',
- 'description': 'abc',
- 'repository': 'git://abc/',
- 'license': 'ISC',
- 'dependencies': {
- 'modA': modA
- }
-}
-
-var modAJson = {
- 'name': 'modA',
- 'version': '1.0.0',
- 'optionalDependencies': {
- 'modB': modB
- }
-}
-
-var modBJson = {
- 'name': 'modB',
- 'version': '1.0.0',
- 'os': ['nope'],
- 'cpu': 'invalid'
-}
-
-function modJoin () {
- var modules = Array.prototype.slice.call(arguments)
- return modules.reduce(function (a, b) {
- return path.resolve(a, 'node_modules', b)
- })
-}
-
-function writeJson (mod, data) {
- fs.writeFileSync(path.resolve(mod, 'package.json'), JSON.stringify(data))
-}
-
-function setup () {
- cleanup()
- ;[modA, modB].forEach(function (mod) { mkdirp.sync(mod) })
- writeJson(base, json)
- writeJson(modA, modAJson)
- writeJson(modB, modBJson)
-}
-
-function cleanup () {
- rimraf.sync(base)
-}
-
-test('setup', function (t) {
- setup()
- t.end()
-})
-
-function exists (t, filepath, msg) {
- try {
- fs.statSync(filepath)
- t.pass(msg)
- return true
- } catch (ex) {
- t.fail(msg, {found: null, wanted: 'exists', compare: 'fs.stat(' + filepath + ')'})
- return false
- }
-}
-
-function notExists (t, filepath, msg) {
- try {
- fs.statSync(filepath)
- t.fail(msg, {found: 'exists', wanted: null, compare: 'fs.stat(' + filepath + ')'})
- return true
- } catch (ex) {
- t.pass(msg)
- return false
- }
-}
-
-test('tree-style', function (t) {
- common.npm(['install', '--json', '--loglevel=warn'], {cwd: base}, function (err, code, stdout, stderr) {
- if (err) throw err
- t.is(code, 0, 'result code')
- var result = JSON.parse(stdout)
- t.is(result.added.length, 1, 'only added one module')
- t.is(result.added[0].name, 'modA', 'modA got installed')
- t.is(result.warnings.length, 1, 'one warning')
- var stderrlines = stderr.trim().split(/\n/)
- t.is(stderrlines.length, 2, 'two lines of warnings')
- t.match(stderr, /SKIPPING OPTIONAL DEPENDENCY/, 'expected optional failure warning in stderr')
- t.match(stderr, /Unsupported platform/, 'reason for optional failure in stderr')
- t.match(result.warnings[0], /SKIPPING OPTIONAL DEPENDENCY/, 'expected optional failure warning in JSON')
- t.match(result.warnings[0], /Unsupported platform/, 'reason for optional failure in JSON')
- exists(t, modJoin(base, 'modA'), 'module A')
- notExists(t, modJoin(base, 'modB'), 'module B')
- t.done()
- })
-})
-
-test('cleanup', function (t) {
- cleanup()
- t.end()
-})
diff --git a/deps/npm/test/tap/fund.js b/deps/npm/test/tap/fund.js
deleted file mode 100644
index 48d903f989..0000000000
--- a/deps/npm/test/tap/fund.js
+++ /dev/null
@@ -1,405 +0,0 @@
-'use strict'
-
-const fs = require('fs')
-const path = require('path')
-
-const test = require('tap').test
-const Tacks = require('tacks')
-const Dir = Tacks.Dir
-const File = Tacks.File
-const common = require('../common-tap.js')
-const isWindows = require('../../lib/utils/is-windows.js')
-
-const base = common.pkg
-const noFunding = path.join(base, 'no-funding-package')
-const maintainerOwnsAllDeps = path.join(base, 'maintainer-owns-all-deps')
-const nestedNoFundingPackages = path.join(base, 'nested-no-funding-packages')
-const nestedMultipleFundingPackages = path.join(base, 'nested-multiple-funding-packages')
-const fundingStringShorthand = path.join(base, 'funding-string-shorthand')
-
-function getFixturePackage ({ name, version, dependencies, funding }, extras) {
- const getDeps = () => Object
- .keys(dependencies)
- .reduce((res, dep) => (Object.assign({}, res, {
- [dep]: '*'
- })), {})
-
- return Dir(Object.assign({
- 'package.json': File({
- name,
- version: version || '1.0.0',
- funding: (funding === undefined) ? {
- type: 'individual',
- url: 'http://example.com/donate'
- } : funding,
- dependencies: dependencies && getDeps(dependencies)
- })
- }, extras))
-}
-
-const fixture = new Tacks(Dir({
- 'funding-string-shorthand': Dir({
- 'package.json': File({
- name: 'funding-string-shorthand',
- version: '0.0.0',
- funding: 'https://example.com/sponsor'
- })
- }),
- 'no-funding-package': Dir({
- 'package.json': File({
- name: 'no-funding-package',
- version: '0.0.0'
- })
- }),
- 'maintainer-owns-all-deps': getFixturePackage({
- name: 'maintainer-owns-all-deps',
- dependencies: {
- 'dep-foo': '*',
- 'dep-bar': '*'
- }
- }, {
- node_modules: Dir({
- 'dep-foo': getFixturePackage({
- name: 'dep-foo',
- dependencies: {
- 'dep-sub-foo': '*'
- }
- }, {
- node_modules: Dir({
- 'dep-sub-foo': getFixturePackage({
- name: 'dep-sub-foo'
- })
- })
- }),
- 'dep-bar': getFixturePackage({
- name: 'dep-bar'
- })
- })
- }),
- 'nested-no-funding-packages': getFixturePackage({
- name: 'nested-no-funding-packages',
- funding: null,
- dependencies: {
- foo: '*'
- },
- devDependencies: {
- lorem: '*'
- }
- }, {
- node_modules: Dir({
- foo: getFixturePackage({
- name: 'foo',
- dependencies: {
- bar: '*'
- },
- funding: null
- }, {
- node_modules: Dir({
- bar: getFixturePackage({
- name: 'bar'
- }, {
- node_modules: Dir({
- 'sub-bar': getFixturePackage({
- name: 'sub-bar',
- funding: 'https://example.com/sponsor'
- })
- })
- })
- })
- }),
- lorem: getFixturePackage({
- name: 'lorem',
- funding: {
- url: 'https://example.com/lorem'
- }
- })
- })
- }),
- 'nested-multiple-funding-packages': getFixturePackage({
- name: 'nested-multiple-funding-packages',
- funding: [
- 'https://one.example.com',
- 'https://two.example.com'
- ],
- dependencies: {
- foo: '*'
- },
- devDependencies: {
- bar: '*'
- }
- }, {
- node_modules: Dir({
- foo: getFixturePackage({
- name: 'foo',
- funding: [
- 'http://example.com',
- { url: 'http://sponsors.example.com/me' },
- 'http://collective.example.com'
- ]
- }),
- bar: getFixturePackage({
- name: 'bar',
- funding: [
- 'http://collective.example.com',
- { url: 'http://sponsors.example.com/you' }
- ]
- })
- })
- })
-}))
-
-function checkOutput (t, { code, stdout, stderr }) {
- t.is(code, 0, `exited code 0`)
- t.is(stderr, '', 'no warnings')
-}
-
-function jsonTest (t, { assertionMsg, expected, stdout }) {
- let parsed = JSON.parse(stdout)
- t.deepEqual(parsed, expected, assertionMsg)
-}
-
-function snapshotTest (t, { stdout, assertionMsg }) {
- t.matchSnapshot(stdout, assertionMsg)
-}
-
-function testFundCmd ({ title, assertionMsg, args = [], opts = {}, output = checkOutput, assertion = snapshotTest, expected }) {
- const validate = (t) => (err, code, stdout, stderr) => {
- if (err) throw err
-
- output(t, { code, stdout, stderr })
- assertion(t, { assertionMsg, expected, stdout })
- }
-
- return test(title, (t) => {
- t.plan(3)
- common.npm(['fund', '--unicode=false'].concat(args), opts, validate(t))
- })
-}
-
-test('setup', function (t) {
- fixture.remove(base)
- fixture.create(base)
- t.end()
-})
-
-testFundCmd({
- title: 'fund with no package containing funding',
- assertionMsg: 'should print empty funding info',
- opts: { cwd: noFunding }
-})
-
-testFundCmd({
- title: 'fund in which same maintainer owns all its deps',
- assertionMsg: 'should print stack packages together',
- opts: { cwd: maintainerOwnsAllDeps }
-})
-
-testFundCmd({
- title: 'fund in which same maintainer owns all its deps, using --json option',
- assertionMsg: 'should print stack packages together',
- args: ['--json'],
- opts: { cwd: maintainerOwnsAllDeps },
- assertion: jsonTest,
- expected: {
- length: 3,
- name: 'maintainer-owns-all-deps',
- version: '1.0.0',
- funding: { type: 'individual', url: 'http://example.com/donate' },
- dependencies: {
- 'dep-bar': {
- version: '1.0.0',
- funding: { type: 'individual', url: 'http://example.com/donate' }
- },
- 'dep-foo': {
- version: '1.0.0',
- funding: { type: 'individual', url: 'http://example.com/donate' },
- dependencies: {
- 'dep-sub-foo': {
- version: '1.0.0',
- funding: { type: 'individual', url: 'http://example.com/donate' }
- }
- }
- }
- }
- }
-})
-
-testFundCmd({
- title: 'fund containing multi-level nested deps with no funding',
- assertionMsg: 'should omit dependencies with no funding declared',
- opts: { cwd: nestedNoFundingPackages }
-})
-
-testFundCmd({
- title: 'fund containing multi-level nested deps with no funding, using --json option',
- assertionMsg: 'should omit dependencies with no funding declared',
- args: ['--json'],
- opts: { cwd: nestedNoFundingPackages },
- assertion: jsonTest,
- expected: {
- length: 3,
- name: 'nested-no-funding-packages',
- version: '1.0.0',
- dependencies: {
- lorem: { version: '1.0.0', funding: { url: 'https://example.com/lorem' } },
- bar: {
- version: '1.0.0',
- funding: { type: 'individual', url: 'http://example.com/donate' },
- dependencies: {
- 'sub-bar': {
- version: '1.0.0',
- funding: { url: 'https://example.com/sponsor' }
- }
- }
- }
- }
- }
-})
-
-testFundCmd({
- title: 'fund containing multi-level nested deps with multiple funding sources, using --json option',
- assertionMsg: 'should omit dependencies with no funding declared',
- args: ['--json'],
- opts: { cwd: nestedMultipleFundingPackages },
- assertion: jsonTest,
- expected: {
- length: 2,
- name: 'nested-multiple-funding-packages',
- version: '1.0.0',
- funding: [
- {
- url: 'https://one.example.com'
- },
- {
- url: 'https://two.example.com'
- }
- ],
- dependencies: {
- bar: {
- version: '1.0.0',
- funding: [
- {
- url: 'http://collective.example.com'
- },
- {
- url: 'http://sponsors.example.com/you'
- }
- ]
- },
- foo: {
- version: '1.0.0',
- funding: [
- {
- url: 'http://example.com'
- },
- {
- url: 'http://sponsors.example.com/me'
- },
- {
- url: 'http://collective.example.com'
- }
- ]
- }
- }
- }
-})
-
-testFundCmd({
- title: 'fund does not support global',
- assertionMsg: 'should throw EFUNDGLOBAL error',
- args: ['--global'],
- output: (t, { code, stdout, stderr }) => {
- t.is(code, 1, `exited code 0`)
- const [ errCode, errCmd ] = stderr.split('\n')
- t.matchSnapshot(`${errCode}\n${errCmd}`, 'should write error msgs to stderr')
- }
-})
-
-testFundCmd({
- title: 'fund does not support global, using --json option',
- assertionMsg: 'should throw EFUNDGLOBAL error',
- args: ['--global', '--json'],
- output: (t, { code, stdout, stderr }) => {
- t.is(code, 1, `exited code 0`)
- const [ errCode, errCmd ] = stderr.split('\n')
- t.matchSnapshot(`${errCode}\n${errCmd}`, 'should write error msgs to stderr')
- },
- assertion: jsonTest,
- expected: {
- error: {
- code: 'EFUNDGLOBAL',
- summary: '`npm fund` does not support global packages',
- detail: ''
- }
- }
-})
-
-testFundCmd({
- title: 'fund using package argument with no browser',
- assertionMsg: 'should open funding url',
- args: ['.', '--no-browser'],
- opts: { cwd: maintainerOwnsAllDeps }
-})
-
-testFundCmd({
- title: 'fund using string shorthand',
- assertionMsg: 'should open string-only url',
- args: ['.', '--no-browser'],
- opts: { cwd: fundingStringShorthand }
-})
-
-testFundCmd({
- title: 'fund using nested packages with multiple sources',
- assertionMsg: 'should prompt with all available URLs',
- args: ['.'],
- opts: { cwd: nestedMultipleFundingPackages }
-})
-
-testFundCmd({
- title: 'fund using nested packages with multiple sources, with a source number',
- assertionMsg: 'should open the numbered URL',
- args: ['.', '--which=1', '--no-browser'],
- opts: { cwd: nestedMultipleFundingPackages }
-})
-
-testFundCmd({
- title: 'fund using package argument with no browser, using --json option',
- assertionMsg: 'should open funding url',
- args: ['.', '--json', '--no-browser'],
- opts: { cwd: maintainerOwnsAllDeps },
- assertion: jsonTest,
- expected: {
- title: 'individual funding available at the following URL',
- url: 'http://example.com/donate'
- }
-})
-
-if (!isWindows) {
- test('fund using package argument', function (t) {
- const fakeBrowser = path.join(common.pkg, '_script.sh')
- const outFile = path.join(common.pkg, '_output')
-
- const s = '#!/usr/bin/env bash\n' +
- 'echo "$@" > ' + JSON.stringify(common.pkg) + '/_output\n'
- fs.writeFileSync(fakeBrowser, s)
- fs.chmodSync(fakeBrowser, '0755')
-
- common.npm([
- 'fund', '.',
- '--loglevel=silent',
- '--browser=' + fakeBrowser
- ], { cwd: maintainerOwnsAllDeps }, function (err, code, stdout, stderr) {
- t.ifError(err, 'repo command ran without error')
- t.equal(code, 0, 'exit ok')
- var res = fs.readFileSync(outFile, 'utf8')
- t.equal(res, 'http://example.com/donate\n')
- t.end()
- })
- })
-}
-
-test('cleanup', function (t) {
- t.pass(base)
- fixture.remove(base)
- t.end()
-})
diff --git a/deps/npm/test/tap/gently-rm-cmdshims.js b/deps/npm/test/tap/gently-rm-cmdshims.js
deleted file mode 100644
index 6726fe76d8..0000000000
--- a/deps/npm/test/tap/gently-rm-cmdshims.js
+++ /dev/null
@@ -1,161 +0,0 @@
-'use strict'
-/* eslint-disable camelcase */
-var path = require('path')
-var fs = require('graceful-fs')
-var test = require('tap').test
-var mkdirp = require('mkdirp')
-var rimraf = require('rimraf')
-var npm = require('../../lib/npm.js')
-
-const common = require('../common-tap.js')
-var work = common.pkg
-var doremove = path.join(work, 'doremove')
-var dontremove = path.join(work, 'dontremove')
-var example_json = {
- name: 'example',
- version: '1.0.0',
- bin: {
- 'example': 'example.js'
- }
-}
-var example_bin =
- '#!/usr/bin/env node\n' +
- 'true\n'
-
-// NOTE: if this were actually produced on windows it would be \ not / of
-// course, buuut, path.resolve doesn't understand \ outside of windows =/
-var do_example_cmd =
- '@IF EXIST "%~dp0\\node.exe" (\n' +
- ' "%~dp0\\node.exe" "%~dp0\\../example/example.js" %*\n' +
- ') ELSE (\n' +
- ' @SETLOCAL\n' +
- ' @SET PATHEXT=%PATHEXT:;.JS;=;%\n' +
- ' node "%~dp0\\../example/example.js" %*\n' +
- ')\n'
-
-var do_example_cygwin =
- '#!/bin/sh\n' +
- 'basedir=`dirname "$0"`\n' +
- '\n' +
- 'case `uname` in\n' +
- ' *CYGWIN*) basedir=`cygpath -w "$basedir"`;;\n' +
- 'esac\n' +
- '\n' +
- 'if [ -x "$basedir/node" ]; then\n' +
- ' "$basedir/node" "$basedir/../example/example.js" "$@"\n' +
- ' ret=$?\n' +
- 'else\n' +
- ' node "$basedir/../example/example.js" "$@"\n' +
- ' ret=$?\n' +
- 'fi\n' +
- 'exit $ret\n'
-
-var dont_example_cmd =
- '@IF EXIST "%~dp0\\node.exe" (\n' +
- ' "%~dp0\\node.exe" "%~dp0\\../example-other/example.js" %*\n' +
- ') ELSE (\n' +
- ' @SETLOCAL\n' +
- ' @SET PATHEXT=%PATHEXT:;.JS;=;%\n' +
- ' node "%~dp0\\../example-other/example.js" %*\n' +
- ')\n'
-
-var dont_example_cygwin =
- '#!/bin/sh\n' +
- 'basedir=`dirname "$0"`\n' +
- '\n' +
- 'case `uname` in\n' +
- ' *CYGWIN*) basedir=`cygpath -w "$basedir"`;;\n' +
- 'esac\n' +
- '\n' +
- 'if [ -x "$basedir/node" ]; then\n' +
- ' "$basedir/node" "$basedir/../example-other/example.js" "$@"\n' +
- ' ret=$?\n' +
- 'else\n' +
- ' node "$basedir/../example-other/example.js" "$@"\n' +
- ' ret=$?\n' +
- 'fi\n' +
- 'exit $ret\n'
-
-function cleanup () {
- rimraf.sync(work)
-}
-
-var doremove_module = path.join(doremove, 'node_modules', 'example')
-var doremove_example_cmd = path.join(doremove, 'node_modules', '.bin', 'example.cmd')
-var doremove_example_cygwin = path.join(doremove, 'node_modules', '.bin', 'example')
-var dontremove_module = path.join(dontremove, 'node_modules', 'example')
-var dontremove_example_cmd = path.join(dontremove, 'node_modules', '.bin', 'example.cmd')
-var dontremove_example_cygwin = path.join(dontremove, 'node_modules', '.bin', 'example')
-
-function setup () {
- mkdirp.sync(doremove_module)
- mkdirp.sync(path.join(doremove, 'node_modules', '.bin'))
- fs.writeFileSync(path.join(doremove, 'node_modules', 'example', 'package.json'), JSON.stringify(example_json))
- fs.writeFileSync(path.join(doremove, 'node_modules', 'example', 'example.js'), JSON.stringify(example_bin))
- fs.writeFileSync(doremove_example_cmd, do_example_cmd)
- fs.writeFileSync(doremove_example_cygwin, do_example_cygwin)
-
- mkdirp.sync(dontremove_module)
- mkdirp.sync(path.join(dontremove, 'node_modules', '.bin'))
- fs.writeFileSync(path.join(dontremove, 'node_modules', 'example', 'package.json'), JSON.stringify(example_json))
- fs.writeFileSync(path.join(dontremove, 'node_modules', 'example', 'example.js'), JSON.stringify(example_bin))
- fs.writeFileSync(dontremove_example_cmd, dont_example_cmd)
- fs.writeFileSync(dontremove_example_cygwin, dont_example_cygwin)
-}
-
-test('setup', function (t) {
- cleanup()
- setup()
- npm.load({}, function () {
- t.done()
- })
-})
-
-// Like slide.chain, but runs all commands even if they have errors, also
-// throws away results.
-function runAll (cmds, done) {
- runNext()
- function runNext () {
- if (cmds.length === 0) return done()
- var cmdline = cmds.shift()
- var cmd = cmdline.shift()
- cmdline.push(runNext)
- cmd.apply(null, cmdline)
- }
-}
-
-test('remove-cmd-shims', function (t) {
- t.plan(2)
-
- var gentlyRm = require('../../lib/utils/gently-rm.js')
- runAll([ [gentlyRm, doremove_example_cmd, true, doremove_module],
- [gentlyRm, doremove_example_cygwin, true, doremove_module] ],
- function () {
- fs.stat(doremove_example_cmd, function (er) {
- t.is(er && er.code, 'ENOENT', 'cmd-shim was removed')
- })
- fs.stat(doremove_example_cygwin, function (er) {
- t.is(er && er.code, 'ENOENT', 'cmd-shim cygwin script was removed')
- })
- })
-})
-
-test('dont-remove-cmd-shims', function (t) {
- t.plan(2)
- var gentlyRm = require('../../lib/utils/gently-rm.js')
- runAll([ [gentlyRm, dontremove_example_cmd, true, dontremove_module],
- [gentlyRm, dontremove_example_cygwin, true, dontremove_module] ],
- function () {
- fs.stat(dontremove_example_cmd, function (er) {
- t.is(er, null, 'cmd-shim was not removed')
- })
- fs.stat(dontremove_example_cygwin, function (er) {
- t.is(er, null, 'cmd-shim cygwin script was not removed')
- })
- })
-})
-
-test('cleanup', function (t) {
- cleanup()
- t.done()
-})
diff --git a/deps/npm/test/tap/gently-rm-linked-module.js b/deps/npm/test/tap/gently-rm-linked-module.js
deleted file mode 100644
index ab595e10c7..0000000000
--- a/deps/npm/test/tap/gently-rm-linked-module.js
+++ /dev/null
@@ -1,100 +0,0 @@
-var common = require('../common-tap.js')
-
-var resolve = require('path').resolve
-var fs = require('graceful-fs')
-var test = require('tap').test
-var rimraf = require('rimraf')
-var Tacks = require('tacks')
-var File = Tacks.File
-var Dir = Tacks.Dir
-var Symlink = Tacks.Symlink
-var isWindows = require('../../lib/utils/is-windows.js')
-
-var base = common.pkg
-var fixture = new Tacks(Dir({
- 'working-dir': Dir({
- 'node_modules': Dir({}) // so it doesn't try to install into npm's own node_modules
- }),
- 'test-module': Dir({
- 'package.json': File({
- name: '@test/linked',
- version: '1.0.0',
- bin: {
- linked: './index.js'
- }
- }),
- 'index.js': File("module.exports = function () { console.log('whoop whoop') }")
- }),
- 'global-dir': Dir({}),
- 'linked-global-dir': Symlink('global-dir')
-}))
-
-var workingDir = resolve(base, 'working-dir')
-var toInstall = resolve(base, 'test-module')
-var linkedGlobal = resolve(base, 'linked-global-dir')
-
-var env = Object.assign({}, process.env)
-
-// We set the global install location via env var here
-// instead of passing it in via `--prefix` because
-// `--prefix` ALSO changes the current package location.
-// And we don't ue the PREFIX env var because
-// npm_config_prefix takes precedence over it and is
-// passed in when running from the npm test suite.
-env.npm_config_prefix = linkedGlobal
-var EXEC_OPTS = {
- cwd: workingDir,
- env: env,
- stdio: [0, 'pipe', 2]
-}
-
-test('setup', function (t) {
- cleanup()
- setup()
-
- t.end()
-})
-
-test('install and link', function (t) {
- var globalBin = resolve(linkedGlobal, isWindows ? '.' : 'bin', 'linked')
- var globalModule = resolve(linkedGlobal, isWindows ? '.' : 'lib', 'node_modules', '@test', 'linked')
- // link our test module into the global folder
- return common.npm(['--loglevel', 'error', 'link', toInstall], EXEC_OPTS).spread((code, out) => {
- t.comment(out)
- t.is(code, 0, 'link succeeded')
- var localBin = resolve(workingDir, 'node_modules', '.bin', 'linked')
- var localModule = resolve(workingDir, 'node_modules', '@test', 'linked')
- try {
- t.ok(fs.statSync(globalBin), 'global bin exists')
- t.is(fs.lstatSync(globalModule).isSymbolicLink(), true, 'global module is link')
- t.ok(fs.statSync(localBin), 'local bin exists')
- t.is(fs.lstatSync(localModule).isSymbolicLink(), true, 'local module is link')
- } catch (ex) {
- t.ifError(ex, 'linking happened')
- }
- if (code !== 0) throw new Error('aborting')
-
- // and try removing it and make sure that succeeds
- return common.npm(['--global', '--loglevel', 'error', 'rm', '@test/linked'], EXEC_OPTS)
- }).spread((code, out) => {
- t.comment(out)
- t.is(code, 0, 'rm succeeded')
- t.throws(function () { fs.statSync(globalBin) }, 'global bin removed')
- t.throws(function () { fs.statSync(globalModule) }, 'global module removed')
- })
-})
-
-test('cleanup', function (t) {
- cleanup()
-
- t.end()
-})
-
-function cleanup () {
- fixture.remove(base)
- rimraf.sync(base)
-}
-
-function setup () {
- fixture.create(base)
-}
diff --git a/deps/npm/test/tap/gently-rm-overeager.js b/deps/npm/test/tap/gently-rm-overeager.js
deleted file mode 100644
index 91a3768aff..0000000000
--- a/deps/npm/test/tap/gently-rm-overeager.js
+++ /dev/null
@@ -1,60 +0,0 @@
-var path = require('path')
-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 testdir = common.pkg
-var pkg = path.join(testdir, 'gently-rm-overeager')
-var dep = path.join(testdir, '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()
-
- return common.npm(['pack', 'file:test-whoops'], {cwd: testdir, stdio: 'inherit'}).spread((code) => {
- t.is(code, 0, 'pack')
- })
-})
-
-test('cache add', function (t) {
- common.npm(['install', '--no-save', '../test-whoops-1.0.0.tgz'], 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, [], 'no files remain')
- t.end()
- })
- })
-})
-
-test('cleanup', function (t) {
- cleanup()
-
- t.end()
-})
-
-function cleanup () {
- rimraf.sync(testdir)
-}
-
-function setup () {
- mkdirp.sync(pkg)
- // so it doesn't try to install into npm's own node_modules
- mkdirp.sync(path.join(pkg, 'node_modules'))
- mkdirp.sync(dep)
- fs.writeFileSync(path.join(dep, 'package.json'), JSON.stringify(fixture))
-}
diff --git a/deps/npm/test/tap/gently-rm-symlinked-global-dir.js b/deps/npm/test/tap/gently-rm-symlinked-global-dir.js
deleted file mode 100644
index 0a27dae5c5..0000000000
--- a/deps/npm/test/tap/gently-rm-symlinked-global-dir.js
+++ /dev/null
@@ -1,119 +0,0 @@
-var common = require('../common-tap.js')
-
-var resolve = require('path').resolve
-var fs = require('graceful-fs')
-var test = require('tap').test
-var mkdirp = require('mkdirp')
-var rimraf = require('rimraf')
-var isWindows = require('../../lib/utils/is-windows.js')
-
-var pkg = resolve(common.pkg, 'package')
-var dep = resolve(common.pkg, 'test-linked')
-var glb = resolve(common.pkg, 'test-global')
-var lnk = resolve(common.pkg, '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',
- '--json',
- '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',
- '--json',
- '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 resolvePath () {
- return resolve.apply(null, Array.prototype.slice.call(arguments)
- .filter(function (arg) { return arg }))
-}
-
-function verify (t, stdout) {
- var result = JSON.parse(stdout)
- var pkgPath = resolvePath(lnk, !isWindows && 'lib', 'node_modules', '@test', 'linked')
- if (result.added.length) {
- t.is(result.added.length, 1, 'added the module')
- t.is(result.added[0].path, pkgPath, 'in the right location')
- } else {
- t.is(result.updated.length, 1, 'updated the module')
- t.is(result.updated[0].path, pkgPath, 'in the right location')
- }
-}
-
-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, 'junction')
- // 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)
-}
diff --git a/deps/npm/test/tap/gist-short-shortcut-package.js b/deps/npm/test/tap/gist-short-shortcut-package.js
deleted file mode 100644
index 601d53a827..0000000000
--- a/deps/npm/test/tap/gist-short-shortcut-package.js
+++ /dev/null
@@ -1,71 +0,0 @@
-'use strict'
-var fs = require('graceful-fs')
-var path = require('path')
-
-var mkdirp = require('mkdirp')
-var requireInject = require('require-inject')
-var test = require('tap').test
-
-var common = require('../common-tap.js')
-
-var pkg = common.pkg
-
-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 third'],
- ['ssh://git@gist.github.com/deadbeef.git', 'GitHub gist shortcuts try SSH second']
- ]
- var npm = requireInject.installGlobally('../../lib/npm.js', {
- 'child_process': {
- 'execFile': function (cmd, args, options, cb) {
- process.nextTick(function () {
- if (args.indexOf('clone') === -1) return cb(null, '', '')
- var cloneUrl = cloneUrls.shift()
- if (cloneUrl) {
- t.is(args[args.length - 2], cloneUrl[0], cloneUrl[1])
- } else {
- t.fail('too many attempts to clone')
- }
- cb(new Error())
- })
- }
- }
- })
-
- var opts = {
- cache: common.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()
- })
- })
-})
-
-function setup () {
- mkdirp.sync(pkg)
- fs.writeFileSync(
- path.join(pkg, 'package.json'),
- JSON.stringify(json, null, 2)
- )
- process.chdir(pkg)
-}
diff --git a/deps/npm/test/tap/gist-short-shortcut.js b/deps/npm/test/tap/gist-short-shortcut.js
deleted file mode 100644
index 82c9ae1750..0000000000
--- a/deps/npm/test/tap/gist-short-shortcut.js
+++ /dev/null
@@ -1,68 +0,0 @@
-'use strict'
-var fs = require('graceful-fs')
-var path = require('path')
-
-var mkdirp = require('mkdirp')
-var requireInject = require('require-inject')
-var test = require('tap').test
-
-var common = require('../common-tap.js')
-
-var pkg = common.pkg
-
-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'],
- ['ssh://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.indexOf('clone') === -1) return cb(null, '', '')
- var cloneUrl = cloneUrls.shift()
- if (cloneUrl) {
- t.is(args[args.length - 2], cloneUrl[0], cloneUrl[1])
- } else {
- t.fail('too many attempts to clone')
- }
- cb(new Error('execFile mock fails on purpose'))
- })
- }
- }
- })
-
- var opts = {
- cache: common.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()
- })
- })
-})
-
-function setup () {
- mkdirp.sync(pkg)
- fs.writeFileSync(
- path.join(pkg, 'package.json'),
- JSON.stringify(json, null, 2)
- )
- process.chdir(pkg)
-}
diff --git a/deps/npm/test/tap/gist-shortcut-package.js b/deps/npm/test/tap/gist-shortcut-package.js
deleted file mode 100644
index 28e57357cc..0000000000
--- a/deps/npm/test/tap/gist-shortcut-package.js
+++ /dev/null
@@ -1,65 +0,0 @@
-'use strict'
-var fs = require('graceful-fs')
-var path = require('path')
-
-var requireInject = require('require-inject')
-var test = require('tap').test
-
-var common = require('../common-tap.js')
-
-var pkg = common.pkg
-
-var json = {
- name: 'gist-shortcut-package',
- version: '0.0.0',
- dependencies: {
- 'private-gist': 'gist:foo/deadbeef'
- }
-}
-
-test('gist-shortcut-package', function (t) {
- setup()
- 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'],
- ['ssh://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.indexOf('clone') === -1) return cb(null, '', '')
- var cloneUrl = cloneUrls.shift()
- if (cloneUrl) {
- t.is(args[args.length - 2], cloneUrl[0], cloneUrl[1])
- } else {
- t.fail('too many attempts to clone')
- }
- cb(new Error())
- })
- }
- }
- })
-
- var opts = {
- cache: common.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()
- })
- })
-})
-
-function setup () {
- fs.writeFileSync(
- path.join(pkg, 'package.json'),
- JSON.stringify(json, null, 2)
- )
- process.chdir(pkg)
-}
diff --git a/deps/npm/test/tap/gist-shortcut.js b/deps/npm/test/tap/gist-shortcut.js
deleted file mode 100644
index ca86d6bc55..0000000000
--- a/deps/npm/test/tap/gist-shortcut.js
+++ /dev/null
@@ -1,58 +0,0 @@
-'use strict'
-var fs = require('graceful-fs')
-var path = require('path')
-
-var requireInject = require('require-inject')
-var test = require('tap').test
-
-var common = require('../common-tap.js')
-
-var pkg = common.pkg
-
-var json = {
- name: 'gist-shortcut',
- version: '0.0.0'
-}
-
-test('gist-shortcut', function (t) {
- fs.writeFileSync(
- path.join(pkg, 'package.json'),
- JSON.stringify(json, null, 2)
- )
- process.chdir(pkg)
- 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'],
- ['ssh://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.indexOf('clone') === -1) return cb(null, '', '')
- var cloneUrl = cloneUrls.shift()
- if (cloneUrl) {
- t.is(args[args.length - 2], cloneUrl[0], cloneUrl[1])
- } else {
- t.fail('too many attempts to clone')
- }
- cb(new Error())
- })
- }
- }
- })
-
- var opts = {
- cache: common.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()
- })
- })
-})
diff --git a/deps/npm/test/tap/git-dependency-install-link.js b/deps/npm/test/tap/git-dependency-install-link.js
deleted file mode 100644
index d80beab057..0000000000
--- a/deps/npm/test/tap/git-dependency-install-link.js
+++ /dev/null
@@ -1,172 +0,0 @@
-var fs = require('fs')
-var resolve = require('path').resolve
-
-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(common.pkg, 'package')
-var repo = resolve(common.pkg, 'repo')
-var prefix = resolve(common.pkg, 'prefix')
-var cache = common.cache
-
-var daemon
-var daemonPID
-var git
-var mockRegistry
-
-var EXEC_OPTS = {
- registry: common.registry,
- cwd: pkg,
- cache: cache
-}
-process.env.npm_config_prefix = prefix
-
-var pjParent = JSON.stringify({
- name: 'parent',
- version: '1.2.3',
- dependencies: {
- 'child': 'git://localhost:' + common.gitPort + '/child.git'
- }
-}, null, 2) + '\n'
-
-var pjChild = JSON.stringify({
- name: 'child',
- version: '1.0.3'
-}, null, 2) + '\n'
-
-test('setup', function (t) {
- t.test('bootstrap', t => bootstrap(t.end))
- t.test('setup', t => 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()
- })
- }))
- t.end()
-})
-
-test('install from git repo [no --link]', function (t) {
- process.chdir(pkg)
-
- common.npm(['install'], 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'], EXEC_OPTS, function (err, code, stdout, stderr) {
- t.ifError(err, 'npm install --link failed')
- t.equal(code, 0, 'npm install --link returned non-0 code')
-
- t.dissimilar(stderr, /Command failed:/, 'expect git to succeed')
- t.dissimilar(stderr, /version not found/, 'should not go to repository')
- t.equal(stderr, '', 'no actual output on stderr')
-
- 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', t.end)
- process.kill(daemonPID)
-})
-
-function bootstrap (cb) {
- rimraf(repo, () => {
- rimraf(pkg, () => {
- mkdirp.sync(pkg)
- mkdirp.sync(cache)
-
- fs.writeFileSync(resolve(pkg, 'package.json'), pjParent)
- cb()
- })
- })
-}
-
-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=' + common.gitPort
- ],
- {
- 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)
- })
-}
diff --git a/deps/npm/test/tap/git-npmignore.js b/deps/npm/test/tap/git-npmignore.js
deleted file mode 100644
index 2ab7db7304..0000000000
--- a/deps/npm/test/tap/git-npmignore.js
+++ /dev/null
@@ -1,200 +0,0 @@
-/* eslint-disable camelcase */
-var child_process = require('child_process')
-var readdir = require('graceful-fs').readdirSync
-var resolve = require('path').resolve
-
-var rimraf = require('rimraf')
-var test = require('tap').test
-var which = require('which')
-
-var common = require('../common-tap.js')
-var escapeArg = require('../../lib/utils/escape-arg.js')
-var Tacks = require('tacks')
-var Dir = Tacks.Dir
-var File = Tacks.File
-
-var fixture = new Tacks(Dir({
- deps: Dir({
- gitch: Dir({
- '.npmignore': File(
- 't.js\n'
- ),
- '.gitignore': File(
- 'node_modules/\n'
- ),
- 'a.js': File(
- "console.log('hi');"
- ),
- 't.js': File(
- "require('tap').test(function (t) { t.pass('I am a test!'); t.end(); });"
- ),
- 'package.json': File({
- name: 'gitch',
- version: '1.0.0',
- private: true,
- main: 'a.js'
- })
- })
- }),
- 'node_modules': Dir({
- })
-}))
-
-var testdir = common.pkg
-var cachedir = common.cache
-var dep = resolve(testdir, 'deps', 'gitch')
-var packname = 'gitch-1.0.0.tgz'
-var packed = resolve(testdir, packname)
-var modules = resolve(testdir, 'node_modules')
-var installed = resolve(modules, 'gitch')
-var expected = [
- 'a.js',
- 'package.json'
-].sort()
-
-var NPM_OPTS = {
- cwd: testdir,
- env: common.newEnv().extend({
- npm_config_cache: cachedir
- })
-}
-
-function exec (todo, opts, cb) {
- console.log(' # EXEC:', todo)
- child_process.exec(todo, opts, cb)
-}
-
-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) {
- var urlPath = dep
- .replace(/\\/g, '/') // fixup slashes for Windows
- .replace(/^\/+/, '') // remove any leading slashes
- packInstallTest('git+file:///' + urlPath, t)
-})
-
-test('cleanup', function (t) {
- cleanup()
-
- t.end()
-})
-
-function packInstallTest (spec, t) {
- console.log(' # pack', spec)
- common.npm(
- [
- '--loglevel', 'error',
- 'pack', spec
- ],
- NPM_OPTS,
- function (err, code, stdout, stderr) {
- if (err) throw err
- t.is(code, 0, 'npm pack exited cleanly')
- t.is(stderr, '', 'npm pack ran silently')
- t.is(stdout.trim(), packname, 'got expected package name')
-
- common.npm(
- [
- '--loglevel', 'error',
- 'install', packed
- ],
- NPM_OPTS,
- function (err, code, stdout, stderr) {
- if (err) throw err
- t.is(code, 0, 'npm install exited cleanly')
- t.is(stderr, '', 'npm install ran silently')
-
- var actual = readdir(installed).sort()
- t.isDeeply(actual, expected, 'no unexpected files in packed directory')
-
- rimraf(packed, function () {
- t.end()
- })
- }
- )
- }
- )
-}
-
-function cleanup () {
- fixture.remove(testdir)
- rimraf.sync(testdir)
-}
-
-function setup (cb) {
- cleanup()
-
- fixture.create(testdir)
-
- common.npm(
- [
- '--loglevel', 'error',
- 'cache', 'clean', '--force'
- ],
- NPM_OPTS,
- function (er, code, _, stderr) {
- if (er) return cb(er)
- if (stderr) return cb(new Error('npm cache clean error: ' + stderr))
- if (code) return cb(new Error('npm cache nonzero exit: ' + code))
-
- which('git', function found (er, gitPath) {
- if (er) return cb(er)
-
- var git = escapeArg(gitPath)
-
- exec(git + ' init', {cwd: dep}, 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'", {cwd: dep}, 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', {cwd: dep}, email)
- }
-
- function email (er, _, stderr) {
- if (er) return cb(er)
- if (stderr) return cb(new Error('git config error: ' + stderr))
-
- exec(git + ' config core.autocrlf input', {cwd: dep}, autocrlf)
- }
-
- function autocrlf (er, _, stderr) {
- if (er) return cb(er)
- if (stderr) return cb(new Error('git config error: ' + stderr))
-
- exec(git + ' add .', {cwd: dep}, 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', {cwd: dep}, commit)
- }
-
- function commit (er, _, stderr) {
- if (er) return cb(er)
- if (stderr) return cb(new Error('git commit error: ' + stderr))
- cb()
- }
- })
- }
- )
-}
diff --git a/deps/npm/test/tap/git-prepare.js b/deps/npm/test/tap/git-prepare.js
deleted file mode 100644
index 072f4dfc44..0000000000
--- a/deps/npm/test/tap/git-prepare.js
+++ /dev/null
@@ -1,166 +0,0 @@
-'use strict'
-
-const fs = require('fs')
-const path = require('path')
-
-const test = require('tap').test
-const mr = require('npm-registry-mock')
-
-const npm = require('../../lib/npm.js')
-const common = require('../common-tap.js')
-
-const testdir = common.pkg
-const repo = path.join(testdir, 'repo')
-const prefix = path.join(testdir, 'prefix')
-const cache = common.cache
-
-var Tacks = require('tacks')
-var Dir = Tacks.Dir
-var File = Tacks.File
-
-let daemon
-let daemonPID
-let git
-let mockRegistry
-
-process.env.npm_config_prefix = prefix
-
-const fixture = new Tacks(Dir({
- repo: Dir({}),
- prefix: Dir({}),
- deps: Dir({
- parent: Dir({
- 'package.json': File({
- name: 'parent',
- version: '1.2.3',
- dependencies: {
- 'child': 'git://localhost:' + common.gitPort + '/child.git'
- }
- })
- }),
- child: Dir({
- 'package.json': File({
- name: 'child',
- version: '1.0.3',
- main: 'dobuild.js',
- scripts: {
- 'prepublish': 'exit 123',
- 'prepare': 'writer build-artifact'
- },
- devDependencies: {
- writer: 'file:' + path.join(testdir, 'deps', 'writer')
- }
- })
- }),
- writer: Dir({
- 'package.json': File({
- name: 'writer',
- version: '1.0.0',
- bin: 'writer.js'
- }),
- 'writer.js': File(`#!/usr/bin/env node\n
- require('fs').writeFileSync(process.argv[2], 'hello, world!')
- `)
- })
- })
-}))
-
-test('setup', function (t) {
- fixture.create(testdir)
- 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 with prepare script', function (t) {
- const parent = path.join(testdir, 'deps', 'parent')
-
- common.npm([
- 'install',
- '--no-save',
- '--registry', common.registry,
- '--cache', cache,
- '--loglevel', 'error'
- ], {
- cwd: parent
- }, function (err, code, stdout, stderr) {
- if (err) { throw err }
- t.equal(code, 0, 'exited successfully')
- t.equal(stderr, '', 'no actual output on stderr')
-
- const target = path.join(parent, 'node_modules', 'child', 'build-artifact')
- fs.readFile(target, 'utf8', (err, data) => {
- if (err) { throw err }
- t.equal(data, 'hello, world!', 'build artifact written for git dep')
- t.end()
- })
- })
-})
-
-test('clean', function (t) {
- mockRegistry.close()
- daemon.on('close', t.end)
- process.kill(daemonPID)
-})
-
-function setup (cb) {
- npm.load({
- prefix: testdir,
- loglevel: 'silent'
- }, function () {
- git = require('../../lib/utils/git.js')
-
- function startDaemon (cb) {
- // start git server
- const d = git.spawn(
- [
- 'daemon',
- '--verbose',
- '--listen=localhost',
- '--export-all',
- '--base-path=.',
- '--reuseaddr',
- '--port=' + common.gitPort
- ],
- {
- cwd: repo,
- env: process.env
- }
- )
- d.stderr.on('data', childFinder)
-
- function childFinder (c) {
- const cpid = c.toString().match(/^\[(\d+)\]/)
- if (cpid[1]) {
- this.removeListener('data', childFinder)
- cb(null, [d, cpid[1]])
- }
- }
- }
-
- const childPath = path.join(testdir, 'deps', 'child')
- common.makeGitRepo({
- path: childPath,
- commands: [
- git.chainableExec([
- 'clone', '--bare', childPath, 'child.git'
- ], { cwd: repo, env: process.env }),
- startDaemon
- ]
- }, cb)
- })
-}
diff --git a/deps/npm/test/tap/github-shortcut-package.js b/deps/npm/test/tap/github-shortcut-package.js
deleted file mode 100644
index 444520308a..0000000000
--- a/deps/npm/test/tap/github-shortcut-package.js
+++ /dev/null
@@ -1,61 +0,0 @@
-'use strict'
-var fs = require('graceful-fs')
-var path = require('path')
-
-var requireInject = require('require-inject')
-var test = require('tap').test
-
-var common = require('../common-tap.js')
-
-var pkg = common.pkg
-
-var json = {
- name: 'github-shortcut-package',
- version: '0.0.0',
- dependencies: {
- 'private': 'foo/private'
- }
-}
-
-test('github-shortcut-package', function (t) {
- fs.writeFileSync(
- path.join(pkg, 'package.json'),
- JSON.stringify(json, null, 2)
- )
- process.chdir(pkg)
- 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'],
- ['ssh://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.indexOf('clone') === -1) return cb(null, '', '')
- var cloneUrl = cloneUrls.shift()
- if (cloneUrl) {
- t.is(args[args.length - 2], cloneUrl[0], cloneUrl[1])
- } else {
- t.fail('too many attempts to clone')
- }
- cb(new Error())
- })
- }
- }
- })
-
- var opts = {
- cache: common.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()
- })
- })
-})
diff --git a/deps/npm/test/tap/github-shortcut.js b/deps/npm/test/tap/github-shortcut.js
deleted file mode 100644
index 59c7e39ea9..0000000000
--- a/deps/npm/test/tap/github-shortcut.js
+++ /dev/null
@@ -1,61 +0,0 @@
-'use strict'
-
-const BB = require('bluebird')
-
-const fs = require('graceful-fs')
-const path = require('path')
-
-const requireInject = require('require-inject')
-const test = require('tap').test
-
-const common = require('../common-tap.js')
-
-const pkg = common.pkg
-
-const json = {
- name: 'github-shortcut',
- version: '0.0.0'
-}
-
-test('github-shortcut', function (t) {
- fs.writeFileSync(
- path.join(pkg, 'package.json'),
- JSON.stringify(json, null, 2)
- )
- process.chdir(pkg)
- const 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'],
- ['ssh://git@github.com/foo/private.git', 'GitHub shortcuts try SSH third']
- ]
- const npm = requireInject.installGlobally('../../lib/npm.js', {
- 'pacote/lib/util/git': {
- 'revs': (repo, opts) => {
- return BB.resolve().then(() => {
- const cloneUrl = cloneUrls.shift()
- if (cloneUrl) {
- t.is(repo, cloneUrl[0], cloneUrl[1])
- } else {
- t.fail('too many attempts to clone')
- }
- throw new Error('git.revs mock fails on purpose')
- })
- }
- }
- })
-
- const opts = {
- cache: common.cache,
- prefix: pkg,
- registry: common.registry,
- loglevel: 'silent'
- }
- t.plan(2 + cloneUrls.length)
- npm.load(opts, function (err) {
- t.ifError(err, 'npm loaded without error')
- npm.commands.install(['foo/private'], function (err, result) {
- t.match(err.message, /mock fails on purpose/, 'mocked install failed as expected')
- t.end()
- })
- })
-})
diff --git a/deps/npm/test/tap/gitlab-shortcut-package.js b/deps/npm/test/tap/gitlab-shortcut-package.js
deleted file mode 100644
index 9b431ff7b6..0000000000
--- a/deps/npm/test/tap/gitlab-shortcut-package.js
+++ /dev/null
@@ -1,60 +0,0 @@
-'use strict'
-var fs = require('graceful-fs')
-var path = require('path')
-
-var requireInject = require('require-inject')
-var test = require('tap').test
-
-var common = require('../common-tap.js')
-
-var pkg = common.pkg
-
-var json = {
- name: 'gitlab-shortcut-package',
- version: '0.0.0',
- dependencies: {
- 'private': 'gitlab:foo/private'
- }
-}
-
-test('gitlab-shortcut-package', function (t) {
- fs.writeFileSync(
- path.join(pkg, 'package.json'),
- JSON.stringify(json, null, 2)
- )
- process.chdir(pkg)
- var cloneUrls = [
- ['https://gitlab.com/foo/private.git', 'GitLab shortcuts try HTTPS URLs second'],
- ['ssh://git@gitlab.com/foo/private.git', 'GitLab shortcuts try SSH first']
- ]
- var npm = requireInject.installGlobally('../../lib/npm.js', {
- 'child_process': {
- 'execFile': function (cmd, args, options, cb) {
- process.nextTick(function () {
- if (args.indexOf('clone') === -1) return cb(null, '', '')
- var cloneUrl = cloneUrls.shift()
- if (cloneUrl) {
- t.is(args[args.length - 2], cloneUrl[0], cloneUrl[1])
- } else {
- t.fail('too many attempts to clone')
- }
- cb(new Error())
- })
- }
- }
- })
-
- var opts = {
- cache: common.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()
- })
- })
-})
diff --git a/deps/npm/test/tap/gitlab-shortcut.js b/deps/npm/test/tap/gitlab-shortcut.js
deleted file mode 100644
index 344311b45f..0000000000
--- a/deps/npm/test/tap/gitlab-shortcut.js
+++ /dev/null
@@ -1,57 +0,0 @@
-'use strict'
-var fs = require('graceful-fs')
-var path = require('path')
-
-var requireInject = require('require-inject')
-var test = require('tap').test
-
-var common = require('../common-tap.js')
-
-var pkg = common.pkg
-
-var json = {
- name: 'gitlab-shortcut',
- version: '0.0.0'
-}
-
-test('gitlab-shortcut', function (t) {
- fs.writeFileSync(
- path.join(pkg, 'package.json'),
- JSON.stringify(json, null, 2)
- )
- process.chdir(pkg)
- var cloneUrls = [
- ['https://gitlab.com/foo/private.git', 'GitLab shortcuts try HTTPS URLs second'],
- ['ssh://git@gitlab.com/foo/private.git', 'GitLab shortcuts try SSH first']
- ]
- var npm = requireInject.installGlobally('../../lib/npm.js', {
- 'child_process': {
- 'execFile': function (cmd, args, options, cb) {
- process.nextTick(function () {
- if (args.indexOf('clone') === -1) return cb(null, '', '')
- var cloneUrl = cloneUrls.shift()
- if (cloneUrl) {
- t.is(args[args.length - 2], cloneUrl[0], cloneUrl[1])
- } else {
- t.fail('too many attempts to clone')
- }
- cb(new Error('execFile mock fails on purpose'))
- })
- }
- }
- })
-
- var opts = {
- cache: common.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()
- })
- })
-})
diff --git a/deps/npm/test/tap/global-prefix-set-in-userconfig.js b/deps/npm/test/tap/global-prefix-set-in-userconfig.js
deleted file mode 100644
index 422bcb2477..0000000000
--- a/deps/npm/test/tap/global-prefix-set-in-userconfig.js
+++ /dev/null
@@ -1,36 +0,0 @@
-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()
-})
diff --git a/deps/npm/test/tap/graceful-restart.js b/deps/npm/test/tap/graceful-restart.js
deleted file mode 100644
index 787aa98894..0000000000
--- a/deps/npm/test/tap/graceful-restart.js
+++ /dev/null
@@ -1,94 +0,0 @@
-var fs = require('fs')
-var resolve = require('path').resolve
-var test = require('tap').test
-var common = require('../common-tap.js')
-var pkg = common.pkg
-
-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('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.replace(/\r/g, ''), 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.replace(/\r/g, ''), outGraceful, 'expected only *restart scripts to run')
- t.end()
- })
-})
-
-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)
-}
diff --git a/deps/npm/test/tap/help.js b/deps/npm/test/tap/help.js
deleted file mode 100644
index bc66a92298..0000000000
--- a/deps/npm/test/tap/help.js
+++ /dev/null
@@ -1,26 +0,0 @@
-var test = require('tap').test
-var common = require('../common-tap')
-
-test('npm food', function (t) {
- common.npm('docz', {}, function (err, code, stdout, stderr) {
- if (err) throw err
- t.equal(code, 1, 'command ran with error')
-
- t.has(stdout, 'Did you mean this?')
-
- t.notOk(stderr, 'stderr should be empty')
- t.end()
- })
-})
-
-test('npm jet', function (t) {
- common.npm('jet', {}, function (err, code, stdout, stderr) {
- if (err) throw err
- t.equal(code, 1, 'command ran with error')
-
- t.has(stdout, 'Did you mean one of these?')
-
- t.notOk(stderr, 'stderr should be empty')
- t.end()
- })
-})
diff --git a/deps/npm/test/tap/hook.js b/deps/npm/test/tap/hook.js
deleted file mode 100644
index d50b7b1221..0000000000
--- a/deps/npm/test/tap/hook.js
+++ /dev/null
@@ -1,243 +0,0 @@
-'use strict'
-
-const common = require('../common-tap.js')
-const test = require('tap').test
-
-test('hook add', (t) => {
- let body
- return common.withServer(server => {
- server.filteringRequestBody(bod => {
- body = JSON.parse(bod)
- t.deepEqual(body, {
- type: 'owner',
- name: 'zkat',
- endpoint: 'https://example.com',
- secret: 'sekrit'
- }, 'request sent correct body')
- return true
- })
- .post('/-/npm/v1/hooks/hook', true)
- .reply(201, {
- name: 'zkat',
- type: 'owner',
- endpoint: 'https://example.com'
- })
- return common.npm([
- 'hook', 'add', '~zkat', 'https://example.com', 'sekrit',
- '--registry', server.registry
- ], {}).then(([code, stdout, stderr]) => {
- t.comment(stdout)
- t.comment(stderr)
- t.equal(code, 0, 'exited successfully')
- t.match(
- stdout.trim(),
- /^\+ ~zkat.*https:\/\/example\.com$/,
- 'output info about new hook'
- )
- })
- })
-})
-
-test('hook add --json', (t) => {
- return common.withServer(server => {
- server
- .filteringRequestBody(() => true)
- .post('/-/npm/v1/hooks/hook', true)
- .reply(201, {
- name: 'npm',
- type: 'scope',
- endpoint: 'https://example.com'
- })
- return common.npm([
- 'hook', 'add', '~zkat', 'https://example.com', 'sekrit',
- '--json',
- '--registry', server.registry
- ], {}).then(([code, stdout, stderr]) => {
- t.comment(stdout)
- t.comment(stderr)
- t.equal(code, 0, 'exited successfully')
- t.deepEqual(JSON.parse(stdout), {
- name: 'npm',
- type: 'scope',
- endpoint: 'https://example.com'
- }, 'json response data returned')
- })
- })
-})
-
-test('hook rm', t => {
- return common.withServer(server => {
- server
- .delete('/-/npm/v1/hooks/hook/dead%40beef')
- .reply(200, {
- name: 'zkat',
- type: 'owner',
- endpoint: 'https://example.com',
- secret: 'sekrit'
- })
- return common.npm([
- 'hook', 'rm', 'dead@beef',
- '--registry', server.registry
- ], {}).then(([code, stdout, stderr]) => {
- t.comment(stdout)
- t.comment(stderr)
- t.equal(code, 0, 'exited successfully')
- t.match(
- stdout.trim(),
- /^- ~zkat.*https:\/\/example\.com$/,
- 'output info about new hook'
- )
- })
- })
-})
-
-test('hook rm --json', t => {
- return common.withServer(server => {
- server
- .delete('/-/npm/v1/hooks/hook/dead%40beef')
- .reply(200, {
- name: 'zkat',
- type: 'owner',
- endpoint: 'https://example.com',
- secret: 'sekrit'
- })
- return common.npm([
- 'hook', 'rm', 'dead@beef',
- '--json',
- '--registry', server.registry
- ], {}).then(([code, stdout, stderr]) => {
- t.comment(stdout)
- t.comment(stderr)
- t.equal(code, 0, 'exited successfully')
- t.deepEqual(JSON.parse(stdout), {
- name: 'zkat',
- type: 'owner',
- endpoint: 'https://example.com',
- secret: 'sekrit'
- }, 'json response data returned')
- })
- })
-})
-
-test('hook ls', t => {
- const objects = [
- {id: 'foo', type: 'package', name: '@foo/pkg', endpoint: 'foo.com'},
- {id: 'bar', type: 'owner', name: 'bar', endpoint: 'bar.com'},
- {id: 'baz', type: 'scope', name: 'baz', endpoint: 'baz.com'}
- ]
- return common.withServer(server => {
- server
- .get('/-/npm/v1/hooks?package=%40npm%2Fhooks')
- .reply(200, {objects})
- return common.npm([
- 'hook', 'ls', '@npm/hooks',
- '--registry', server.registry
- ], {}).then(([code, stdout, stderr]) => {
- t.comment(stdout)
- t.comment(stderr)
- t.equal(code, 0, 'exited successfully')
- t.match(
- stdout,
- /You have 3 hooks configured/,
- 'message about hook count'
- )
- t.match(
- stdout,
- /foo\s+.*\s+@foo\/pkg\s+.*\s+foo\.com/,
- 'package displayed as expected'
- )
- t.match(
- stdout,
- /bar\s+.*\s+~bar\s+.*\s+bar\.com/,
- 'owner displayed as expected'
- )
- t.match(
- stdout,
- /baz\s+.*\s+@baz\s+.*\s+baz\.com/,
- 'scope displayed as expected'
- )
- })
- })
-})
-
-test('hook ls --json', t => {
- const objects = [
- {id: 'foo'},
- {id: 'bar'},
- {id: 'baz'}
- ]
- return common.withServer(server => {
- server
- .get('/-/npm/v1/hooks?package=%40npm%2Fhooks')
- .reply(200, {objects})
- return common.npm([
- 'hook', 'ls', '@npm/hooks',
- '--json',
- '--registry', server.registry
- ], {}).then(([code, stdout, stderr]) => {
- t.comment(stdout)
- t.comment(stderr)
- t.equal(code, 0, 'exited successfully')
- t.deepEqual(JSON.parse(stdout), objects, 'objects output as json')
- })
- })
-})
-
-test('hook update', t => {
- return common.withServer(server => {
- server.filteringRequestBody(() => true)
- .put('/-/npm/v1/hooks/hook/dead%40beef', true)
- .reply(200, {
- type: 'scope',
- name: 'npm',
- endpoint: 'https://example.com',
- secret: 'sekrit'
- })
- return common.npm([
- 'hook', 'update', 'dead@beef', 'https://example.com', 'sekrit',
- '--registry', server.registry
- ], {}).then(([code, stdout, stderr]) => {
- t.comment(stdout)
- t.comment(stderr)
- t.equal(code, 0, 'exited successfully')
- t.match(
- stdout.trim(),
- /^\+ @npm\s+.*\s+https:\/\/example\.com$/,
- 'output info about updated hook'
- )
- })
- })
-})
-
-test('hook update --json', t => {
- let body
- return common.withServer(server => {
- server.filteringRequestBody(bod => {
- body = JSON.parse(bod)
- t.deepEqual(body, {
- endpoint: 'https://example.com',
- secret: 'sekrit'
- }, 'request sent correct body')
- return true
- })
- .put('/-/npm/v1/hooks/hook/dead%40beef', true)
- .reply(200, {
- endpoint: 'https://example.com',
- secret: 'sekrit'
- })
- return common.npm([
- 'hook', 'update', 'dead@beef', 'https://example.com', 'sekrit',
- '--json',
- '--registry', server.registry
- ], {}).then(([code, stdout, stderr]) => {
- t.comment(stdout)
- t.comment(stderr)
- t.equal(code, 0, 'exited successfully')
- const json = JSON.parse(stdout)
- t.deepEqual(json, {
- endpoint: 'https://example.com',
- secret: 'sekrit'
- }, 'json response data returned')
- })
- })
-})
diff --git a/deps/npm/test/tap/ignore-install-link.js b/deps/npm/test/tap/ignore-install-link.js
deleted file mode 100644
index 038b9448d7..0000000000
--- a/deps/npm/test/tap/ignore-install-link.js
+++ /dev/null
@@ -1,71 +0,0 @@
-var common = require('../common-tap.js')
-common.skipIfWindows('symlinks are weird on windows')
-var test = require('tap').test
-var path = require('path')
-var fs = require('fs')
-var rimraf = require('rimraf')
-var mkdirp = require('mkdirp')
-
-var root = common.pkg
-var pkg = path.resolve(root, 'pkg')
-var dep = path.resolve(root, 'dep')
-var target = path.resolve(pkg, 'node_modules', 'dep')
-var cache = common.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()
-})
diff --git a/deps/npm/test/tap/ignore-scripts.js b/deps/npm/test/tap/ignore-scripts.js
deleted file mode 100644
index f5af4553c2..0000000000
--- a/deps/npm/test/tap/ignore-scripts.js
+++ /dev/null
@@ -1,128 +0,0 @@
-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 = common.pkg
-
-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',
- preshrinkwrap: 'exit 123',
- shrinkwrap: 'exit 123',
- postshrinkwrap: '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',
- 'preshrinkwrap', 'shrinkwrap', 'postshrinkwrap'
-]
-
-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
- )
-}
diff --git a/deps/npm/test/tap/init-create.js b/deps/npm/test/tap/init-create.js
deleted file mode 100644
index 22d9090a97..0000000000
--- a/deps/npm/test/tap/init-create.js
+++ /dev/null
@@ -1,171 +0,0 @@
-/* eslint-disable standard/no-callback-literal */
-var test = require('tap').test
-var requireInject = require('require-inject')
-
-var npm = require('../../lib/npm.js')
-
-test('npm init <name>', function (t) {
- var initJsonMock = function () {
- t.ok(false, 'should not run initJson()')
- }
- initJsonMock.yes = function () {
- t.ok(false, 'should not run initJson.yes()')
- return false
- }
- var libnpxMock = function () {
- return Promise.resolve()
- }
- libnpxMock.parseArgs = function (argv, defaultNpm) {
- t.ok(argv[0].includes('node'), 'node is the first arg')
- t.equals(argv[2], '--always-spawn', 'set npx opts.alwaysSpawn')
- t.equals(argv[3], 'create-name', 'expands name')
- t.ok(defaultNpm.endsWith('npm-cli.js'), 'passes npm bin path')
- }
-
- npm.load({ loglevel: 'silent' }, function () {
- var init = requireInject('../../lib/init', {
- 'init-package-json': initJsonMock,
- 'libnpx': libnpxMock
- })
-
- init(['name'], function () {})
-
- t.end()
- })
-})
-
-test('npm init expands scopes', function (t) {
- var libnpxMock = function () {
- return Promise.resolve()
- }
-
- npm.load({ loglevel: 'silent' }, function () {
- var init = requireInject('../../lib/init', {
- 'libnpx': libnpxMock
- })
-
- libnpxMock.parseArgs = function (argv) {
- t.equals(argv[3], '@scope/create', 'expands @scope')
- }
-
- init(['@scope'], function () {})
-
- libnpxMock.parseArgs = function (argv) {
- t.equals(argv[3], '@scope/create-name', 'expands @scope/name')
- }
-
- init(['@scope/name'], function () {})
-
- t.end()
- })
-})
-
-test('npm init expands version names', function (t) {
- var libnpxMock = function () {
- return Promise.resolve()
- }
-
- npm.load({ loglevel: 'silent' }, function () {
- var init = requireInject('../../lib/init', {
- 'libnpx': libnpxMock
- })
-
- libnpxMock.parseArgs = function (argv) {
- t.equals(argv[3], 'create-name@1.2.3', 'expands name@1.2.3')
- }
-
- init(['name@1.2.3'], function () {})
-
- libnpxMock.parseArgs = function (argv) {
- t.equals(argv[3], 'create-name@^1.2.3', 'expands name@^1.2.3')
- }
-
- init(['name@^1.2.3'], function () {})
-
- t.end()
- })
-})
-
-test('npm init expands git names', function (t) {
- var libnpxMock = function () {
- return Promise.resolve()
- }
-
- npm.load({ loglevel: 'silent' }, function () {
- var init = requireInject('../../lib/init', {
- 'libnpx': libnpxMock
- })
-
- libnpxMock.parseArgs = function (argv) {
- t.equals(argv[3], 'user/create-foo', 'expands git repo')
- }
-
- init(['user/foo'], function () {})
-
- libnpxMock.parseArgs = function (argv) {
- t.equals(argv[3], 'git+https://github.com/user/create-foo', 'expands git url')
- }
-
- init(['git+https://github.com/user/foo'], function () {})
-
- t.end()
- })
-})
-
-test('npm init errors on folder and tarballs', function (t) {
- npm.load({ loglevel: 'silent' }, function () {
- var init = require('../../lib/init')
-
- try {
- init(['../foo/bar/'], function () {})
- } catch (e) {
- t.equals(e.code, 'EUNSUPPORTED')
- }
-
- t.throws(
- () => init(['../foo/bar/'], function () {}),
- /Unrecognized initializer: \.\.\/foo\/bar\//
- )
-
- t.throws(
- () => init(['file:foo.tar.gz'], function () {}),
- /Unrecognized initializer: file:foo\.tar\.gz/
- )
-
- t.throws(
- () => init(['http://x.com/foo.tgz'], function () {}),
- /Unrecognized initializer: http:\/\/x\.com\/foo\.tgz/
- )
-
- t.end()
- })
-})
-
-test('npm init forwards arguments', function (t) {
- var libnpxMock = function () {
- return Promise.resolve()
- }
-
- npm.load({ loglevel: 'silent' }, function () {
- var origArgv = process.argv
- var init = requireInject('../../lib/init', {
- 'libnpx': libnpxMock
- })
-
- libnpxMock.parseArgs = function (argv) {
- process.argv = origArgv
- t.same(argv.slice(4), ['a', 'b', 'c'])
- }
- process.argv = [
- process.argv0,
- 'NPM_CLI_PATH',
- 'init',
- 'name',
- 'a', 'b', 'c'
- ]
-
- init(['name'], function () {})
-
- t.end()
- })
-})
diff --git a/deps/npm/test/tap/init-interrupt.js b/deps/npm/test/tap/init-interrupt.js
deleted file mode 100644
index 38c38053e5..0000000000
--- a/deps/npm/test/tap/init-interrupt.js
+++ /dev/null
@@ -1,38 +0,0 @@
-/* eslint-disable standard/no-callback-literal */
-// if 'npm init' is interrupted with ^C, don't report
-// 'init written successfully'
-var test = require('tap').test
-var npmlog = require('npmlog')
-var requireInject = require('require-inject')
-
-var npm = require('../../lib/npm.js')
-
-require('../common-tap.js')
-
-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()
- })
- })
-})
diff --git a/deps/npm/test/tap/install-actions.js b/deps/npm/test/tap/install-actions.js
deleted file mode 100644
index 071dc2cc37..0000000000
--- a/deps/npm/test/tap/install-actions.js
+++ /dev/null
@@ -1,117 +0,0 @@
-'use strict'
-var npm = require('../../lib/npm.js')
-var log = require('npmlog')
-var test = require('tap').test
-
-var mockLog = {
- finish: function () {},
- silly: function () {}
-}
-
-var actions
-test('setup', function (t) {
- npm.load({ 'unsafe-perm': true }, function () {
- log.disableProgress()
- actions = require('../../lib/install/actions.js').actions
- t.end()
- })
-})
-
-test('->optdep:a->dep:b', function (t) {
- var moduleA = {
- name: 'a',
- path: '/a',
- package: {
- scripts: {
- postinstall: 'false'
- },
- dependencies: {
- b: '*'
- }
- },
- isTop: true
- }
- var moduleB = {
- name: 'b',
- path: '/b',
- package: {},
- requires: [],
- requiredBy: [moduleA]
- }
- moduleA.requires = [moduleB]
-
- var tree = {
- path: '/',
- package: {
- optionalDependencies: {
- a: '*'
- }
- },
- children: [moduleA, moduleB],
- requires: [moduleA],
- isTop: true
- }
- moduleA.requiredBy = [tree]
- moduleA.parent = tree
- moduleB.parent = tree
-
- t.plan(3)
- return actions.postinstall('/', moduleA, mockLog).then(() => {
- throw new Error('was not supposed to succeed')
- }, (err) => {
- t.is(err && err.code, 'ELIFECYCLE', 'Lifecycle failed')
- t.ok(moduleA.failed, 'moduleA (optional dep) is marked failed')
- t.ok(moduleB.failed, 'moduleB (direct dep of moduleA) is marked as failed')
- t.end()
- })
-})
-
-test('->dep:b,->optdep:a->dep:b', function (t) {
- var moduleA = {
- name: 'a',
- path: '/',
- package: {
- scripts: {
- postinstall: 'false'
- },
- dependencies: {
- b: '*'
- }
- },
- isTop: false
- }
- var moduleB = {
- name: 'b',
- path: '/',
- package: {},
- requires: [],
- requiredBy: [moduleA],
- isTop: false
- }
- moduleA.requires = [moduleB]
-
- var tree = {
- name: 'tree',
- path: '/',
- package: {
- dependencies: {
- b: '*'
- },
- optionalDependencies: {
- a: '*'
- }
- },
- children: [moduleA, moduleB],
- requires: [moduleA, moduleB],
- isTop: true
- }
- moduleA.requiredBy = [tree]
- moduleB.requiredBy.push(tree)
- moduleA.parent = tree
- moduleB.parent = tree
-
- return actions.postinstall('/', moduleA, mockLog).then(() => {
- t.ok(moduleA.failed, 'moduleA (optional dep) is marked failed')
- t.ok(!moduleB.failed, 'moduleB (direct dep of moduleA) is marked as failed')
- })
-})
diff --git a/deps/npm/test/tap/install-at-locally.js b/deps/npm/test/tap/install-at-locally.js
deleted file mode 100644
index e4920d22d1..0000000000
--- a/deps/npm/test/tap/install-at-locally.js
+++ /dev/null
@@ -1,52 +0,0 @@
-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.js')
-
-var pkg = common.pkg
-
-var EXEC_OPTS = { cwd: pkg, stdio: [0, 1, 2] }
-
-var json = {
- name: 'install-at-locally-mock',
- version: '0.0.0'
-}
-
-test('\'npm install ./package@1.2.3\' should install local pkg', function (t) {
- var target = './package@1.2.3'
- setup(target)
- common.npm(['install', '--loglevel=silent', target], EXEC_OPTS, function (err, code) {
- if (err) throw err
- var p = path.resolve(pkg, 'node_modules/install-at-locally-mock/package.json')
- 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) {
- if (err) throw err
- var p = path.resolve(pkg, 'node_modules/install-at-locally-mock/package.json')
- t.equal(code, 0, 'npm install exited with code')
- t.ok(JSON.parse(fs.readFileSync(p, 'utf8')))
- t.end()
- })
-})
-
-function setup (target) {
- rimraf.sync(pkg)
- 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'))
-}
diff --git a/deps/npm/test/tap/install-at-sub-path-locally.js b/deps/npm/test/tap/install-at-sub-path-locally.js
deleted file mode 100644
index 931d29bbd2..0000000000
--- a/deps/npm/test/tap/install-at-sub-path-locally.js
+++ /dev/null
@@ -1,49 +0,0 @@
-var fs = require('graceful-fs')
-var path = require('path')
-
-var mkdirp = require('mkdirp')
-var test = require('tap').test
-
-var common = require('../common-tap.js')
-
-var pkg = path.resolve(common.pkg, 'package')
-
-var EXEC_OPTS = { cwd: pkg, stdio: [0, 1, 2] }
-
-var json = {
- name: 'install-at-sub-path-locally-mock',
- version: '0.0.0'
-}
-
-var target = '../package@1.2.3'
-
-test('setup', function (t) {
- 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'))
- t.end()
-})
-
-test('\'npm install ../package@1.2.3\' should install local pkg from sub path', function (t) {
- common.npm(['install', '--loglevel=silent', target], EXEC_OPTS, function (err, code) {
- if (err) throw err
- var p = path.resolve(pkg, 'node_modules/install-at-sub-path-locally-mock/package.json')
- t.equal(code, 0, 'npm install exited with code')
- t.ok(JSON.parse(fs.readFileSync(p, 'utf8')))
- t.end()
- })
-})
-
-test('\'running npm install ../package@1.2.3\' should not break on sub path re-install', function (t) {
- common.npm(['install', '--loglevel=silent', target], EXEC_OPTS, function (err, code) {
- if (err) throw err
- var p = path.resolve(pkg, 'node_modules/install-at-sub-path-locally-mock/package.json')
- t.equal(code, 0, 'npm install exited with code')
- t.ok(JSON.parse(fs.readFileSync(p, 'utf8')))
- t.end()
- })
-})
diff --git a/deps/npm/test/tap/install-bad-dep-format.js b/deps/npm/test/tap/install-bad-dep-format.js
deleted file mode 100644
index 9d9a413835..0000000000
--- a/deps/npm/test/tap/install-bad-dep-format.js
+++ /dev/null
@@ -1,33 +0,0 @@
-var fs = require('graceful-fs')
-var path = require('path')
-
-var mkdirp = require('mkdirp')
-var test = require('tap').test
-
-var common = require('../common-tap.js')
-
-var json = {
- author: 'John Foo',
- name: 'bad-dep-format',
- version: '0.0.0',
- dependencies: {
- 'not-legit': 'bad:not-legit@1.0'
- }
-}
-
-test('invalid url format returns appropriate error', function (t) {
- var pkgPath = path.resolve(common.pkg, json.name)
- mkdirp.sync(pkgPath)
- fs.writeFileSync(
- path.join(pkgPath, 'package.json'),
- JSON.stringify(json, null, 2)
- )
- common.npm(['install'], {cwd: pkgPath}, function (err, code, stdout, stderr) {
- t.ifError(err, 'install ran without error')
- t.equals(code, 1, 'install exited with code 1')
- t.match(stderr,
- /ERR.*Unsupported URL Type/,
- 'Error should report that invalid url-style formats are used')
- t.end()
- })
-})
diff --git a/deps/npm/test/tap/install-bad-man.js b/deps/npm/test/tap/install-bad-man.js
deleted file mode 100644
index 0aa83a21c5..0000000000
--- a/deps/npm/test/tap/install-bad-man.js
+++ /dev/null
@@ -1,61 +0,0 @@
-var fs = require('fs')
-var resolve = require('path').resolve
-
-var mkdirp = require('mkdirp')
-var test = require('tap').test
-
-var common = require('../common-tap.js')
-
-var pkg = resolve(common.pkg, 'package')
-var target = resolve(common.pkg, 'target')
-
-var EXEC_OPTS = {
- cwd: target
-}
-
-var json = {
- name: 'install-bad-man',
- version: '1.2.3',
- man: [ './install-bad-man.1.lol' ]
-}
-
-common.skipIfWindows('man pages do not get installed on Windows')
-
-test('setup', function (t) {
- 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')
- 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()
- }
- )
-})
diff --git a/deps/npm/test/tap/install-before.js b/deps/npm/test/tap/install-before.js
deleted file mode 100644
index 05a254a1ef..0000000000
--- a/deps/npm/test/tap/install-before.js
+++ /dev/null
@@ -1,89 +0,0 @@
-'use strict'
-
-const BB = require('bluebird')
-
-const common = require('../common-tap.js')
-const mockTar = require('../util/mock-tarball.js')
-const mr = common.fakeRegistry.compat
-const path = require('path')
-const rimraf = BB.promisify(require('rimraf'))
-const Tacks = require('tacks')
-const { test } = require('tap')
-
-const { Dir, File } = Tacks
-
-const testDir = common.pkg
-
-let server
-test('setup', t => {
- mr({}, (err, s) => {
- t.ifError(err, 'registry mocked successfully')
- server = s
- t.end()
- })
-})
-
-test('installs an npm package before a certain date', t => {
- const fixture = new Tacks(Dir({
- 'package.json': File({})
- }))
- fixture.create(testDir)
- const packument = {
- name: 'foo',
- 'dist-tags': { latest: '1.2.4' },
- versions: {
- '1.2.3': {
- name: 'foo',
- version: '1.2.3',
- dist: {
- tarball: `${server.registry}/foo/-/foo-1.2.3.tgz`
- }
- },
- '1.2.4': {
- name: 'foo',
- version: '1.2.4',
- dist: {
- tarball: `${server.registry}/foo/-/foo-1.2.4.tgz`
- }
- }
- },
- time: {
- created: '2017-01-01T00:00:01.000Z',
- modified: '2018-01-01T00:00:01.000Z',
- '1.2.3': '2017-01-01T00:00:01.000Z',
- '1.2.4': '2018-01-01T00:00:01.000Z'
- }
- }
- server.get('/foo').reply(200, packument)
- return mockTar({
- 'package.json': JSON.stringify({
- name: 'foo',
- version: '1.2.3'
- })
- }).then(tarball => {
- server.get('/foo/-/foo-1.2.3.tgz').reply(200, tarball)
- server.get('/foo/-/foo-1.2.4.tgz').reply(500)
- return common.npm([
- 'install', 'foo',
- '--before', '2018',
- '--json',
- '--cache', path.join(testDir, 'npmcache'),
- '--registry', server.registry
- ], { cwd: testDir })
- }).then(([code, stdout, stderr]) => {
- t.comment(stdout)
- t.comment(stderr)
- t.like(JSON.parse(stdout), {
- added: [{
- action: 'add',
- name: 'foo',
- version: '1.2.3'
- }]
- }, 'installed the 2017 version of the package')
- })
-})
-
-test('cleanup', t => {
- server.close()
- return rimraf(testDir)
-})
diff --git a/deps/npm/test/tap/install-bin-null.js b/deps/npm/test/tap/install-bin-null.js
deleted file mode 100644
index 2ad75eb599..0000000000
--- a/deps/npm/test/tap/install-bin-null.js
+++ /dev/null
@@ -1,73 +0,0 @@
-var fs = require('graceful-fs')
-var path = require('path')
-
-var mkdirp = require('mkdirp')
-var test = require('tap').test
-
-var common = require('../common-tap.js')
-
-var pkg = common.pkg
-
-var EXEC_OPTS = { cwd: pkg }
-
-var parentPkg = {
- name: 'parent-package',
- version: '0.0.0',
- dependencies: {
- 'child-package-a': 'file:./child-package-a',
- 'child-package-b': 'file:./child-package-b'
- }
-}
-
-var childPkgA = {
- name: 'child-package-a',
- version: '0.0.0',
- bin: 'index.js'
-}
-
-var childPkgB = {
- name: 'child-package-b',
- version: '0.0.0',
- dependencies: {
- 'grandchild-package': 'file:../grandchild-package'
- }
-}
-
-var grandchildPkg = {
- name: 'grandchild-package',
- version: '0.0.0',
- bin: null
-}
-
-var pkgs = [childPkgA, childPkgB, grandchildPkg]
-
-test('setup', t => {
- mkdirp.sync(pkg)
- fs.writeFileSync(
- path.join(pkg, 'package.json'),
- JSON.stringify(parentPkg, null, 2)
- )
- pkgs.forEach(function (json) {
- var pkgPath = path.resolve(pkg, json.name)
- mkdirp.sync(pkgPath)
- fs.writeFileSync(
- path.join(pkgPath, 'package.json'),
- JSON.stringify(json, null, 2)
- )
- })
- fs.writeFileSync(
- path.join(pkg, childPkgA.name, 'index.js'),
- ''
- )
- t.end()
-})
-
-test('the grandchild has bin:null', function (t) {
- common.npm(['install'], EXEC_OPTS, function (err, code, stdout, stderr) {
- t.ifErr(err, 'npm link finished without error')
- t.equal(code, 0, 'exited ok')
- t.ok(stdout, 'output indicating success')
- t.notOk(stderr, 'no output stderr')
- t.end()
- })
-})
diff --git a/deps/npm/test/tap/install-cli-only-development.js b/deps/npm/test/tap/install-cli-only-development.js
deleted file mode 100644
index 6f03931d80..0000000000
--- a/deps/npm/test/tap/install-cli-only-development.js
+++ /dev/null
@@ -1,95 +0,0 @@
-var fs = require('graceful-fs')
-var path = require('path')
-var existsSync = fs.existsSync || path.existsSync
-
-var mkdirp = require('mkdirp')
-var rimraf = require('rimraf')
-const t = require('tap')
-
-var common = require('../common-tap.js')
-
-var pkg = common.pkg
-
-var EXEC_OPTS = { cwd: pkg }
-
-var json = {
- name: 'install-cli-development',
- description: 'fixture',
- version: '0.0.0',
- 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'
-}
-
-t.test('setup', 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, 'dev-dependency'))
- fs.writeFileSync(
- path.join(pkg, 'dev-dependency', '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)
- )
-
- t.end()
-})
-
-t.test('\'npm install --only=development\' should only install devDependencies', function (t) {
- common.npm(['install', '--only=development'], EXEC_OPTS, function (err, code) {
- t.ifError(err, 'install development successful')
- t.equal(code, 0, 'npm install did not raise error code')
- t.ok(
- JSON.parse(fs.readFileSync(
- path.resolve(pkg, 'node_modules/dev-dependency/package.json'), 'utf8')
- ),
- 'devDependency was installed'
- )
- t.notOk(
- existsSync(path.resolve(pkg, 'node_modules/dependency/package.json')),
- 'dependency was NOT installed'
- )
- rimraf(path.join(pkg, 'node_modules'), t.end)
- })
-})
-
-t.test('\'npm install --only=development\' should only install devDependencies regardless of npm.config.get(\'production\')', function (t) {
- common.npm(['install', '--only=development', '--production'], EXEC_OPTS, function (err, code) {
- t.ifError(err, 'install development successful')
- t.equal(code, 0, 'npm install did not raise error code')
- t.ok(
- JSON.parse(fs.readFileSync(
- path.resolve(pkg, 'node_modules/dev-dependency/package.json'), 'utf8')
- ),
- 'devDependency was installed'
- )
- t.notOk(
- existsSync(path.resolve(pkg, 'node_modules/dependency/package.json')),
- 'dependency was NOT installed'
- )
- rimraf(path.join(pkg, 'node_modules'), t.end)
- })
-})
diff --git a/deps/npm/test/tap/install-cli-only-production.js b/deps/npm/test/tap/install-cli-only-production.js
deleted file mode 100644
index 63863ff934..0000000000
--- a/deps/npm/test/tap/install-cli-only-production.js
+++ /dev/null
@@ -1,81 +0,0 @@
-var fs = require('graceful-fs')
-var path = require('path')
-var existsSync = fs.existsSync || path.existsSync
-
-var mkdirp = require('mkdirp')
-var test = require('tap').test
-
-var common = require('../common-tap.js')
-
-var pkg = common.pkg
-
-var EXEC_OPTS = { cwd: pkg }
-
-var json = {
- name: 'install-cli-only-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, 'dev-dependency'))
- fs.writeFileSync(
- path.join(pkg, 'dev-dependency', '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)
- )
-
- t.end()
-})
-
-test('\'npm install --only=production\' should only install dependencies', function (t) {
- common.npm(['install', '--only=production'], EXEC_OPTS, function (err, code, stdout, stderr) {
- if (err) throw err
- t.comment('1> ' + stdout)
- t.comment('2> ' + stderr)
- 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()
- })
-})
diff --git a/deps/npm/test/tap/install-cli-only-shrinkwrap.js b/deps/npm/test/tap/install-cli-only-shrinkwrap.js
deleted file mode 100644
index 004593d782..0000000000
--- a/deps/npm/test/tap/install-cli-only-shrinkwrap.js
+++ /dev/null
@@ -1,119 +0,0 @@
-var fs = require('graceful-fs')
-var path = require('path')
-var existsSync = fs.existsSync || path.existsSync
-
-var mkdirp = require('mkdirp')
-var rimraf = require('rimraf')
-var test = require('tap').test
-
-var common = require('../common-tap.js')
-
-var pkg = common.pkg
-
-var EXEC_OPTS = { cwd: pkg }
-
-var json = {
- name: 'install-cli-only-shrinkwrap',
- description: 'fixture',
- version: '0.0.0',
- dependencies: {
- dependency: 'file:./dependency'
- },
- devDependencies: {
- 'dev-dependency': 'file:./dev-dependency'
- }
-}
-
-var shrinkwrap = {
- name: 'install-cli-only-shrinkwrap',
- description: 'fixture',
- version: '0.0.0',
- lockfileVersion: 1,
- requires: true,
- dependencies: {
- dependency: {
- version: 'file:./dependency'
- },
- 'dev-dependency': {
- version: 'file:./dev-dependency',
- dev: true
- }
- }
-}
-
-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, 'dev-dependency'))
- fs.writeFileSync(
- path.join(pkg, 'dev-dependency', '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)
- )
- fs.writeFileSync(
- path.join(pkg, 'npm-shrinkwrap.json'),
- JSON.stringify(shrinkwrap, null, 2)
- )
- t.end()
-})
-
-test('\'npm install --only=development\' should only install devDependencies', function (t) {
- common.npm(['install', '--only=development'], EXEC_OPTS, function (err, code, stderr, stdout) {
- if (err) throw err
- t.comment(stdout.trim())
- t.comment(stderr.trim())
- t.is(code, 0, 'npm install did not raise error code')
- t.ok(
- existsSync(
- path.resolve(pkg, 'node_modules/dev-dependency/package.json')
- ),
- 'devDependency was installed'
- )
- t.notOk(
- existsSync(path.resolve(pkg, 'node_modules/dependency/package.json')),
- 'dependency was NOT installed'
- )
- rimraf(path.join(pkg, 'node_modules'), t.end)
- })
-})
-
-test('\'npm install --only=production\' should only install dependencies', function (t) {
- common.npm(['install', '--only=production'], EXEC_OPTS, function (err, code, stdout, stderr) {
- if (err) throw err
- t.comment(stdout.trim())
- t.comment(stderr.trim())
- t.is(code, 0, 'npm install did not raise error code')
- t.ok(
- existsSync(
- path.resolve(pkg, 'node_modules/dependency/package.json')
- ),
- 'dependency was installed'
- )
- t.notOk(
- existsSync(path.resolve(pkg, 'node_modules/dev-dependency/package.json')),
- 'devDependency was NOT installed'
- )
- rimraf(path.join(pkg, 'node_modules'), t.end)
- })
-})
diff --git a/deps/npm/test/tap/install-cli-production-nosave.js b/deps/npm/test/tap/install-cli-production-nosave.js
deleted file mode 100644
index 23f5494996..0000000000
--- a/deps/npm/test/tap/install-cli-production-nosave.js
+++ /dev/null
@@ -1,48 +0,0 @@
-var fs = require('fs')
-var path = require('path')
-
-var mkdirp = require('mkdirp')
-var mr = require('npm-registry-mock')
-var t = require('tap')
-
-var common = require('../common-tap.js')
-
-var pkg = common.pkg
-
-var EXEC_OPTS = { cwd: pkg }
-
-var PACKAGE_JSON1 = {
- name: 'install-cli-production-nosave',
- version: '0.0.1',
- dependencies: {
- }
-}
-
-t.test('setup', function (t) {
- mkdirp.sync(path.resolve(pkg, 'node_modules'))
- fs.writeFileSync(
- path.join(pkg, 'package.json'),
- JSON.stringify(PACKAGE_JSON1, null, 2)
- )
- mr({ port: common.port }, function (er, s) {
- t.ifError(er, 'started mock registry')
- t.parent.teardown(() => s.close())
- t.end()
- })
-})
-
-t.test('install --production <module> without --save exits successfully', function (t) {
- common.npm(
- [
- '--registry', common.registry,
- '--loglevel', 'silent',
- 'install', '--production', 'underscore'
- ],
- EXEC_OPTS,
- function (err, code) {
- t.ifError(err, 'npm install ran without issue')
- t.notOk(code, 'npm install exited with code 0')
- t.end()
- }
- )
-})
diff --git a/deps/npm/test/tap/install-cli-production.js b/deps/npm/test/tap/install-cli-production.js
deleted file mode 100644
index d083b42957..0000000000
--- a/deps/npm/test/tap/install-cli-production.js
+++ /dev/null
@@ -1,79 +0,0 @@
-var fs = require('graceful-fs')
-var path = require('path')
-var existsSync = fs.existsSync || path.existsSync
-
-var mkdirp = require('mkdirp')
-var test = require('tap').test
-
-var common = require('../common-tap.js')
-
-var pkg = common.pkg
-
-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, 'dev-dependency'))
- fs.writeFileSync(
- path.join(pkg, 'dev-dependency', '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)
- )
-
- 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()
- })
-})
diff --git a/deps/npm/test/tap/install-cli-unicode.js b/deps/npm/test/tap/install-cli-unicode.js
deleted file mode 100644
index 930066db5f..0000000000
--- a/deps/npm/test/tap/install-cli-unicode.js
+++ /dev/null
@@ -1,57 +0,0 @@
-var fs = require('graceful-fs')
-var path = require('path')
-
-var mr = require('npm-registry-mock')
-var test = require('tap').test
-
-var common = require('../common-tap.js')
-
-var pkg = common.pkg
-
-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) {
- fs.writeFileSync(
- path.join(pkg, 'package.json'),
- JSON.stringify(json, null, 2)
- )
-
- mr({ port: common.port }, function (er, s) {
- t.parent.teardown(() => s.close())
- 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()
- }
- )
-})
diff --git a/deps/npm/test/tap/install-contributors-count.js b/deps/npm/test/tap/install-contributors-count.js
deleted file mode 100644
index ead9250813..0000000000
--- a/deps/npm/test/tap/install-contributors-count.js
+++ /dev/null
@@ -1,69 +0,0 @@
-'use strict'
-var test = require('tap').test
-var Tacks = require('tacks')
-var Dir = Tacks.Dir
-var File = Tacks.File
-var common = require('../common-tap.js')
-
-var testdir = common.pkg
-var fixture = new Tacks(Dir({
- node_modules: Dir({
- a: Dir({
- 'package.json': File({
- name: 'a',
- version: '1.0.0',
- dependencies: {
- b: '1.0.0'
- }
- }),
- node_modules: Dir({
- b: Dir({
- 'package.json': File({
- name: 'b',
- version: '1.0.0'
- })
- })
- })
- })
- }),
- 'b-src': Dir({
- 'package.json': File({
- name: 'b',
- author: 'Author Contributor',
- contributors: [
- {name: 'Author Contributor'},
- 'Another Contributor'
- ],
- version: '1.0.0'
- })
- })
-}))
-
-function setup () {
- cleanup()
- fixture.create(testdir)
-}
-
-function cleanup () {
- fixture.remove(testdir)
-}
-
-test('setup', function (t) {
- setup()
- t.end()
-})
-
-test('install', function (t) {
- common.npm(['install', '--no-save', './b-src'], {cwd: testdir}, function (err, code, stdout, stderr) {
- if (err) throw err
- t.is(code, 0, 'installed successfully')
- t.is(stderr, '', 'no warnings')
- t.includes(stdout, 'added 1 package from 2 contributors', 'lists number of unique contributors')
- t.end()
- })
-})
-
-test('cleanup', function (t) {
- cleanup()
- t.end()
-})
diff --git a/deps/npm/test/tap/install-dep-classification.js b/deps/npm/test/tap/install-dep-classification.js
deleted file mode 100644
index 1c9995cedc..0000000000
--- a/deps/npm/test/tap/install-dep-classification.js
+++ /dev/null
@@ -1,188 +0,0 @@
-'use strict'
-const path = require('path')
-const test = require('tap').test
-const Tacks = require('tacks')
-const File = Tacks.File
-const Dir = Tacks.Dir
-const common = require('../common-tap.js')
-const fs = require('fs')
-
-const basedir = common.pkg
-const testdir = path.join(basedir, 'testdir')
-const cachedir = common.cache
-const globaldir = path.join(basedir, 'global')
-const tmpdir = path.join(basedir, 'tmp')
-const optionaldir = path.join(testdir, 'optional')
-const devdir = path.join(testdir, 'dev')
-
-const env = common.newEnv().extend({
- npm_config_cache: cachedir,
- npm_config_tmp: tmpdir,
- npm_config_prefix: globaldir,
- npm_config_registry: common.registry,
- npm_config_loglevel: 'error'
-})
-
-/**
- * NOTE: Tarball Fixtures
- * They contain package.json files with dependencies like the following:
- * a-1.0.0.tgz: package/package.json
- * {
- * "name":"a",
- * "version":"1.0.0",
- * "dependencies":{
- * "b":"./b-1.0.0.tgz"
- * }
- * }
- * example-1.0.0.tgz: package/package.json
- * {
- * "name":"example",
- * "version":"1.0.0",
- * "dependencies":{
- * "a":"./a-1.0.0.tgz",
- * "b":"./b-1.0.0.tgz"
- * }
- * }
- */
-const fixture = new Tacks(Dir({
- cache: Dir(),
- global: Dir(),
- tmp: Dir(),
- testdir: Dir({
- 'a-1.0.0.tgz': File(Buffer.from(
- '1f8b0800000000000003edcfc10a83300c06e09df71492f35653567bf06d' +
- 'a2067163b558b7c3c4775f54f0e4654c18837e973f4da0249eca1bd59cfa' +
- '25d535b4eeb03344b4c6245bfd8946995d328b5a5b3bd55264464beebdc8' +
- '9647e8a99355befd67b92559f34f0ce0e8ce9003c1099edc85a675f2d20a' +
- '154aa762cfae6257361c201fa090994a8bf33c577dfd82713cfefa86288a' +
- 'a2e8736f68a0ff4400080000',
- 'hex'
- )),
- 'b-1.0.0.tgz': File(Buffer.from(
- '1f8b08000000000000032b484cce4e4c4fd52f80d07a59c5f9790c540606' +
- '06066626260ad8c4c1c0d85c81c1d8d4ccc0d0d0cccc00a80ec830353103' +
- 'd2d4760836505a5c925804740aa5e640bca200a78708a856ca4bcc4d55b2' +
- '524a52d2512a4b2d2acecccf03f20cf50cf40c946ab906da79a360148c82' +
- '51300a680400106986b400080000',
- 'hex'
- )),
- dev: Dir({
- 'package.json': File({
- name: 'dev',
- version: '1.0.0',
- devDependencies: {
- example: '../example-1.0.0.tgz'
- }
- })
- }),
- 'example-1.0.0.tgz': File(Buffer.from(
- '1f8b0800000000000003ed8fc10a83300c863def2924e7ada6587bf06daa' +
- '06719bb55837c6c4775fa6307670a70963d0ef92f02584fcce94275353e2' +
- '962a8ebeb3d1c620a2562a5ef34f64aae328cd344aa935f21e379962875b' +
- '3fb2c6c50fa6e757bebdb364895ff54f18c19a962007ba99d69d09f670a5' +
- 'de379d6527050a645391235b912d1bf2908f607826127398e762a8efbc53' +
- 'ccae7873d3b4fb75ba402010087ce2014747c9d500080000',
- 'hex'
- )),
- optional: Dir({
- 'package.json': File({
- name: 'optional',
- version: '1.0.0',
- optionalDependencies: {
- example: '../example-1.0.0.tgz'
- }
- })
- })
- })
-}))
-
-function setup () {
- cleanup()
- fixture.create(basedir)
-}
-
-function cleanup () {
- fixture.remove(basedir)
-}
-
-test('setup', function (t) {
- setup()
- return common.fakeRegistry.listen()
-})
-
-test('optional dependency identification', function (t) {
- return common.npm(['install', '--no-optional'], {cwd: optionaldir, env}).then(([code, stdout, stderr]) => {
- t.is(code, 0, 'no error code')
- t.is(stderr, '', 'no error output')
- t.notOk(fs.existsSync(path.join(optionaldir, 'node_modules')), 'did not install anything')
- t.similar(JSON.parse(fs.readFileSync(path.join(optionaldir, 'package-lock.json'), 'utf8')), {
- dependencies: {
- a: {
- version: 'file:../a-1.0.0.tgz',
- optional: true
- },
- b: {
- version: 'file:../b-1.0.0.tgz',
- optional: true
- },
- example: {
- version: 'file:../example-1.0.0.tgz',
- optional: true
- }
- }
- }, 'locks dependencies as optional')
- })
-})
-
-test('development dependency identification', function (t) {
- return common.npm(['install', '--only=prod'], {cwd: devdir, env}).then(([code, stdout, stderr]) => {
- t.is(code, 0, 'no error code')
- t.is(stderr, '', 'no error output')
- t.notOk(fs.existsSync(path.join(devdir, 'node_modules')), 'did not install anything')
- t.similar(JSON.parse(fs.readFileSync(path.join(devdir, 'package-lock.json'), 'utf8')), {
- dependencies: {
- a: {
- version: 'file:../a-1.0.0.tgz',
- dev: true
- },
- b: {
- version: 'file:../b-1.0.0.tgz',
- dev: true
- },
- example: {
- version: 'file:../example-1.0.0.tgz',
- dev: true
- }
- }
- }, 'locks dependencies as dev')
- })
-})
-
-test('default dependency identification', function (t) {
- return common.npm(['install'], {cwd: optionaldir, env}).then(([code, stdout, stderr]) => {
- t.is(code, 0, 'no error code')
- t.is(stderr, '', 'no error output')
- t.similar(JSON.parse(fs.readFileSync(path.join(optionaldir, 'package-lock.json'), 'utf8')), {
- dependencies: {
- a: {
- version: 'file:../a-1.0.0.tgz',
- optional: true
- },
- b: {
- version: 'file:../b-1.0.0.tgz',
- optional: true
- },
- example: {
- version: 'file:../example-1.0.0.tgz',
- optional: true
- }
- }
- }, 'locks dependencies as optional')
- })
-})
-
-test('cleanup', function (t) {
- common.fakeRegistry.close()
- cleanup()
- t.done()
-})
diff --git a/deps/npm/test/tap/install-duplicate-deps-warning.js b/deps/npm/test/tap/install-duplicate-deps-warning.js
deleted file mode 100644
index 869476ccd1..0000000000
--- a/deps/npm/test/tap/install-duplicate-deps-warning.js
+++ /dev/null
@@ -1,51 +0,0 @@
-var fs = require('graceful-fs')
-var path = require('path')
-
-var mr = require('npm-registry-mock')
-var test = require('tap').test
-
-var common = require('../common-tap.js')
-var npm = require('../../')
-
-var pkg = common.pkg
-
-var json = {
- dependencies: {
- underscore: '1.5.1'
- },
- devDependencies: {
- underscore: '1.3.1'
- }
-}
-
-test('npm install with duplicate dependencies, different versions', function (t) {
- t.plan(1)
- t.comment('test for https://github.com/npm/npm/issues/6725')
-
- fs.writeFileSync(
- path.join(pkg, 'package.json'),
- JSON.stringify(json, null, 2)
- )
- process.chdir(pkg)
-
- mr({ port: common.port }, function (er, s) {
- var opts = {
- cache: common.cache,
- registry: common.registry
- }
-
- npm.load(opts, function (err) {
- if (err) return t.fail(err)
-
- npm.install('.', function (err, additions, result) {
- if (err) return t.fail(err)
-
- var invalid = result.warnings.filter(function (warning) { return warning.code === 'EDUPLICATEDEP' })
- t.is(invalid.length, 1, 'got a warning (EDUPLICATEDEP) for duplicate dev/production dependencies')
-
- s.close()
- t.end()
- })
- })
- })
-})
diff --git a/deps/npm/test/tap/install-from-local-multipath.js b/deps/npm/test/tap/install-from-local-multipath.js
deleted file mode 100644
index e35794dca9..0000000000
--- a/deps/npm/test/tap/install-from-local-multipath.js
+++ /dev/null
@@ -1,173 +0,0 @@
-var fs = require('graceful-fs')
-var path = require('path')
-
-var mkdirp = require('mkdirp')
-var test = require('tap').test
-
-var common = require('../common-tap')
-
-var root = common.pkg
-// Allow running this test on older commits (useful for bisecting)
-if (!root) {
- var main = require.main.filename
- root = path.resolve(path.dirname(main), path.basename(main, '.js'))
-}
-var pkg = path.join(root, 'parent')
-
-var EXEC_OPTS = { cwd: pkg }
-
-var parent = {
- name: 'parent',
- version: '0.0.0',
- dependencies: {
- 'child-1-1': 'file:../children/child-1-1',
- 'child-1-2': 'file:../children/child-1-2',
- 'child-2': 'file:../children/child-2'
- }
-}
-
-var parentLock = {
- 'name': 'parent',
- 'version': '1.0.0',
- 'lockfileVersion': 1,
- 'requires': true,
- 'dependencies': {
- 'child-1-1': {
- 'version': 'file:../children/child-1-1',
- 'requires': {
- 'child-2': 'file:../children/child-2'
- }
- },
- 'child-1-2': {
- 'version': 'file:../children/child-1-2',
- 'requires': {
- 'child-1-1': 'file:../children/child-1-1',
- 'child-2': 'file:../children/child-2'
- }
- },
- 'child-2': {
- 'version': 'file:../children/child-2'
- }
- }
-}
-
-var child11 = {
- name: 'parent',
- version: '0.0.0',
- 'dependencies': {
- 'child-2': 'file:../child-2'
- }
-}
-
-var child11Lock = {
- 'name': 'child-1-1',
- 'version': '1.0.0',
- 'lockfileVersion': 1,
- 'requires': true,
- 'dependencies': {
- 'child-2': {
- 'version': 'file:../child-2'
- }
- }
-}
-
-var child12 = {
- 'name': 'child-1-2',
- 'version': '1.0.0',
- 'dependencies': {
- 'child-1-1': 'file:../child-1-1',
- 'child-2': 'file:../child-2'
- }
-}
-
-var child12Lock = {
- 'name': 'child-1-2',
- 'version': '1.0.0',
- 'lockfileVersion': 1,
- 'requires': true,
- 'dependencies': {
- 'child-1-1': {
- 'version': 'file:../child-1-1',
- 'requires': {
- 'child-2': 'file:../child-2'
- }
- },
- 'child-2': {
- 'version': 'file:../child-2'
- }
- }
-}
-
-var child2 = {
- 'name': 'child-2',
- 'version': '1.0.0',
- 'dependencies': {}
-}
-
-var child2Lock = {
- 'name': 'child-2',
- 'version': '1.0.0',
- 'lockfileVersion': 1,
- 'requires': true,
- 'dependencies': {}
-}
-
-test('setup', function (t) {
- mkdirp.sync(pkg)
- fs.writeFileSync(
- path.join(pkg, 'package.json'),
- JSON.stringify(parent, null, 2)
- )
-
- fs.writeFileSync(
- path.join(pkg, 'package-lock.json'),
- JSON.stringify(parentLock, null, 2)
- )
-
- mkdirp.sync(path.join(root, 'children', 'child-1-1'))
- fs.writeFileSync(
- path.join(root, 'children', 'child-1-1', 'package.json'),
- JSON.stringify(child11, null, 2)
- )
- fs.writeFileSync(
- path.join(root, 'children', 'child-1-1', 'package-lock.json'),
- JSON.stringify(child11Lock, null, 2)
- )
-
- mkdirp.sync(path.join(root, 'children', 'child-1-2'))
- fs.writeFileSync(
- path.join(root, 'children', 'child-1-2', 'package.json'),
- JSON.stringify(child12, null, 2)
- )
- fs.writeFileSync(
- path.join(root, 'children', 'child-1-2', 'package-lock.json'),
- JSON.stringify(child12Lock, null, 2)
- )
-
- mkdirp.sync(path.join(root, 'children', 'child-2'))
- fs.writeFileSync(
- path.join(root, 'children', 'child-2', 'package.json'),
- JSON.stringify(child2, null, 2)
- )
- fs.writeFileSync(
- path.join(root, 'children', 'child-2', 'package-lock.json'),
- JSON.stringify(child2Lock, 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')
- t.end()
- }
- )
-})
diff --git a/deps/npm/test/tap/install-from-local.js b/deps/npm/test/tap/install-from-local.js
deleted file mode 100644
index 1ab94243ff..0000000000
--- a/deps/npm/test/tap/install-from-local.js
+++ /dev/null
@@ -1,89 +0,0 @@
-var fs = require('graceful-fs')
-var path = require('path')
-
-var mkdirp = require('mkdirp')
-var test = require('tap').test
-
-var common = require('../common-tap')
-
-var root = common.pkg
-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) {
- 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()
- }
- )
-})
diff --git a/deps/npm/test/tap/install-into-likenamed-folder.js b/deps/npm/test/tap/install-into-likenamed-folder.js
deleted file mode 100644
index c7bc86f3ba..0000000000
--- a/deps/npm/test/tap/install-into-likenamed-folder.js
+++ /dev/null
@@ -1,44 +0,0 @@
-'use strict'
-var path = require('path')
-var fs = require('graceful-fs')
-var mkdirp = require('mkdirp')
-var rimraf = require('rimraf')
-var test = require('tap').test
-var common = require('../common-tap.js')
-
-var base = common.pkg
-var moduleDir = path.join(base, 'example-src')
-var destDir = path.join(base, 'example')
-var moduleJson = {
- name: 'example',
- version: '1.0.0'
-}
-
-function setup () {
- cleanup()
- mkdirp.sync(moduleDir)
- mkdirp.sync(path.join(destDir, 'node_modules'))
- fs.writeFileSync(path.join(moduleDir, 'package.json'), JSON.stringify(moduleJson))
-}
-
-function cleanup () {
- rimraf.sync(base)
-}
-
-test('setup', function (t) {
- setup()
- t.end()
-})
-
-test('like-named', function (t) {
- common.npm(['install', '../example-src'], {cwd: destDir}, function (er, code, stdout, stderr) {
- t.is(code, 0, 'no error code')
- t.is(stderr, '', 'no error output')
- t.end()
- })
-})
-
-test('cleanup', function (t) {
- cleanup()
- t.end()
-})
diff --git a/deps/npm/test/tap/install-lifecycle.js b/deps/npm/test/tap/install-lifecycle.js
deleted file mode 100644
index c5b0fd35a0..0000000000
--- a/deps/npm/test/tap/install-lifecycle.js
+++ /dev/null
@@ -1,35 +0,0 @@
-var fs = require('graceful-fs')
-var path = require('path')
-var test = require('tap').test
-var common = require('../common-tap.js')
-var pkg = common.pkg
-
-test('npm install execution order', function (t) {
- const packageJson = {
- name: 'life-test',
- version: '0.0.1',
- description: 'Test for npm install execution order',
- scripts: {
- install: 'true',
- preinstall: 'true',
- preshrinkwrap: 'true',
- postinstall: 'true',
- postshrinkwrap: 'true',
- shrinkwrap: 'true'
- }
- }
- fs.writeFileSync(path.resolve(pkg, 'package.json'), JSON.stringify(packageJson), 'utf8')
- common.npm(['install', '--loglevel=error'], { cwd: pkg }, function (err, code, stdout, stderr) {
- if (err) throw err
-
- t.comment(stdout)
- t.comment(stderr)
-
- const steps = ['preinstall', 'install', 'postinstall', 'preshrinkwrap', 'shrinkwrap', 'postshrinkwrap']
- const expectedLines = steps.map(function (step) {
- return '> ' + packageJson.name + '@' + packageJson.version + ' ' + step
- })
- t.match(stdout, new RegExp(expectedLines.map(common.escapeForRe).join('(.|\n)*')))
- t.end()
- })
-})
diff --git a/deps/npm/test/tap/install-link-metadeps-locally.js b/deps/npm/test/tap/install-link-metadeps-locally.js
deleted file mode 100644
index 136fd46d10..0000000000
--- a/deps/npm/test/tap/install-link-metadeps-locally.js
+++ /dev/null
@@ -1,52 +0,0 @@
-// XXX Remove in npm v7, when this is no longer how we do things
-const t = require('tap')
-const common = require('../common-tap.js')
-const pkg = common.pkg
-const mkdirp = require('mkdirp')
-const { writeFileSync, statSync } = require('fs')
-const { resolve } = require('path')
-const mr = require('npm-registry-mock')
-const rimraf = require('rimraf')
-
-t.test('setup', t => {
- mkdirp.sync(resolve(pkg, 'node_modules'))
- mkdirp.sync(resolve(pkg, 'foo'))
- writeFileSync(resolve(pkg, 'foo', 'package.json'), JSON.stringify({
- name: 'foo',
- version: '1.2.3',
- dependencies: {
- underscore: '*'
- }
- }))
-
- writeFileSync(resolve(pkg, 'package.json'), JSON.stringify({
- name: 'root',
- version: '1.2.3',
- dependencies: {
- foo: 'file:foo'
- }
- }))
-
- mr({ port: common.port }, (er, s) => {
- if (er) {
- throw er
- }
- t.parent.teardown(() => s.close())
- t.end()
- })
-})
-
-t.test('initial install to create package-lock',
- t => common.npm(['install', '--registry', common.registry], { cwd: pkg })
- .then(([code]) => t.equal(code, 0, 'command worked')))
-
-t.test('remove node_modules', t =>
- rimraf(resolve(pkg, 'node_modules'), t.end))
-
-t.test('install again from package-lock', t =>
- common.npm(['install', '--registry', common.registry], { cwd: pkg })
- .then(([code]) => {
- t.equal(code, 0, 'command worked')
- const underscore = resolve(pkg, 'node_modules', 'underscore')
- t.equal(statSync(underscore).isDirectory(), true, 'underscore installed')
- }))
diff --git a/deps/npm/test/tap/install-link-metadeps-subfolders.js b/deps/npm/test/tap/install-link-metadeps-subfolders.js
deleted file mode 100644
index 7544c8a4eb..0000000000
--- a/deps/npm/test/tap/install-link-metadeps-subfolders.js
+++ /dev/null
@@ -1,68 +0,0 @@
-const t = require('tap')
-const common = require('../common-tap.js')
-const mkdirp = require('mkdirp')
-const { writeFileSync, readFileSync } = require('fs')
-const { resolve } = require('path')
-const pkg = common.pkg
-const app = resolve(pkg, 'app')
-const lib = resolve(pkg, 'lib')
-const moda = resolve(lib, 'module-a')
-const modb = resolve(lib, 'module-b')
-
-const rimraf = require('rimraf')
-
-t.test('setup', t => {
- mkdirp.sync(app)
- mkdirp.sync(moda)
- mkdirp.sync(modb)
-
- writeFileSync(resolve(app, 'package.json'), JSON.stringify({
- name: 'app',
- version: '1.2.3',
- dependencies: {
- moda: 'file:../lib/module-a'
- }
- }))
-
- writeFileSync(resolve(moda, 'package.json'), JSON.stringify({
- name: 'moda',
- version: '1.2.3',
- dependencies: {
- modb: 'file:../module-b'
- }
- }))
-
- writeFileSync(resolve(modb, 'package.json'), JSON.stringify({
- name: 'modb',
- version: '1.2.3'
- }))
-
- t.end()
-})
-
-t.test('initial install to create package-lock',
- t => common.npm(['install'], { cwd: app })
- .then(([code]) => t.equal(code, 0, 'command worked')))
-
-t.test('remove node_modules', t =>
- rimraf(resolve(pkg, 'node_modules'), t.end))
-
-t.test('install again from package-lock', t =>
- common.npm(['install'], { cwd: app })
- .then(([code]) => {
- t.equal(code, 0, 'command worked')
- // verify that module-b is linked under module-a
- const depPkg = resolve(
- app,
- 'node_modules',
- 'moda',
- 'node_modules',
- 'modb',
- 'package.json'
- )
- const data = JSON.parse(readFileSync(depPkg, 'utf8'))
- t.strictSame(data, {
- name: 'modb',
- version: '1.2.3'
- })
- }))
diff --git a/deps/npm/test/tap/install-link-scripts.js b/deps/npm/test/tap/install-link-scripts.js
deleted file mode 100644
index 52e50c6e9f..0000000000
--- a/deps/npm/test/tap/install-link-scripts.js
+++ /dev/null
@@ -1,121 +0,0 @@
-var fs = require('graceful-fs')
-var path = require('path')
-
-var mkdirp = require('mkdirp')
-var rimraf = require('rimraf')
-const t = require('tap')
-
-var common = require('../common-tap.js')
-common.skipIfWindows('links are weird on windows')
-
-var pkg = common.pkg
-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: 'node ./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
-
-t.beforeEach(cb => {
- rimraf(pkg, er => {
- if (er) {
- return cb(er)
- }
- 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')
- cb()
- })
-})
-
-t.test('plain install', function (t) {
- 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()
- }
- )
-})
-
-t.test('link', function (t) {
- 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()
- }
- )
-})
-
-t.test('install --link', function (t) {
- 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()
- }
- )
- }
- )
-})
diff --git a/deps/npm/test/tap/install-local-dep-cycle.js b/deps/npm/test/tap/install-local-dep-cycle.js
deleted file mode 100644
index a66f04bce4..0000000000
--- a/deps/npm/test/tap/install-local-dep-cycle.js
+++ /dev/null
@@ -1,79 +0,0 @@
-'use strict'
-var path = require('path')
-var fs = require('graceful-fs')
-var mkdirp = require('mkdirp')
-var rimraf = require('rimraf')
-var test = require('tap').test
-var common = require('../common-tap.js')
-
-var base = common.pkg
-
-var baseJSON = {
- name: 'base',
- version: '1.0.0',
- dependencies: {
- a: 'file:a/',
- b: 'file:b/'
- }
-}
-
-var aPath = path.join(base, 'a')
-var aJSON = {
- name: 'a',
- version: '1.0.0',
- dependencies: {
- b: 'file:../b',
- c: 'file:../c'
- }
-}
-
-var bPath = path.join(base, 'b')
-var bJSON = {
- name: 'b',
- version: '1.0.0'
-}
-
-var cPath = path.join(base, 'c')
-var cJSON = {
- name: 'c',
- version: '1.0.0',
- dependencies: {
- b: 'file:../b'
- }
-}
-
-test('setup', function (t) {
- cleanup()
- setup()
- t.end()
-})
-
-test('install', function (t) {
- common.npm(['install'], {cwd: base}, function (er, code, stdout, stderr) {
- t.ifError(er, 'npm config ran without issue')
- t.is(code, 0, 'exited with a non-error code')
- t.is(stderr, '', 'Ran without errors')
- t.end()
- })
-})
-
-test('cleanup', function (t) {
- cleanup()
- t.end()
-})
-
-function saveJson (pkgPath, json) {
- mkdirp.sync(pkgPath)
- fs.writeFileSync(path.join(pkgPath, 'package.json'), JSON.stringify(json, null, 2))
-}
-
-function setup () {
- saveJson(base, baseJSON)
- saveJson(aPath, aJSON)
- saveJson(bPath, bJSON)
- saveJson(cPath, cJSON)
-}
-
-function cleanup () {
- rimraf.sync(base)
-}
diff --git a/deps/npm/test/tap/install-local-from-local.js b/deps/npm/test/tap/install-local-from-local.js
deleted file mode 100644
index ec53c74a39..0000000000
--- a/deps/npm/test/tap/install-local-from-local.js
+++ /dev/null
@@ -1,94 +0,0 @@
-'use strict'
-var path = require('path')
-var fs = require('graceful-fs')
-var test = require('tap').test
-var common = require('../common-tap.js')
-var Tacks = require('tacks')
-var Dir = Tacks.Dir
-var File = Tacks.File
-
-var testdir = path.join(__dirname, path.basename(__filename, '.js'))
-var cwd = path.join(testdir, '3')
-
-/**
- * NOTE: Tarball Fixtures
- * They contain package.json files with dependencies like the following:
- * 1-1.0.0.tgz: package/package.json
- * {
- * "name":"1",
- * "version":"1.0.0"
- * }
- * 2-1.0.0.tgz: package/package.json
- * {
- * "name":"2",
- * "version":"1.0.0",
- * "dependencies":{
- * "1":"file:../1/1-1.0.0.tgz"
- * }
- * }
- */
-var fixture = new Tacks(Dir({
- '1': Dir({
- '1-1.0.0.tgz': File(Buffer.from(
- '1f8b08000000000000032b484cce4e4c4fd52f80d07a59c5f9790c540606' +
- '06066626260ad8c4c1c0d85c81c1d8d4ccc0d0d0cccc00a80ec830353103' +
- 'd2d4760836505a5c925804740aa5e640bca200a78708a856ca4bcc4d55b2' +
- '523254d2512a4b2d2acecccf03f1f40cf40c946ab906da79a360148c8251' +
- '300a6804007849dfdf00080000',
- 'hex'
- ))
- }),
- '2': Dir({
- '2-1.0.0.tgz': File(Buffer.from(
- '1f8b0800000000000003ed8f3d0e83300c8599394594b90d36840cdc2602' +
- '17d19f80087468c5ddeb14a9135b91aa4af996e73c3f47f660eb8b6d291b' +
- '565567dfbb646700c0682db6fc00ea5c24456900d118e01c17a52e58f75e' +
- '648bd94f76e455befd67bd457cf44f78a64248676f242b21737908cf3b8d' +
- 'beeb5d70508182d56d6820d790ab3bf2dc0a83ec62489dba2b554a6598e1' +
- 'f13da1a6f62139b0a44bfaeb0b23914824b2c50b8b5b623100080000',
- 'hex'
- ))
- }),
- '3': Dir({
- 'package.json': File({
- name: '3',
- version: '1.0.0',
- dependencies: {
- '2': '../2/2-1.0.0.tgz'
- }
- })
- })
-}))
-
-function setup () {
- fixture.create(testdir)
-}
-
-function cleanup () {
- fixture.remove(testdir)
-}
-
-test('setup', function (t) {
- cleanup()
- setup()
- t.end()
-})
-
-test('installing local package with local dependency', function (t) {
- common.npm(
- ['install'],
- {cwd: cwd},
- function (er, code, stdout, stderr) {
- t.is(code, 0, 'no error code')
- t.is(stderr, '', 'no error output')
- t.ok(fs.existsSync(path.join(cwd, 'node_modules', '2')), 'installed direct dep')
- t.ok(fs.existsSync(path.join(cwd, 'node_modules', '1')), 'installed indirect dep')
- t.end()
- }
- )
-})
-
-test('cleanup', function (t) {
- cleanup()
- t.end()
-})
diff --git a/deps/npm/test/tap/install-man.js b/deps/npm/test/tap/install-man.js
deleted file mode 100644
index 8c4b890151..0000000000
--- a/deps/npm/test/tap/install-man.js
+++ /dev/null
@@ -1,57 +0,0 @@
-var fs = require('fs')
-var resolve = require('path').resolve
-
-var mkdirp = require('mkdirp')
-var test = require('tap').test
-
-var common = require('../common-tap.js')
-
-var pkg = resolve(common.pkg, 'package')
-var target = resolve(common.pkg, 'target')
-
-common.pendIfWindows('man pages do not get installed on Windows')
-
-var EXEC_OPTS = {
- cwd: target
-}
-
-var json = {
- name: 'install-man',
- version: '1.2.3',
- man: [ './install-man.1' ]
-}
-
-test('setup', function (t) {
- 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')
- 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()
- }
- )
-})
diff --git a/deps/npm/test/tap/install-mention-funding.js b/deps/npm/test/tap/install-mention-funding.js
deleted file mode 100644
index 3e9b81f240..0000000000
--- a/deps/npm/test/tap/install-mention-funding.js
+++ /dev/null
@@ -1,127 +0,0 @@
-'use strict'
-const path = require('path')
-const test = require('tap').test
-const Tacks = require('tacks')
-const Dir = Tacks.Dir
-const File = Tacks.File
-const common = require('../common-tap.js')
-
-const base = common.pkg
-const singlePackage = path.join(base, 'single-funding-package')
-const multiplePackages = path.join(base, 'top-level-funding')
-
-function getFixturePackage ({ name, version, dependencies, funding }) {
- return Dir({
- 'package.json': File({
- name,
- version: version || '1.0.0',
- funding: funding || {
- type: 'individual',
- url: 'http://example.com/donate'
- },
- dependencies: dependencies || {}
- })
- })
-}
-
-const fixture = new Tacks(Dir({
- 'package.json': File({}),
- 'single-funding-package': getFixturePackage({
- name: 'single-funding-package'
- }),
- 'top-level-funding': getFixturePackage({
- name: 'top-level-funding',
- dependencies: {
- 'dep-foo': 'file:../dep-foo',
- 'dep-bar': 'file:../dep-bar'
- }
- }),
- 'dep-foo': getFixturePackage({
- name: 'dep-foo',
- funding: {
- type: 'corporate',
- url: 'https://corp.example.com/sponsor'
- },
- dependencies: {
- 'sub-dep-bar': 'file:../sub-dep-bar'
- }
- }),
- 'dep-bar': getFixturePackage({
- name: 'dep-bar',
- version: '2.1.0',
- dependencies: {
- 'sub-dep-bar': 'file:../sub-dep-bar'
- }
- }),
- 'sub-dep-bar': getFixturePackage({
- name: 'sub-dep-bar',
- funding: {
- type: 'foo',
- url: 'http://example.com/foo'
- }
- })
-}))
-
-test('mention npm fund upon installing single dependency', function (t) {
- setup(t)
- common.npm(['install', '--no-save', singlePackage], {cwd: base}, function (err, code, stdout, stderr) {
- if (err) throw err
- t.is(code, 0, 'installed successfully')
- t.is(stderr, '', 'no warnings')
- t.includes(stdout, '1 package is looking for funding', 'should print amount of packages needing funding')
- t.includes(stdout, ' run `npm fund` for details', 'should print npm fund mention')
- t.end()
- })
-})
-
-test('mention npm fund upon installing multiple dependencies', function (t) {
- setup(t)
- common.npm(['install', '--no-save', multiplePackages], {cwd: base}, function (err, code, stdout, stderr) {
- if (err) throw err
- t.is(code, 0, 'installed successfully')
- t.is(stderr, '', 'no warnings')
- t.includes(stdout, '4 packages are looking for funding', 'should print amount of packages needing funding')
- t.includes(stdout, ' run `npm fund` for details', 'should print npm fund mention')
- t.end()
- })
-})
-
-test('skips mention npm fund using --no-fund option', function (t) {
- setup(t)
- common.npm(['install', '--no-save', '--no-fund', multiplePackages], {cwd: base}, function (err, code, stdout, stderr) {
- if (err) throw err
- t.is(code, 0, 'installed successfully')
- t.is(stderr, '', 'no warnings')
- t.doesNotHave(stdout, '4 packages are looking for funding', 'should print amount of packages needing funding')
- t.doesNotHave(stdout, ' run `npm fund` for details', 'should print npm fund mention')
- t.end()
- })
-})
-
-test('mention packages looking for funding using --json', function (t) {
- setup(t)
- common.npm(['install', '--no-save', '--json', multiplePackages], {cwd: base}, function (err, code, stdout, stderr) {
- if (err) throw err
- t.is(code, 0, 'installed successfully')
- t.is(stderr, '', 'no warnings')
- const res = JSON.parse(stdout)
- t.match(res.funding, '4 packages are looking for funding', 'should print amount of packages needing funding')
- t.end()
- })
-})
-
-test('cleanup', function (t) {
- cleanup()
- t.end()
-})
-
-function setup (t) {
- fixture.create(base)
- t.teardown(() => {
- cleanup()
- })
-}
-
-function cleanup () {
- fixture.remove(base)
-}
diff --git a/deps/npm/test/tap/install-noargs-dev.js b/deps/npm/test/tap/install-noargs-dev.js
deleted file mode 100644
index 53422b9b5b..0000000000
--- a/deps/npm/test/tap/install-noargs-dev.js
+++ /dev/null
@@ -1,90 +0,0 @@
-var fs = require('fs')
-var path = require('path')
-
-var mkdirp = require('mkdirp')
-var mr = require('npm-registry-mock')
-var test = require('tap').test
-
-var common = require('../common-tap.js')
-
-var pkg = common.pkg
-
-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) {
- mkdirp.sync(path.resolve(pkg, 'node_modules'))
- fs.writeFileSync(
- path.join(pkg, 'package.json'),
- JSON.stringify(PACKAGE_JSON1, null, 2)
- )
- mr({ port: common.port }, function (er, s) {
- t.ifError(er, 'started mock registry')
- t.parent.teardown(() => s.close())
- t.end()
- })
-})
-
-test('install noargs installs devDependencies', function (t) {
- common.npm(
- [
- '--registry', common.registry,
- '--loglevel', 'silent',
- '--no-save',
- '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',
- '--no-save',
- '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()
- }
- )
-})
diff --git a/deps/npm/test/tap/install-order.js b/deps/npm/test/tap/install-order.js
deleted file mode 100644
index c4a2b1c383..0000000000
--- a/deps/npm/test/tap/install-order.js
+++ /dev/null
@@ -1,65 +0,0 @@
-'use strict'
-/* eslint-disable no-use-before-define */
-var test = require('tap').test
-var sortActions = require('../../lib/install/diff-trees.js').sortActions
-var top = {
- location: '/',
- package: {},
- requiredBy: [],
- requires: [a, b],
- isTop: true
-}
-var a = {
- location: '/a',
- package: {},
- requiredBy: [],
- requires: [c],
- isTop: false,
- userRequired: false,
- existing: false,
- parent: top
-}
-var b = {
- location: '/b',
- package: {},
- requiredBy: [],
- requires: [c],
- isTop: false,
- userRequired: false,
- existing: false,
- parent: top
-}
-var c = {
- location: '/c',
- package: {},
- requiredBy: [a, b],
- requires: [],
- isTop: false,
- userRequired: false,
- existing: false,
- parent: top
-}
-
-test('install-order when installing deps', function (t) {
- var plain = [
- ['add', a],
- ['add', b],
- ['add', c]]
- var sorted = [
- ['add', c],
- ['add', a],
- ['add', b]]
- t.isDeeply(sortActions(plain), sorted)
- t.end()
-})
-
-test('install-order when not installing deps', function (t) {
- var plain = [
- ['add', a],
- ['add', b]]
- var sorted = [
- ['add', a],
- ['add', b]]
- t.isDeeply(sortActions(plain), sorted)
- t.end()
-})
diff --git a/deps/npm/test/tap/install-package-json-order.js b/deps/npm/test/tap/install-package-json-order.js
deleted file mode 100644
index 45ce882620..0000000000
--- a/deps/npm/test/tap/install-package-json-order.js
+++ /dev/null
@@ -1,42 +0,0 @@
-var test = require('tap').test
-var path = require('path')
-var mkdirp = require('mkdirp')
-var spawn = require('child_process').spawn
-var npm = require.resolve('../../bin/npm-cli.js')
-var node = process.execPath
-const common = require('../common-tap.js')
-var pkg = common.pkg
-var workdir = path.join(pkg, 'workdir')
-var tmp = path.join(pkg, 'tmp')
-var fs = require('fs')
-
-test('package.json sorting after install', function (t) {
- var packageJson = path.resolve(pkg, 'package.json')
- var installedPackage = path.resolve(workdir,
- 'node_modules/install-package-json-order/package.json')
-
- mkdirp.sync(tmp)
- mkdirp.sync(workdir)
-
- fs.writeFileSync(path.resolve(pkg, 'package.json'), JSON.stringify({
- 'name': 'install-package-json-order',
- 'version': '0.0.0',
- 'array': [ 'one', 'two', 'three' ]
- }, null, 2), 'utf8')
-
- fs.writeFileSync(path.resolve(workdir, 'package.json'), JSON.stringify({
- 'name': 'install-package-json-order-work',
- 'version': '0.0.0'
- }, null, 2), 'utf8')
-
- var before = JSON.parse(fs.readFileSync(packageJson).toString())
- var child = spawn(node, [npm, 'install', pkg], { cwd: workdir })
-
- child.on('close', function (code) {
- t.equal(code, 0, 'npm install exited with code')
- var result = fs.readFileSync(installedPackage, 'utf8')
- var resultAsJson = JSON.parse(result)
- t.same(resultAsJson.array, before.array)
- t.end()
- })
-})
diff --git a/deps/npm/test/tap/install-package-lock-only.js b/deps/npm/test/tap/install-package-lock-only.js
deleted file mode 100644
index 2c5191a02e..0000000000
--- a/deps/npm/test/tap/install-package-lock-only.js
+++ /dev/null
@@ -1,123 +0,0 @@
-'use strict'
-var fs = require('fs')
-var path = require('path')
-var test = require('tap').test
-var mr = require('npm-registry-mock')
-var Tacks = require('tacks')
-var File = Tacks.File
-var Dir = Tacks.Dir
-var common = require('../common-tap.js')
-
-var basedir = common.pkg
-var testdir = path.join(basedir, 'testdir')
-var cachedir = common.cache
-var globaldir = path.join(basedir, 'global')
-var tmpdir = path.join(basedir, 'tmp')
-
-var pkgLockPath = path.join(testdir, 'package-lock.json')
-var nodeModulesPath = path.join(testdir, 'node_modules')
-
-var conf = {
- cwd: testdir,
- env: Object.assign({}, process.env, {
- npm_config_cache: cachedir,
- npm_config_tmp: tmpdir,
- npm_config_prefix: globaldir,
- npm_config_registry: common.registry,
- npm_config_loglevel: 'warn'
- })
-}
-
-const confPkgLockFalse = {
- cwd: testdir,
- env: Object.assign({}, process.env, {
- npm_config_cache: cachedir,
- npm_config_tmp: tmpdir,
- npm_config_prefix: globaldir,
- npm_config_registry: common.registry,
- npm_config_loglevel: 'warn',
- npm_config_package_lock: false
- })
-}
-
-var server
-var fixture = new Tacks(Dir({
- cache: Dir(),
- global: Dir(),
- tmp: Dir(),
- testdir: Dir({
- 'package.json': File({
- name: 'install-package-lock-only',
- version: '1.0.0',
- dependencies: {
- mkdirp: '^0.3.4'
- }
- })
- })
-}))
-
-function setup () {
- cleanup()
- fixture.create(basedir)
-}
-
-function cleanup () {
- fixture.remove(basedir)
-}
-
-test('setup', function (t) {
- mr({port: common.port, throwOnUnmatched: true}, function (err, s) {
- if (err) throw err
- server = s
- t.done()
- })
-})
-
-test('package-lock-only', function (t) {
- setup()
- return common.npm(['install', '--package-lock-only'], conf).spread((code, stdout, stderr) => {
- t.is(code, 0, 'command ran ok')
- t.comment(stdout.trim())
- t.comment(stderr.trim())
- // Verify that node_modules does not exist
- t.notOk(fs.existsSync(nodeModulesPath), 'ensure that node_modules does not exist')
-
- // Verify that package-lock.json exists and has `mkdirp@0.3.5` in it.
- t.ok(fs.existsSync(pkgLockPath), 'ensure that package-lock.json was created')
- var pkgLock = JSON.parse(fs.readFileSync(pkgLockPath, 'utf-8'))
- t.equal(pkgLock.dependencies.mkdirp.version, '0.3.5')
- t.done()
- })
-})
-
-test('--package-lock-only with --package-lock negates `package_lock: false`', function (t) {
- setup()
- return common.npm(['install', '--package-lock', '--package-lock-only'], confPkgLockFalse).spread((code, stdout, stderr) => {
- t.is(code, 0, 'ok')
- t.comment(stdout.trim())
- t.comment(stderr.trim())
-
- // Verify that package-lock.json exists.
- t.ok(fs.existsSync(pkgLockPath), 'ensure that package-lock.json was created')
- t.end()
- })
-})
-
-test('package-lock-only creates package_lock.json when config has `package_lock: false`', function (t) {
- setup()
- return common.npm(['install', '--package-lock-only'], confPkgLockFalse).spread((code, stdout, stderr) => {
- t.is(code, 0, 'ok')
- t.comment(stdout.trim())
- t.comment(stderr.trim())
-
- // Verify that package-lock.json exists.
- t.ok(fs.existsSync(pkgLockPath), 'ensure that package-lock.json was created')
- t.end()
- })
-})
-
-test('cleanup', function (t) {
- server.close()
- cleanup()
- t.done()
-})
diff --git a/deps/npm/test/tap/install-parse-error.js b/deps/npm/test/tap/install-parse-error.js
deleted file mode 100644
index 1a72c336de..0000000000
--- a/deps/npm/test/tap/install-parse-error.js
+++ /dev/null
@@ -1,50 +0,0 @@
-'use strict'
-var test = require('tap').test
-var Tacks = require('tacks')
-var File = Tacks.File
-var Dir = Tacks.Dir
-var common = require('../common-tap.js')
-
-var testdir = common.pkg
-
-var fixture = new Tacks(Dir({
- 'package.json': File(
- '{\n' +
- "'name': 'some-name',\n" +
- "'dependencies': {}\n" +
- '}'
- ),
- 'node_modules': Dir()
-}))
-
-function setup () {
- fixture.create(testdir)
-}
-
-function cleanup () {
- fixture.remove(testdir)
-}
-
-test('setup', function (t) {
- cleanup()
- setup()
- t.end()
-})
-
-test('failing to parse package.json should be error', function (t) {
- common.npm(
- ['install'],
- {cwd: testdir},
- function (err, code, stdout, stderr) {
- if (err) throw err
- t.equal(code, 1, 'exit not ok')
- t.similar(stderr, /npm ERR! JSON.parse Failed to parse json/)
- t.end()
- }
- )
-})
-
-test('cleanup', function (t) {
- cleanup()
- t.end()
-})
diff --git a/deps/npm/test/tap/install-property-conflicts.js b/deps/npm/test/tap/install-property-conflicts.js
deleted file mode 100644
index a98f8570c6..0000000000
--- a/deps/npm/test/tap/install-property-conflicts.js
+++ /dev/null
@@ -1,53 +0,0 @@
-var fs = require('fs')
-var resolve = require('path').resolve
-
-var mkdirp = require('mkdirp')
-var test = require('tap').test
-
-var common = require('../common-tap.js')
-
-var pkg = common.pkg
-var target = resolve(pkg, '_target')
-
-var EXEC_OPTS = {
- cwd: target
-}
-
-var json = {
- name: 'install-property-conflicts',
- version: '1.2.3',
- type: 'nose-boop!'
-}
-
-test('setup', function (t) {
- // make sure it installs locally
- mkdirp.sync(resolve(target, 'node_modules'))
- fs.writeFileSync(
- resolve(pkg, 'package.json'),
- JSON.stringify(json, null, 2) + '\n'
- )
- t.end()
-})
-
-test('install package with a `type` property', function (t) {
- t.comment('issue: https://github.com/npm/npm/issues/11398')
- common.npm(
- [
- 'install',
- '--prefix', target,
- 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)')
- var installedPkg = resolve(
- target,
- 'node_modules',
- 'install-property-conflicts',
- 'package.json')
- t.ok(fs.statSync(installedPkg), 'package installed successfully')
- t.end()
- }
- )
-})
diff --git a/deps/npm/test/tap/install-report-just-installed.js b/deps/npm/test/tap/install-report-just-installed.js
deleted file mode 100644
index 23b373b269..0000000000
--- a/deps/npm/test/tap/install-report-just-installed.js
+++ /dev/null
@@ -1,74 +0,0 @@
-'use strict'
-var test = require('tap').test
-var Tacks = require('tacks')
-var Dir = Tacks.Dir
-var File = Tacks.File
-var common = require('../common-tap.js')
-
-var testdir = common.pkg
-var fixture = new Tacks(Dir({
- node_modules: Dir({
- a: Dir({
- 'package.json': File({
- name: 'a',
- version: '1.0.0',
- dependencies: {
- b: '1.0.0'
- }
- }),
- node_modules: Dir({
- b: Dir({
- 'package.json': File({
- name: 'b',
- version: '1.0.0'
- })
- })
- })
- })
- }),
- 'b-src': Dir({
- 'package.json': File({
- name: 'b',
- version: '1.0.0'
- })
- })
-}))
-
-function setup () {
- cleanup()
- fixture.create(testdir)
-}
-
-function cleanup () {
- fixture.remove(testdir)
-}
-
-test('setup', function (t) {
- setup()
- t.end()
-})
-
-test('install-report', function (t) {
- common.npm(['install', '--no-save', '--json', './b-src'], {cwd: testdir}, function (err, code, stdout, stderr) {
- if (err) throw err
- t.is(code, 0, 'installed successfully')
- t.is(stderr, '', 'no warnings')
- try {
- var report = JSON.parse(stdout)
- t.pass('stdout was json')
- } catch (ex) {
- t.fail('stdout was json')
- console.error(ex)
- t.skip(2)
- return t.end()
- }
- t.is(report.added.length, 1, 'one dependency reported as installed')
- t.match(report.added, [{name: 'b'}], 'that dependency was `b`')
- t.end()
- })
-})
-
-test('cleanup', function (t) {
- cleanup()
- t.end()
-})
diff --git a/deps/npm/test/tap/install-save-consistent-newlines.js b/deps/npm/test/tap/install-save-consistent-newlines.js
deleted file mode 100644
index dfe41c649d..0000000000
--- a/deps/npm/test/tap/install-save-consistent-newlines.js
+++ /dev/null
@@ -1,98 +0,0 @@
-'use strict'
-
-const fs = require('graceful-fs')
-const path = require('path')
-
-const mkdirp = require('mkdirp')
-const mr = require('npm-registry-mock')
-const rimraf = require('rimraf')
-const test = require('tap').test
-
-const common = require('../common-tap.js')
-
-const pkg = common.pkg
-
-const EXEC_OPTS = { cwd: pkg }
-
-const json = {
- name: 'install-save-consistent-newlines',
- version: '0.0.1',
- description: 'fixture'
-}
-
-test('mock registry', function (t) {
- mr({ port: common.port }, function (er, s) {
- t.parent.teardown(() => s.close())
- t.end()
- })
-})
-
-const runTest = (t, opts) => {
- t.test('setup', setup(opts.ending))
- t.test('check', check(opts))
- t.end()
-}
-
-const setup = lineEnding => t => {
- rimraf(pkg, er => {
- if (er) {
- throw er
- }
- mkdirp.sync(path.resolve(pkg, 'node_modules'))
-
- var jsonStr = JSON.stringify(json, null, 2)
-
- if (lineEnding === '\r\n') {
- jsonStr = jsonStr.replace(/\n/g, '\r\n')
- }
-
- fs.writeFileSync(
- path.join(pkg, 'package.json'),
- jsonStr
- )
-
- t.end()
- })
-}
-
-const check = opts => t => common.npm(
- [
- '--loglevel', 'silent',
- '--registry', common.registry,
- '--save',
- 'install', 'underscore@1.3.1'
- ],
- EXEC_OPTS
-).then(([code, err, out]) => {
- t.notOk(code, 'npm install exited without raising an error code')
-
- const pkgPath = path.resolve(pkg, 'package.json')
- const pkgStr = fs.readFileSync(pkgPath, 'utf8')
-
- t.match(pkgStr, opts.match)
- t.notMatch(pkgStr, opts.notMatch)
-
- const pkgLockPath = path.resolve(pkg, 'package-lock.json')
- const pkgLockStr = fs.readFileSync(pkgLockPath, 'utf8')
-
- t.match(pkgLockStr, opts.match)
- t.notMatch(pkgLockStr, opts.notMatch)
-
- t.end()
-})
-
-test('keep LF line endings', t => {
- runTest(t, {
- ending: '\n',
- match: '\n',
- notMatch: '\r'
- })
-})
-
-test('keep CRLF line endings', t => {
- runTest(t, {
- ending: '\r\n',
- match: '\r\n',
- notMatch: /[^\r]\n/
- })
-})
diff --git a/deps/npm/test/tap/install-save-exact.js b/deps/npm/test/tap/install-save-exact.js
deleted file mode 100644
index efa1e63613..0000000000
--- a/deps/npm/test/tap/install-save-exact.js
+++ /dev/null
@@ -1,82 +0,0 @@
-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 = common.pkg
-
-var EXEC_OPTS = { cwd: pkg }
-
-var json = {
- name: 'install-save-exact',
- version: '0.0.1',
- description: 'fixture'
-}
-
-test('mock registry', function (t) {
- mr({ port: common.port }, function (er, s) {
- t.parent.teardown(() => s.close())
- t.end()
- })
-})
-
-const setup = t => {
- t.test('destroy', t => rimraf(pkg, t.end))
- t.test('create', t => {
- mkdirp.sync(path.resolve(pkg, 'node_modules'))
- fs.writeFileSync(
- path.join(pkg, 'package.json'),
- JSON.stringify(json, null, 2)
- )
- t.end()
- })
- t.end()
-}
-
-const check = (savearg, deptype) => t => {
- common.npm(
- [
- '--loglevel', 'silent',
- '--registry', common.registry,
- savearg,
- '--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[deptype],
- { 'underscore': '1.3.1' },
- 'underscore dependency should specify exactly 1.3.1'
- )
-
- t.end()
- }
- )
-}
-
-test('\'npm install --save --save-exact\' should install local pkg', function (t) {
- t.test('setup', setup)
- t.test('check', check('--save', 'dependencies'))
- t.end()
-})
-
-test('\'npm install --save-dev --save-exact\' should install local pkg', function (t) {
- t.test('setup', setup)
- t.test('check', check('--save-dev', 'devDependencies'))
- t.end()
-})
diff --git a/deps/npm/test/tap/install-save-local.js b/deps/npm/test/tap/install-save-local.js
deleted file mode 100644
index 8b65979528..0000000000
--- a/deps/npm/test/tap/install-save-local.js
+++ /dev/null
@@ -1,181 +0,0 @@
-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.js')
-
-var root = common.pkg
-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 deps in root', t => {
- 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)
- )
-
- t.end()
-})
-
-test('\'npm install --save ../local/path\' should save to package.json', function (t) {
- t.plan(2)
- t.test('setup', setup)
- t.test('run test', t => common.npm(
- [
- '--loglevel', 'silent',
- '--save',
- 'install', '../package-local-dependency'
- ],
- EXEC_OPTS
- ).then(([code]) => {
- t.equal(code, 0, '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.is(Object.keys(pkgJson.dependencies).length, 1, 'only one dep')
- t.ok(
- /file:.*?[/]package-local-dependency$/.test(pkgJson.dependencies['package-local-dependency']),
- 'local package saved correctly'
- )
- }))
-})
-
-test('\'npm install --save local/path\' should save to package.json', function (t) {
- t.plan(2)
- t.test('setup', setup)
- t.test('run test', t => common.npm(
- [
- '--loglevel', 'silent',
- '--save',
- 'install', 'package-local-dependency/'
- ],
- EXEC_OPTS
- ).then(([code, out, err]) => {
- t.equal(code, 0, '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.is(Object.keys(pkgJson.dependencies).length, 1, 'only one dep')
- t.ok(
- /file:package-local-dependency$/.test(pkgJson.dependencies['package-local-dependency']),
- 'local package saved correctly'
- )
- }))
-})
-
-test('\'npm install --save-dev ../local/path\' should save to package.json', function (t) {
- t.plan(2)
- t.test('setup', setup)
- t.test('run test', t => common.npm(
- [
- '--loglevel', 'silent',
- '--save-dev',
- 'install', '../package-local-dev-dependency'
- ],
- EXEC_OPTS
- ).then(([code]) => {
- t.equal(code, 0, '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.is(Object.keys(pkgJson.devDependencies).length, 1, 'only one dep')
- t.ok(
- /file:.*?[/\\]package-local-dev-dependency$/.test(pkgJson.devDependencies['package-local-dev-dependency']),
- 'local package saved correctly'
- )
-
- t.end()
- }))
-})
-
-test('\'npm install --save-dev local/path\' should save to package.json', function (t) {
- t.plan(2)
- t.test('setup', setup)
- t.test('run test', t => common.npm(
- [
- '--loglevel', 'silent',
- '--save-dev',
- 'install', 'package-local-dev-dependency/'
- ],
- EXEC_OPTS
- ).then(([code]) => {
- t.equal(code, 0, '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.is(Object.keys(pkgJson.devDependencies).length, 1, 'only one dep')
- t.ok(
- /file:package-local-dev-dependency$/.test(pkgJson.devDependencies['package-local-dev-dependency']),
- 'local package saved correctly'
- )
-
- t.end()
- }))
-})
-
-function setup (t) {
- t.test('destroy', t => rimraf(pkg, t.end))
- t.test('create', t => {
- mkdirp.sync(pkg)
- fs.writeFileSync(
- path.join(pkg, 'package.json'),
- JSON.stringify(json, null, 2)
- )
-
- mkdirp.sync(path.join(pkg, 'package-local-dependency'))
- fs.writeFileSync(
- path.join(pkg, 'package-local-dependency', 'package.json'),
- JSON.stringify(localDependency, null, 2)
- )
-
- mkdirp.sync(path.join(pkg, 'package-local-dev-dependency'))
- fs.writeFileSync(
- path.join(pkg, 'package-local-dev-dependency', 'package.json'),
- JSON.stringify(localDevDependency, null, 2)
- )
- t.end()
- })
- t.end()
-}
diff --git a/deps/npm/test/tap/install-save-prefix.js b/deps/npm/test/tap/install-save-prefix.js
deleted file mode 100644
index d61608e1cf..0000000000
--- a/deps/npm/test/tap/install-save-prefix.js
+++ /dev/null
@@ -1,164 +0,0 @@
-var fs = require('fs')
-var path = require('path')
-
-var mr = require('npm-registry-mock')
-var rimraf = require('rimraf')
-var test = require('tap').test
-
-var common = require('../common-tap.js')
-
-var pkg = common.pkg
-
-var EXEC_OPTS = { cwd: pkg }
-
-var json = {
- name: 'install-save-prefix',
- version: '0.0.1'
-}
-
-test('start mock reg', function (t) {
- mr({ port: common.port }, function (er, s) {
- t.ifError(er, 'started mock registry')
- t.parent.teardown(() => s.close())
- t.end()
- })
-})
-
-test('install --save with \'^\' save prefix should accept minor updates', function (t) {
- t.plan(2)
- t.test('setup', setup)
- t.test('run test', t => common.npm(
- [
- '--registry', common.registry,
- '--loglevel', 'silent',
- '--save-prefix', '^',
- '--save',
- 'install', 'underscore@latest'
- ],
- EXEC_OPTS
- ).then(([code]) => {
- console.error('back from install!', code)
- t.equal(code, 0, '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'
- )
- }))
-})
-
-test('install --save-dev with \'^\' save prefix should accept minor dev updates', function (t) {
- t.plan(2)
- t.test('setup', setup)
- t.test('run test', t => common.npm(
- [
- '--registry', common.registry,
- '--loglevel', 'silent',
- '--save-prefix', '^',
- '--save-dev',
- 'install', 'underscore@1.3.1'
- ],
- EXEC_OPTS
- ).then(([code]) => {
- t.equal(code, 0, '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) {
- t.plan(2)
- t.test('setup', setup)
- t.test('run test', t => common.npm(
- [
- '--registry', common.registry,
- '--loglevel', 'silent',
- '--save-prefix', '~',
- '--save',
- 'install', 'underscore@1.3.1'
- ],
- EXEC_OPTS
- ).then(([code]) => {
- t.equal(code, 0, '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'
- )
- }))
-})
-
-test('install --save-dev with \'~\' save prefix should accept patch updates', function (t) {
- t.plan(2)
- t.test('setup', setup)
- t.test('run test', t => common.npm(
- [
- '--registry', common.registry,
- '--loglevel', 'silent',
- '--save-prefix', '~',
- '--save-dev',
- 'install', 'underscore@1.3.1'
- ],
- EXEC_OPTS
- ).then(([code]) => {
- 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'
- )
- }))
-})
-
-function setup (t) {
- t.test('destroy', t => {
- t.plan(2)
- rimraf(path.resolve(pkg, 'node_modules'), () => t.pass('node_modules'))
- rimraf(path.resolve(pkg, 'pacakage-lock.json'), () => t.pass('lock file'))
- })
- t.test('create', t => {
- fs.writeFileSync(
- path.join(pkg, 'package.json'),
- JSON.stringify(json, null, 2)
- )
- t.end()
- })
-
- t.end()
-}
diff --git a/deps/npm/test/tap/install-scoped-already-installed.js b/deps/npm/test/tap/install-scoped-already-installed.js
deleted file mode 100644
index d4655f4a9a..0000000000
--- a/deps/npm/test/tap/install-scoped-already-installed.js
+++ /dev/null
@@ -1,129 +0,0 @@
-var fs = require('graceful-fs')
-var path = require('path')
-var existsSync = fs.existsSync || path.existsSync
-
-var mkdirp = require('mkdirp')
-var test = require('tap').test
-
-var common = require('../common-tap')
-
-var root = common.pkg
-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-scoped-dependency',
- version: '0.0.0',
- description: 'Test for local installs'
-}
-
-test('setup', function (t) {
- 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)
- )
-
- t.end()
-})
-
-test('installing already installed local scoped package', function (t) {
- common.npm(
- [
- '--loglevel', 'silent',
- '--parseable',
- '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-scoped-dependency', 'package.json')),
- 'package installed'
- )
- t.ok(
- contains(installed, 'node_modules/@scoped/package-scoped-dependency'),
- 'installed @scoped/package-scoped-dependency'
- )
- t.ok(
- contains(installed, 'node_modules/package-local-dependency'),
- 'installed package-local-dependency'
- )
-
- common.npm(
- [
- '--loglevel', 'silent',
- '--parseable',
- '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-scoped-dependency', 'package.json')),
- 'package installed'
- )
-
- t.notOk(
- contains(installed, 'node_modules/@scoped/package-scoped-dependency'),
- 'did not reinstall @scoped/package-scoped-dependency'
- )
- t.notOk(
- contains(installed, 'node_modules/package-local-dependency'),
- 'did not reinstall package-local-dependency'
- )
- t.end()
- }
- )
- }
- )
-})
-
-function contains (list, element) {
- var matcher = new RegExp(element.replace(/\//g, '[\\\\/]') + '$')
- for (var i = 0; i < list.length; ++i) {
- if (matcher.test(list[i])) {
- return true
- }
- }
- return false
-}
-
-function parseNpmInstallOutput (stdout) {
- return stdout.trim().split(/\n\n|\s+/)
-}
diff --git a/deps/npm/test/tap/install-scoped-link.js b/deps/npm/test/tap/install-scoped-link.js
deleted file mode 100644
index a0c9c61a98..0000000000
--- a/deps/npm/test/tap/install-scoped-link.js
+++ /dev/null
@@ -1,73 +0,0 @@
-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 test = require('tap').test
-
-var escapeExecPath = require('../../lib/utils/escape-exec-path')
-
-var common = require('../common-tap.js')
-
-var resolve = require('path').resolve
-var pkg = resolve(common.pkg, 'package')
-var work = resolve(common.pkg, 'TEST')
-var modules = path.join(work, 'node_modules')
-
-var EXEC_OPTS = { cwd: work }
-
-var world = '#!/usr/bin/env node\nconsole.log("hello blrbld")\n'
-
-var json = {
- name: '@scoped/package',
- version: '0.0.0',
- bin: {
- hello: './world.js'
- }
-}
-
-test('setup', function (t) {
- 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(escapeExecPath(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()
- })
- }
- )
-})
diff --git a/deps/npm/test/tap/install-scoped-with-bundled-dependency.js b/deps/npm/test/tap/install-scoped-with-bundled-dependency.js
deleted file mode 100644
index db126eb642..0000000000
--- a/deps/npm/test/tap/install-scoped-with-bundled-dependency.js
+++ /dev/null
@@ -1,83 +0,0 @@
-'use strict'
-var path = require('path')
-var test = require('tap').test
-var Tacks = require('tacks')
-var File = Tacks.File
-var Dir = Tacks.Dir
-var common = require('../common-tap.js')
-
-var basedir = common.pkg
-var testdir = path.join(basedir, 'testdir')
-var cachedir = common.cache
-var globaldir = path.join(basedir, 'global')
-var tmpdir = path.join(basedir, 'tmp')
-
-var conf = {
- cwd: testdir,
- env: Object.assign({
- npm_config_cache: cachedir,
- npm_config_tmp: tmpdir,
- npm_config_prefix: globaldir,
- npm_config_registry: common.registry,
- npm_config_loglevel: 'warn'
- }, process.env)
-}
-
-var fixture = new Tacks(Dir({
- cache: Dir(),
- global: Dir(),
- tmp: Dir(),
- testdir: Dir({
- node_modules: Dir({
- }),
- package: Dir({
- node_modules: Dir({
- 'bundled-dep': Dir({
- 'package.json': File({
- name: 'bundled-dep',
- version: '0.0.0'
- })
- })
- }),
- 'package.json': File({
- name: '@scope/package',
- version: '0.0.0',
- dependencies: {
- 'bundled-dep': '*'
- },
- bundledDependencies: [
- 'bundled-dep'
- ]
- })
- })
- })
-}))
-
-function setup () {
- cleanup()
- fixture.create(basedir)
-}
-
-function cleanup () {
- fixture.remove(basedir)
-}
-
-test('setup', function (t) {
- setup()
- t.done()
-})
-
-test('install dependencies of bundled dependencies', function (t) {
- common.npm(['install', './package'], conf, function (err, code, stdout, stderr) {
- if (err) throw err
- t.is(code, 0, 'command ran ok')
- t.comment(stdout.trim())
- t.comment(stderr.trim())
- t.done()
- })
-})
-
-test('cleanup', function (t) {
- cleanup()
- t.done()
-})
diff --git a/deps/npm/test/tap/install-scoped-with-peer-dependency.js b/deps/npm/test/tap/install-scoped-with-peer-dependency.js
deleted file mode 100644
index 016f5f0453..0000000000
--- a/deps/npm/test/tap/install-scoped-with-peer-dependency.js
+++ /dev/null
@@ -1,40 +0,0 @@
-var fs = require('fs')
-var path = require('path')
-
-var mkdirp = require('mkdirp')
-var test = require('tap').test
-
-var common = require('../common-tap.js')
-var pkg = common.pkg
-var local = path.join(pkg, 'package')
-
-var EXEC_OPTS = { cwd: pkg }
-
-var json = {
- name: '@scope/package',
- version: '0.0.0',
- peerDependencies: {
- underscore: '*'
- }
-}
-
-test('setup', function (t) {
- mkdirp.sync(local)
- mkdirp.sync(path.resolve(pkg, 'node_modules'))
- fs.writeFileSync(
- path.join(local, 'package.json'),
- JSON.stringify(json, null, 2)
- )
- t.end()
-})
-
-test('it should install peerDependencies in same tree level as the parent package', function (t) {
- common.npm(['install', '--loglevel=warn', './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.match(stderr, /npm WARN @scope[/]package@0[.]0[.]0 requires a peer of underscore@[*] but none is installed[.] You must install peer dependencies yourself[.]\n/,
- 'npm install warned about unresolved peer dep')
-
- t.end()
- })
-})
diff --git a/deps/npm/test/tap/install-shrinkwrapped-git.js b/deps/npm/test/tap/install-shrinkwrapped-git.js
deleted file mode 100644
index 3cdc2b9129..0000000000
--- a/deps/npm/test/tap/install-shrinkwrapped-git.js
+++ /dev/null
@@ -1,155 +0,0 @@
-'use strict'
-
-var fs = require('fs')
-var path = require('path')
-var resolve = path.resolve
-var mkdirp = require('mkdirp')
-var rimraf = require('rimraf')
-var test = require('tap').test
-var npm = require('../../lib/npm')
-var common = require('../common-tap')
-var chain = require('slide').chain
-
-var mockPath = common.pkg
-var parentPath = resolve(mockPath, 'parent')
-var parentNodeModulesPath = path.join(parentPath, 'node_modules')
-var outdatedNodeModulesPath = resolve(mockPath, 'node-modules-backup')
-var childPath = resolve(mockPath, 'child.git')
-
-var gitDaemon
-var gitDaemonPID
-var git
-
-var parentPackageJSON = JSON.stringify({
- name: 'parent',
- version: '0.1.0'
-})
-
-var childPackageJSON = JSON.stringify({
- name: 'child',
- version: '0.1.0'
-})
-
-test('setup', function (t) {
- mkdirp.sync(parentPath)
- fs.writeFileSync(resolve(parentPath, 'package.json'), parentPackageJSON)
- process.chdir(parentPath)
-
- // Setup child
- mkdirp.sync(childPath)
- fs.writeFileSync(resolve(childPath, 'package.json'), childPackageJSON)
-
- // Setup npm and then git
- npm.load({
- registry: common.registry,
- loglevel: 'silent',
- save: true // Always install packages with --save
- }, function () {
- // It's important to initialize git after npm because it uses config
- initializeGit(function (err, result) {
- t.ifError(err, 'git started up successfully')
-
- if (!err) {
- gitDaemon = result[result.length - 2]
- gitDaemonPID = result[result.length - 1]
- }
-
- t.end()
- })
- })
-})
-
-test('shrinkwrapped git dependency got updated', function (t) {
- t.comment('test for https://github.com/npm/npm/issues/12718')
-
- // Prepare the child package git repo with two commits
- prepareChildAndGetRefs(function (err, refs) {
- if (err) { throw err }
- chain([
- // Install & shrinkwrap child package's first commit
- [npm.commands.install, ['git://localhost:' + common.gitPort + '/child.git#' + refs[0]]],
- // Backup node_modules with the first commit
- [fs.rename, parentNodeModulesPath, outdatedNodeModulesPath],
- // Install & shrinkwrap child package's latest commit
- [npm.commands.install, ['git://localhost:' + common.gitPort + '/child.git#' + refs[1].substr(0, 8)]],
- // Restore node_modules with the first commit
- [rimraf, parentNodeModulesPath],
- [fs.rename, outdatedNodeModulesPath, parentNodeModulesPath],
- // Update node_modules
- [npm.commands.install, []]
- ], function () {
- const pkglock = require(path.join(parentPath, 'package-lock.json'))
- t.similar(pkglock, {
- dependencies: {
- child: {
- version: `git://localhost:${common.gitPort}/child.git#${refs[1]}`,
- from: `git://localhost:${common.gitPort}/child.git#${refs[1].substr(0, 8)}`
- }
- }
- }, 'version and from fields are correct in git-based pkglock dep')
- var childPackageJSON = require(path.join(parentNodeModulesPath, 'child', 'package.json'))
- t.equal(
- childPackageJSON._resolved,
- 'git://localhost:' + common.gitPort + '/child.git#' + refs[1],
- "Child package wasn't updated"
- )
- t.end()
- })
- })
-})
-
-test('clean', function (t) {
- gitDaemon.on('close', t.end)
- process.kill(gitDaemonPID)
-})
-
-function prepareChildAndGetRefs (cb) {
- var opts = { cwd: childPath, env: { PATH: process.env.PATH } }
- chain([
- [fs.writeFile, path.join(childPath, 'README.md'), ''],
- git.chainableExec(['add', 'README.md'], opts),
- git.chainableExec(['commit', '-m', 'Add README'], opts),
- git.chainableExec(['log', '--pretty=format:"%H"', '-2'], opts)
- ], function (err) {
- if (err) { return cb(err) }
- var gitLogStdout = arguments[arguments.length - 1]
- var refs = gitLogStdout[gitLogStdout.length - 1].split('\n').map(function (ref) {
- return ref.match(/^"(.+)"$/)[1]
- }).reverse() // Reverse refs order: last, first -> first, last
- cb(null, refs)
- })
-}
-
-function initializeGit (cb) {
- git = require('../../lib/utils/git')
- common.makeGitRepo({
- path: childPath,
- commands: [startGitDaemon]
- }, cb)
-}
-
-function startGitDaemon (cb) {
- var daemon = git.spawn(
- [
- 'daemon',
- '--verbose',
- '--listen=localhost',
- '--export-all',
- '--base-path=' + mockPath, // Path to the dir that contains child.git
- '--reuseaddr',
- '--port=' + common.gitPort
- ],
- {
- cwd: parentPath,
- env: process.env,
- stdio: ['pipe', 'pipe', 'pipe']
- }
- )
- daemon.stderr.on('data', function findChild (c) {
- var cpid = c.toString().match(/^\[(\d+)\]/)
- if (cpid[1]) {
- this.removeListener('data', findChild)
- cb(null, [daemon, cpid[1]])
- }
- })
-}
diff --git a/deps/npm/test/tap/install-test-cli-with-broken-package-lock.js b/deps/npm/test/tap/install-test-cli-with-broken-package-lock.js
deleted file mode 100644
index 3c1a56131b..0000000000
--- a/deps/npm/test/tap/install-test-cli-with-broken-package-lock.js
+++ /dev/null
@@ -1,118 +0,0 @@
-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 = common.pkg
-
-var EXEC_OPTS = { cwd: pkg }
-
-var json = {
- name: 'install-test-cli-with-broken-package-lock',
- description: 'fixture',
- version: '0.0.0',
- dependencies: {
- optimist: '0.6.0'
- }
-}
-
-var brokenLockfile = {
- name: 'install-test-cli-with-broken-package-lock',
- version: '0.0.0',
- lockfileVersion: 1,
- requires: true,
- dependencies: {
- optimist: {
- version: '0.6.0',
- resolved: 'https://registry.npmjs.org/optimist/-/optimist-0.6.0.tgz',
- integrity: 'sha1-aUJIJvNAX3nxQub8PZrljU27kgA=',
- requires: {
- minimist: '~0.0.1',
- wordwrap: '~0.0.2'
- }
- },
- wordwrap: {
- version: '0.0.3',
- resolved: 'https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz',
- integrity: 'sha1-o9XabNXAvAAI03I0u68b7WMFkQc='
- }
- }
-}
-
-var expected = {
- name: 'install-test-cli-with-broken-package-lock',
- version: '0.0.0',
- lockfileVersion: 1,
- requires: true,
- dependencies: {
- minimist: {
- version: '0.0.10',
- resolved: 'https://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz',
- integrity: 'sha1-3j+YVD2/lggr5IrRoMfNqDYwHc8='
- },
- optimist: {
- version: '0.6.0',
- resolved: 'https://registry.npmjs.org/optimist/-/optimist-0.6.0.tgz',
- integrity: 'sha1-aUJIJvNAX3nxQub8PZrljU27kgA=',
- requires: {
- minimist: '~0.0.1',
- wordwrap: '~0.0.2'
- }
- },
- wordwrap: {
- version: '0.0.3',
- resolved: 'https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz',
- integrity: 'sha1-o9XabNXAvAAI03I0u68b7WMFkQc='
- }
- }
-}
-
-test('setup', function (t) {
- setup()
- t.end()
-})
-
-test('\'npm install-test\' should repair package-lock.json', function (t) {
- common.npm(['install-test'], EXEC_OPTS, function (err, code, stderr, stdout) {
- if (err) throw err
- t.comment(stdout.trim())
- t.comment(stderr.trim())
- t.is(code, 0, 'npm install did not raise error code')
- var lockfile = JSON.parse(fs.readFileSync(path.join(pkg, 'package-lock.json')))
- t.same(
- lockfile,
- expected,
- 'package-lock.json should be repaired'
- )
- 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)
- )
- fs.writeFileSync(
- path.join(pkg, 'package-lock.json'),
- JSON.stringify(brokenLockfile, null, 2)
- )
- process.chdir(pkg)
-}
-
-function cleanup () {
- process.chdir(osenv.tmpdir())
- rimraf.sync(pkg)
-}
diff --git a/deps/npm/test/tap/install-test-cli-without-package-lock.js b/deps/npm/test/tap/install-test-cli-without-package-lock.js
deleted file mode 100644
index 603043af8f..0000000000
--- a/deps/npm/test/tap/install-test-cli-without-package-lock.js
+++ /dev/null
@@ -1,64 +0,0 @@
-var fs = require('graceful-fs')
-var path = require('path')
-
-var mkdirp = require('mkdirp')
-var test = require('tap').test
-
-var common = require('../common-tap.js')
-
-var pkg = common.pkg
-
-var EXEC_OPTS = { cwd: pkg }
-
-var json = {
- name: 'install-test-cli-without-package-lock',
- description: 'fixture',
- version: '0.0.0',
- dependencies: {
- dependency: 'file:./dependency'
- }
-}
-
-var dependency = {
- name: '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, 'node_modules'))
- fs.writeFileSync(
- path.join(pkg, 'package.json'),
- JSON.stringify(json, null, 2)
- )
-
- // Disable package-lock
- fs.writeFileSync(
- path.join(pkg, '.npmrc'),
- 'package-lock=false\n'
- )
- t.end()
-})
-
-test('\'npm install-test\' should not generate package-lock.json.*', function (t) {
- common.npm(['install-test'], EXEC_OPTS, function (err, code, stderr, stdout) {
- if (err) throw err
- t.comment(stdout.trim())
- t.comment(stderr.trim())
- t.is(code, 0, 'npm install did not raise error code')
- var files = fs.readdirSync(pkg).filter(function (f) {
- return f.indexOf('package-lock.json.') === 0
- })
- t.notOk(
- files.length > 0,
- 'package-lock.json.* should not be generated: ' + files
- )
- t.end()
- })
-})
diff --git a/deps/npm/test/tap/install-windows-newlines.js b/deps/npm/test/tap/install-windows-newlines.js
deleted file mode 100644
index b56c7645eb..0000000000
--- a/deps/npm/test/tap/install-windows-newlines.js
+++ /dev/null
@@ -1,90 +0,0 @@
-var fs = require('graceful-fs')
-var path = require('path')
-var existsSync = fs.existsSync || path.existsSync
-
-var mkdirp = require('mkdirp')
-var rimraf = require('rimraf')
-var test = require('tap').test
-
-var common = require('../common-tap.js')
-
-var pkg = common.pkg
-
-var EXEC_OPTS = { cwd: pkg, stdio: [0, 1, 2] }
-
-var json = {
- name: 'install-windows-newlines',
- description: 'fixture',
- version: '0.0.0',
- dependencies: {
- 'cli-dependency': 'file:cli-dependency'
- }
-}
-
-var dependency = {
- name: 'cli-dependency',
- description: 'fixture',
- version: '0.0.0',
- bin: {
- hashbang: './hashbang.js',
- nohashbang: './nohashbang.js'
- }
-}
-
-test('setup', function (t) {
- cleanup()
- mkdirp.sync(path.join(pkg, 'cli-dependency'))
- fs.writeFileSync(
- path.join(pkg, 'cli-dependency', 'package.json'),
- JSON.stringify(dependency, null, 2)
- )
- fs.writeFileSync(
- path.join(pkg, 'cli-dependency', 'hashbang.js'),
- '#!/usr/bin/env node\r\nconsole.log(\'Hello, world!\')\r\n'
- )
- fs.writeFileSync(
- path.join(pkg, 'cli-dependency', 'nohashbang.js'),
- '\'use strict\'\r\nconsole.log(\'Goodbye, world!\')\r\n'
- )
-
- mkdirp.sync(path.join(pkg, 'node_modules'))
- fs.writeFileSync(
- path.join(pkg, 'package.json'),
- JSON.stringify(json, null, 2)
- )
-
- return common.npm(['install'], EXEC_OPTS).spread((code) => {
- t.equal(code, 0, 'npm install did not raise error code')
- t.ok(
- existsSync(path.resolve(pkg, 'node_modules/.bin/hashbang')),
- 'hashbang installed'
- )
- t.ok(
- existsSync(path.resolve(pkg, 'node_modules/.bin/nohashbang')),
- 'nohashbang installed'
- )
- t.notOk(
- fs.readFileSync(
- path.resolve(pkg, 'node_modules/cli-dependency/hashbang.js'),
- 'utf8'
- ).includes('node\r\n'),
- 'hashbang dependency cli newlines converted'
- )
- t.ok(
- fs.readFileSync(
- path.resolve(pkg, 'node_modules/cli-dependency/nohashbang.js'),
- 'utf8'
- ).includes('\r\n'),
- 'nohashbang dependency cli newlines retained'
- )
- })
-})
-
-test('cleanup', function (t) {
- cleanup()
- t.end()
-})
-
-function cleanup () {
- rimraf.sync(pkg)
-}
diff --git a/deps/npm/test/tap/install-with-dev-dep-duplicate.js b/deps/npm/test/tap/install-with-dev-dep-duplicate.js
deleted file mode 100644
index 7d8586f47d..0000000000
--- a/deps/npm/test/tap/install-with-dev-dep-duplicate.js
+++ /dev/null
@@ -1,81 +0,0 @@
-var fs = require('graceful-fs')
-var path = require('path')
-
-var mr = require('npm-registry-mock')
-var test = require('tap').test
-
-var common = require('../common-tap.js')
-var npm = require('../../')
-
-var pkg = common.pkg
-
-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',
- invalid: true
- }
- }
-}
-
-test('prefers version from dependencies over devDependencies', function (t) {
- t.plan(1)
-
- mr({ port: common.port }, function (er, s) {
- setup(function (err) {
- if (err) {
- throw err
- }
-
- npm.install('.', function (err) {
- if (err) {
- throw err
- }
-
- npm.commands.ls([], true, function (err, _, results) {
- if (err) {
- throw err
- }
-
- // these contain full paths so we can't do an exact match
- // with them
- delete results.problems
- delete results.dependencies.underscore.problems
- t.deepEqual(results, expected)
- s.close()
- t.end()
- })
- })
- })
- })
-})
-
-function setup (cb) {
- fs.writeFileSync(
- path.join(pkg, 'package.json'),
- JSON.stringify(json, null, 2)
- )
- process.chdir(pkg)
-
- var opts = {
- cache: common.cache,
- registry: common.registry
- }
- npm.load(opts, cb)
-}
diff --git a/deps/npm/test/tap/install-without-registry-config.js b/deps/npm/test/tap/install-without-registry-config.js
deleted file mode 100644
index 852bd777ce..0000000000
--- a/deps/npm/test/tap/install-without-registry-config.js
+++ /dev/null
@@ -1,35 +0,0 @@
-const t = require('tap')
-const { pkg, npm } = require('../common-tap.js')
-const { writeFileSync, statSync, readFileSync } = require('fs')
-const mkdirp = require('mkdirp')
-const proj = pkg + '/project'
-const dep = pkg + '/dep'
-mkdirp.sync(proj)
-mkdirp.sync(dep)
-writeFileSync(dep + '/package.json', JSON.stringify({
- name: 'dependency',
- version: '1.2.3'
-}))
-writeFileSync(proj + '/package.json', JSON.stringify({
- name: 'project',
- version: '4.2.0'
-}))
-
-const runTest = t => npm([
- 'install',
- '../dep',
- '--no-registry'
-], { cwd: proj }).then(([code, out, err]) => {
- t.equal(code, 0)
- t.match(out, /^\+ dependency@1\.2\.3\n.* 1 package in [0-9.]+m?s\n$/)
- t.equal(err, '')
- const data = readFileSync(proj + '/node_modules/dependency/package.json', 'utf8')
- t.same(JSON.parse(data), {
- name: 'dependency',
- version: '1.2.3'
- }, 'dep got installed')
- t.ok(statSync(proj + '/package-lock.json').isFile(), 'package-lock exists')
-})
-
-t.test('install without a registry, no package lock', t => runTest(t))
-t.test('install without a registry, with package lock', t => runTest(t))
diff --git a/deps/npm/test/tap/install.fund.js b/deps/npm/test/tap/install.fund.js
deleted file mode 100644
index fca5fb3afd..0000000000
--- a/deps/npm/test/tap/install.fund.js
+++ /dev/null
@@ -1,99 +0,0 @@
-'use strict'
-
-const { test } = require('tap')
-const { getPrintFundingReport } = require('../../lib/install/fund')
-
-test('message when there are no funding found', (t) => {
- t.equal(
- getPrintFundingReport({}),
- '',
- 'should not print any message if missing info'
- )
- t.equal(
- getPrintFundingReport({
- name: 'foo',
- version: '1.0.0',
- dependencies: {}
- }),
- '',
- 'should not print any message if package has no dependencies'
- )
- t.equal(
- getPrintFundingReport({
- fund: true,
- idealTree: {
- name: 'foo',
- version: '1.0.0',
- dependencies: {
- bar: {},
- lorem: {}
- }
- }
- }),
- '',
- 'should not print any message if no package has funding info'
- )
- t.end()
-})
-
-test('print appropriate message for a single package', (t) => {
- t.equal(
- getPrintFundingReport({
- fund: true,
- idealTree: {
- name: 'foo',
- version: '1.0.0',
- children: [
- {
- package: {
- name: 'bar',
- version: '1.0.0',
- funding: { type: 'foo', url: 'http://example.com' }
- }
- }
- ]
- }
- }).replace(/[\r\n]+/g, '\n'),
- `\n1 package is looking for funding\n run \`npm fund\` for details\n`,
- 'should print single package message'
- )
- t.end()
-})
-
-test('print appropriate message for many packages', (t) => {
- t.equal(
- getPrintFundingReport({
- fund: true,
- idealTree: {
- name: 'foo',
- version: '1.0.0',
- children: [
- {
- package: {
- name: 'bar',
- version: '1.0.0',
- funding: { type: 'foo', url: 'http://example.com' }
- }
- },
- {
- package: {
- name: 'lorem',
- version: '1.0.0',
- funding: { type: 'foo', url: 'http://example.com' }
- }
- },
- {
- package: {
- name: 'ipsum',
- version: '1.0.0',
- funding: { type: 'foo', url: 'http://example.com' }
- }
- }
- ]
- }
- }).replace(/[\r\n]+/g, '\n'),
- `\n3 packages are looking for funding\n run \`npm fund\` for details\n`,
- 'should print many package message'
- )
- t.end()
-})
diff --git a/deps/npm/test/tap/invalid-cmd-exit-code.js b/deps/npm/test/tap/invalid-cmd-exit-code.js
deleted file mode 100644
index b9a42f1be4..0000000000
--- a/deps/npm/test/tap/invalid-cmd-exit-code.js
+++ /dev/null
@@ -1,34 +0,0 @@
-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 (err, code, stdout, stderr) {
- if (err) throw err
- t.ok(code, 'exit code should not be zero')
- if (stdout.trim()) t.comment(stdout.trim())
- if (stderr.trim()) t.comment(stderr.trim())
- t.end()
- })
-})
-
-test('npm help should return exit code 0', function (t) {
- common.npm(['help'], opts, function (err, code, stdout, stderr) {
- if (err) throw err
- t.equal(code, 0, 'exit code should be 0')
- if (stdout.trim()) t.comment(stdout.trim())
- if (stderr.trim()) t.comment(stderr.trim())
- t.end()
- })
-})
-
-test('npm help fadf should return exit code 0', function (t) {
- common.npm(['help', 'fadf'], opts, function (err, code, stdout, stderr) {
- if (err) throw err
- t.equal(code, 0, 'exit code should be 0')
- if (stdout.trim()) t.comment(stdout.trim())
- if (stderr.trim()) t.comment(stderr.trim())
- t.end()
- })
-})
diff --git a/deps/npm/test/tap/invalid-dep-version-filtering.js b/deps/npm/test/tap/invalid-dep-version-filtering.js
deleted file mode 100644
index f2f175b24e..0000000000
--- a/deps/npm/test/tap/invalid-dep-version-filtering.js
+++ /dev/null
@@ -1,135 +0,0 @@
-'use strict'
-var path = require('path')
-var test = require('tap').test
-var mr = require('npm-registry-mock')
-var common = require('../common-tap')
-var Tacks = require('tacks')
-var File = Tacks.File
-var Dir = Tacks.Dir
-
-var testdir = common.pkg
-var cachedir = common.cache
-
-var fixture = new Tacks(Dir({
- cache: Dir(),
- node_modules: Dir(),
- tarballs: Dir({
- 'pkgA.tgz': File(Buffer.from(
- '1f8b0800000000000003edcfcf0a0221100670cf3ec5e0396cfcb703bd8d' +
- '842cb5e4ca5a5da2776f5da153b78408fc5d3e6684e133f9e3e4c7b04f35' +
- 'e539cf9135868883b5509206b725ea3a6f9c01a634598d8e48134365d0e0' +
- 'fadebac827b77cf5cb5ae5db3bf52bf0ce3ff1e00022fa4b100710691abd' +
- 'd895cd3d2cf934c7b25412250afee4bfaeda755dd735f40211b5bced0008' +
- '0000',
- 'hex'
- )),
- 'pkgB1.tgz': File(Buffer.from(
- '1f8b0800000000000003edcfc10a0221140550d77ec5c375d8d3d111fa1b' +
- '0b196ac891b16913fd7be308adda2544f0cee6e25d3caec99f463f847daa' +
- '292f798aac3144ec8d8192aeb75ba2aeef8ded8029ed8c46eb1c1a86aa43' +
- 'bd76d87ac8274bbef9799df2ed9dfa1578e79f78700011fd35880388340e' +
- '47b12bcd3dccf93cc5522a8912057ff25f4f258410d2d00b247d22080008' +
- '0000',
- 'hex'
- ))
- })
-}))
-
-var pkgAtgz = path.join(testdir, 'tarballs', 'pkgA.tgz')
-var pkgB1tgz = path.join(testdir, 'tarballs', 'pkgB1.tgz')
-
-var server
-
-var pkgA = {
- name: 'pkg-a',
- 'dist-tags': {
- latest: '1.0.0'
- },
- versions: {
- '1.0.0': {
- name: 'pkg-a',
- version: '1.0.0',
- dependencies: {
- 'pkg-b': '1.0.0'
- },
- dist: {
- shasum: 'dc5471ce0439f0f47749bb01473cad4570cc7dc5',
- tarball: common.registry + '/pkg-a/-/pkg-a-1.0.0.tgz'
- }
- }
- }
-}
-
-var pkgB = {
- name: 'pkg-b',
- 'dist-tags': {
- latest: '1.0.0'
- },
- versions: {
- '1.0.0': {
- name: 'pkg-b',
- version: '1.0.0',
- dist: {
- shasum: '53031aa2cf774c0e841c6fdbbe54c13825cd5640',
- tarball: common.registry + '/pkg-b/-/pkg-b-1.0.0.tgz'
- }
- },
- '1.0.0rc1': {
- name: 'pkg-b',
- version: '1.0.0rc1',
- dist: {
- shasum: '7f4b1bf680e3a31113d77619b4dc7c3b4c7dc15c',
- tarball: common.registry + '/pkg-b/-/pkg-b-1.0.0-rc1.tgz'
- }
- }
- }
-}
-
-function setup () {
- cleanup()
- fixture.create(testdir)
-}
-function cleanup () {
- fixture.remove(testdir)
-}
-
-test('setup', function (t) {
- setup()
- mr({ port: common.port, throwOnUnmatched: true }, function (err, s) {
- t.ifError(err, 'registry mocked successfully')
- server = s
- t.end()
- })
-})
-
-test('invalid versions should be ignored', function (t) {
- server.get('/pkg-a').reply(200, pkgA)
- server.get('/pkg-b').reply(200, pkgB)
- server.get('/pkg-a/-/pkg-a-1.0.0.tgz').replyWithFile(200, pkgAtgz)
- server.get('/pkg-b/-/pkg-b-1.0.0.tgz').replyWithFile(200, pkgB1tgz)
-
- common.npm(
- [
- 'install',
- '--cache', cachedir,
- '--registry', common.registry,
- '--fetch-retries=0',
- 'pkg-a@1.0.0'
- ],
- {cwd: testdir},
- function (err, code, stdout, stderr) {
- if (err) throw err
- t.equal(code, 0, 'install succeded')
- t.comment(stdout.trim())
- t.comment(stderr.trim())
- server.done()
- t.end()
- }
- )
-})
-
-test('cleanup', function (t) {
- server.close()
- cleanup()
- t.end()
-})
diff --git a/deps/npm/test/tap/is-fs-access-available.js b/deps/npm/test/tap/is-fs-access-available.js
deleted file mode 100644
index 2e5c7edc98..0000000000
--- a/deps/npm/test/tap/is-fs-access-available.js
+++ /dev/null
@@ -1,55 +0,0 @@
-'use strict'
-var fs = require('fs')
-var test = require('tap').test
-var requireInject = require('require-inject')
-var semver = require('semver')
-
-var globalProcess = global.process
-
-function loadIsFsAccessAvailable (newProcess, newFs) {
- global.process = Object.assign({}, global.process, newProcess)
- var mocks = {fs: Object.assign({}, fs, newFs)}
- var isFsAccessAvailable = requireInject('../../lib/install/is-fs-access-available.js', mocks)
- global.process = globalProcess
- return isFsAccessAvailable
-}
-
-var fsWithAccess = {access: function () {}}
-var fsWithoutAccess = {access: undefined}
-
-if (semver.lt(process.version, '0.12.0')) {
- test('skipping', function (t) {
- t.pass('skipping all tests on < 0.12.0 due to process not being injectable')
- t.end()
- })
-} else {
- test('mac + !fs.access', function (t) {
- var isFsAccessAvailable = loadIsFsAccessAvailable({platform: 'darwin'}, fsWithoutAccess)
- t.is(isFsAccessAvailable, false, 'not available')
- t.end()
- })
-
- test('mac + fs.access', function (t) {
- var isFsAccessAvailable = loadIsFsAccessAvailable({platform: 'darwin'}, fsWithAccess)
- t.is(isFsAccessAvailable, true, 'available')
- t.end()
- })
-
- test('windows + !fs.access', function (t) {
- var isFsAccessAvailable = loadIsFsAccessAvailable({platform: 'win32'}, fsWithoutAccess)
- t.is(isFsAccessAvailable, false, 'not available')
- t.end()
- })
-
- test('windows + fs.access + node 0.12.7', function (t) {
- var isFsAccessAvailable = loadIsFsAccessAvailable({platform: 'win32', version: '0.12.7'}, fsWithAccess)
- t.is(isFsAccessAvailable, false, 'not available')
- t.end()
- })
-
- test('windows + fs.access + node 2.4.0', function (t) {
- var isFsAccessAvailable = loadIsFsAccessAvailable({platform: 'win32', version: '2.4.0'}, fsWithAccess)
- t.is(isFsAccessAvailable, true, 'available')
- t.end()
- })
-}
diff --git a/deps/npm/test/tap/is-registry.js b/deps/npm/test/tap/is-registry.js
deleted file mode 100644
index 832eb537d3..0000000000
--- a/deps/npm/test/tap/is-registry.js
+++ /dev/null
@@ -1,27 +0,0 @@
-'use strict'
-const test = require('tap').test
-const npa = require('npm-package-arg')
-const isRegistry = require('../../lib/utils/is-registry.js')
-
-test('current npa', (t) => {
- t.is(Boolean(isRegistry(npa('foo@1.0.0'))), true, 'version')
- t.is(Boolean(isRegistry(npa('foo@^1.0.0'))), true, 'range')
- t.is(Boolean(isRegistry(npa('foo@test'))), true, 'tag')
- t.is(Boolean(isRegistry(npa('foo@git://foo.bar/test.git'))), false, 'git')
- t.is(Boolean(isRegistry(npa('foo@foo/bar'))), false, 'github')
- t.is(Boolean(isRegistry(npa('foo@http://example.com/example.tgz'))), false, 'remote')
- t.is(Boolean(isRegistry(npa('foo@file:example.tgz'))), false, 'file')
- t.is(Boolean(isRegistry(npa('foo@file:example/'))), false, 'dir')
- t.done()
-})
-
-test('legacy spec data', (t) => {
- t.is(Boolean(isRegistry({type: 'version'})), true, 'version')
- t.is(Boolean(isRegistry({type: 'range'})), true, 'range')
- t.is(Boolean(isRegistry({type: 'tag'})), true, 'tag')
- t.is(Boolean(isRegistry({type: 'git'})), false, 'git')
- t.is(Boolean(isRegistry({type: 'file'})), false, 'file')
- t.is(Boolean(isRegistry({type: 'directory'})), false, 'directory')
- t.is(Boolean(isRegistry({type: 'remote'})), false, 'remote')
- t.done()
-})
diff --git a/deps/npm/test/tap/it.js b/deps/npm/test/tap/it.js
deleted file mode 100644
index bb59bc6f5e..0000000000
--- a/deps/npm/test/tap/it.js
+++ /dev/null
@@ -1,65 +0,0 @@
-var join = require('path').join
-var statSync = require('graceful-fs').statSync
-var writeFileSync = require('graceful-fs').writeFileSync
-
-var mr = require('npm-registry-mock')
-var rimraf = require('rimraf')
-var test = require('tap').test
-
-var common = require('../common-tap')
-
-var pkg = common.pkg
-var installed = join(pkg, 'node_modules', 'underscore', 'package.json')
-
-var json = {
- name: 'npm-it-test',
- dependencies: {
- underscore: '1.5.1'
- },
- scripts: {
- test: 'echo hax'
- }
-}
-
-test('run up the mock registry', function (t) {
- mr({ port: common.port }, function (err, s) {
- if (err) throw err
- t.parent.teardown(() => s.close())
- t.end()
- })
-})
-
-const check = args => t =>
- common.npm(args.concat('--registry=' + common.registry), { cwd: pkg })
- .then(([code, stdout, stderr]) => {
- t.equal(code, 0, 'command ran without error')
- t.ok(statSync(installed), 'package was installed')
- t.equal(require(installed).version, '1.5.1', 'underscore got installed as expected')
- t.match(stdout, /hax/, 'found expected test output')
- t.notOk(stderr, 'stderr should be empty')
- })
-
-test('npm install-test', function (t) {
- t.plan(2)
- t.test('setup', setup)
- t.test('check', check(['install-test', '--no-shrinkwrap']))
-})
-
-test('npm it (the form most people will use)', function (t) {
- t.plan(2)
- t.test('setup', setup)
- t.test('check', check(['it']))
-})
-
-function setup (t) {
- t.test('destroy', t => {
- t.plan(2)
- rimraf(join(pkg, 'node_modules'), () => t.pass('node_modules'))
- rimraf(join(pkg, 'package-lock.json'), () => t.pass('lock file'))
- })
- t.test('create', t => {
- writeFileSync(join(pkg, 'package.json'), JSON.stringify(json, null, 2))
- t.end()
- })
- t.end()
-}
diff --git a/deps/npm/test/tap/legacy-ignore-nested-nm.js b/deps/npm/test/tap/legacy-ignore-nested-nm.js
deleted file mode 100644
index 6a57b72b60..0000000000
--- a/deps/npm/test/tap/legacy-ignore-nested-nm.js
+++ /dev/null
@@ -1,64 +0,0 @@
-'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 = common.pkg
-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)
-}
diff --git a/deps/npm/test/tap/legacy-missing-bindir.js b/deps/npm/test/tap/legacy-missing-bindir.js
deleted file mode 100644
index 398ef0e7ac..0000000000
--- a/deps/npm/test/tap/legacy-missing-bindir.js
+++ /dev/null
@@ -1,78 +0,0 @@
-'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 = common.pkg
-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
- 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
- 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)
-}
diff --git a/deps/npm/test/tap/legacy-no-auth-leak.js b/deps/npm/test/tap/legacy-no-auth-leak.js
deleted file mode 100644
index ce1adaeca7..0000000000
--- a/deps/npm/test/tap/legacy-no-auth-leak.js
+++ /dev/null
@@ -1,74 +0,0 @@
-'use strict'
-var test = require('tap').test
-var common = require('../common-tap.js')
-var basepath = common.pkg
-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)
-}
diff --git a/deps/npm/test/tap/legacy-platform-all.js b/deps/npm/test/tap/legacy-platform-all.js
deleted file mode 100644
index 01c7be7ec1..0000000000
--- a/deps/npm/test/tap/legacy-platform-all.js
+++ /dev/null
@@ -1,74 +0,0 @@
-'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 = common.pkg
-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',
- 'arm64',
- '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)
-}
diff --git a/deps/npm/test/tap/legacy-platform.js b/deps/npm/test/tap/legacy-platform.js
deleted file mode 100644
index 619d2e4330..0000000000
--- a/deps/npm/test/tap/legacy-platform.js
+++ /dev/null
@@ -1,64 +0,0 @@
-'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 = common.pkg
-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)
-}
diff --git a/deps/npm/test/tap/legacy-private.js b/deps/npm/test/tap/legacy-private.js
deleted file mode 100644
index 44a1094cd0..0000000000
--- a/deps/npm/test/tap/legacy-private.js
+++ /dev/null
@@ -1,58 +0,0 @@
-'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 = common.pkg
-var fixturepath = path.resolve(basepath, 'npm-test-private')
-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-private',
- version: '9.9.9-9',
- homepage: 'http://www.youtube.com/watch?v=1MLry6Cn_D4',
- private: 'true'
- })
- })
-)
-
-test('setup', function (t) {
- setup()
- t.done()
-})
-
-test('private', function (t) {
- common.npm(['install', 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')
- 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)
-}
diff --git a/deps/npm/test/tap/legacy-test-package.js b/deps/npm/test/tap/legacy-test-package.js
deleted file mode 100644
index 3c807e5049..0000000000
--- a/deps/npm/test/tap/legacy-test-package.js
+++ /dev/null
@@ -1,70 +0,0 @@
-'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 = common.pkg
-var fixturepath = path.resolve(basepath, 'npm-test-test-package')
-var modulepath = path.resolve(basepath, 'node_modules')
-var installedpath = path.resolve(modulepath, 'npm-test-test-package')
-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-test-package',
- author: 'Testy McMock',
- version: '1.2.3-99-b',
- description: "This is a test package used for debugging. It has some random data and that's all."
- })
- })
-)
-
-test('setup', function (t) {
- setup()
- t.done()
-})
-
-test('test-package', 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) {
- if (err) throw err
- t.is(code, 0, 'npm test w/o test is ok')
- 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)
-}
diff --git a/deps/npm/test/tap/lifecycle-INIT_CWD.js b/deps/npm/test/tap/lifecycle-INIT_CWD.js
deleted file mode 100644
index fbedd3849c..0000000000
--- a/deps/npm/test/tap/lifecycle-INIT_CWD.js
+++ /dev/null
@@ -1,36 +0,0 @@
-var fs = require('fs')
-var path = require('path')
-
-var mkdirp = require('mkdirp')
-var test = require('tap').test
-
-var common = require('../common-tap.js')
-
-var pkg = common.pkg
-var subdir = path.resolve(pkg, 'subdir')
-
-var json = {
- name: 'init-cwd',
- version: '1.0.0',
- scripts: {
- initcwd: process.platform === 'win32' ? 'echo %INIT_CWD%' : 'echo "$INIT_CWD"'
- }
-}
-
-test('setup', function (t) {
- mkdirp.sync(subdir)
- fs.writeFileSync(
- path.join(pkg, 'package.json'),
- JSON.stringify(json, null, 2)
- )
- t.end()
-})
-
-test('make sure the env.INIT_CWD is correct', t =>
- common.npm(['run-script', 'initcwd'], { cwd: subdir })
- .then(([code, stdout, stderr]) => {
- t.equal(code, 0, 'exit code')
- stdout = stdout.trim().split(/\r|\n/).pop()
- var actual = stdout
- t.equal(actual, subdir)
- }))
diff --git a/deps/npm/test/tap/lifecycle-order.js b/deps/npm/test/tap/lifecycle-order.js
deleted file mode 100644
index ac6c07925c..0000000000
--- a/deps/npm/test/tap/lifecycle-order.js
+++ /dev/null
@@ -1,33 +0,0 @@
-var fs = require('graceful-fs')
-var path = require('path')
-var test = require('tap').test
-var common = require('../common-tap.js')
-var pkg = common.pkg
-
-var json = {
- name: 'lifecycle-order',
- version: '1.0.0',
- scripts: {
- preinstall: 'node -e "var fs = require(\'fs\'); fs.openSync(\'preinstall-step\', \'w+\'); if (fs.existsSync(\'node_modules\')) { throw \'node_modules exists on preinstall\' }"',
- install: 'node -e "var fs = require(\'fs\'); if (fs.existsSync(\'preinstall-step\')) { fs.openSync(\'install-step\', \'w+\') } else { throw \'Out of order\' }"',
- postinstall: 'node -e "var fs = require(\'fs\'); if (fs.existsSync(\'install-step\')) { fs.openSync(\'postinstall-step\', \'w+\') } else { throw \'Out of order\' }"'
- }
-}
-
-test('setup', function (t) {
- fs.writeFileSync(
- path.join(pkg, 'package.json'),
- JSON.stringify(json, null, 2)
- )
- t.end()
-})
-
-test('lifecycle scripts execute in the proper order', t =>
- common.npm('install', {cwd: pkg}).then(([code, stdout, stderr]) => {
- t.is(code, 0, 'no error')
-
- // All three files should exist
- t.ok(fs.existsSync(path.join(pkg, 'preinstall-step')), 'preinstall ok')
- t.ok(fs.existsSync(path.join(pkg, 'install-step')), 'install ok')
- t.ok(fs.existsSync(path.join(pkg, 'postinstall-step')), 'postinstall ok')
- }))
diff --git a/deps/npm/test/tap/lifecycle-path.js b/deps/npm/test/tap/lifecycle-path.js
deleted file mode 100644
index 70fb839197..0000000000
--- a/deps/npm/test/tap/lifecycle-path.js
+++ /dev/null
@@ -1,210 +0,0 @@
-var fs = require('fs')
-var path = require('path')
-
-var mkdirp = require('mkdirp')
-var rimraf = require('rimraf')
-var which = require('which')
-var test = require('tap').test
-
-var common = require('../common-tap.js')
-var isWindows = require('../../lib/utils/is-windows.js')
-
-var pkg = common.pkg
-
-var PATH
-if (isWindows) {
- // On Windows the 'comspec' environment variable is used,
- // so cmd.exe does not need to be on the path.
- PATH = path.dirname(process.env.ComSpec)
-} else {
- // On non-Windows, without the path to the shell, nothing usually works.
- PATH = '/bin:/usr/bin'
-}
-
-var systemNode = which.sync('node', { nothrow: true, path: PATH })
-// the path to the system wide node (null if none)
-
-test('setup', function (t) {
- fs.writeFileSync(
- path.join(pkg, 'package.json'),
- JSON.stringify({}, null, 2)
- )
- t.end()
-})
-
-test('make sure the path is correct, without directory of current node', function (t) {
- checkPath({
- withDirOfCurrentNode: false,
- prependNodePathSetting: false
- }, t)
-})
-
-test('make sure the path is correct, with directory of current node', function (t) {
- checkPath({
- withDirOfCurrentNode: true,
- prependNodePathSetting: false
- }, t)
-})
-
-test('make sure the path is correct, with directory of current node but ignored node path', function (t) {
- checkPath({
- withDirOfCurrentNode: true,
- prependNodePathSetting: true
- }, t)
-})
-
-test('make sure the path is correct, without directory of current node and automatic detection', function (t) {
- checkPath({
- withDirOfCurrentNode: false,
- prependNodePathSetting: 'auto'
- }, t)
-})
-
-test('make sure the path is correct, with directory of current node and automatic detection', function (t) {
- checkPath({
- withDirOfCurrentNode: true,
- prependNodePathSetting: 'auto'
- }, t)
-})
-
-test('make sure the path is correct, without directory of current node and warn-only detection', function (t) {
- checkPath({
- withDirOfCurrentNode: false,
- prependNodePathSetting: 'warn-only'
- }, t)
-})
-
-test('make sure the path is correct, with directory of current node and warn-only detection', function (t) {
- checkPath({
- withDirOfCurrentNode: true,
- prependNodePathSetting: 'warn-only'
- }, t)
-})
-
-test('make sure there is no warning with a symlinked node and warn-only detection', {
- skip: isWindows && 'symlinks are weird on windows'
-}, function (t) {
- checkPath({
- withDirOfCurrentNode: false,
- extraNode: true,
- prependNodePathSetting: 'warn-only',
- symlinkNodeInsteadOfCopying: true
- }, t)
-})
-
-test('make sure the path is correct, with directory of current node and warn-only detection and an extra node in path', function (t) {
- checkPath({
- withDirOfCurrentNode: false,
- extraNode: true,
- prependNodePathSetting: 'warn-only'
- }, t)
-})
-
-function checkPath (testconfig, t) {
- var withDirOfCurrentNode = testconfig.withDirOfCurrentNode
- var prependNodePathSetting = testconfig.prependNodePathSetting
- var symlinkedNode = testconfig.symlinkNodeInsteadOfCopying
- var extraNode = testconfig.extraNode
-
- var newPATH = PATH
- var currentNodeExecPath = process.execPath
- if (withDirOfCurrentNode) {
- var newNodeExeDir = path.join(pkg, 'node-bin', 'my_bundled_node')
- mkdirp.sync(newNodeExeDir)
- currentNodeExecPath = path.join(newNodeExeDir, path.basename(process.execPath))
- rimraf.sync(currentNodeExecPath)
-
- if (!symlinkedNode) {
- fs.writeFileSync(currentNodeExecPath, fs.readFileSync(process.execPath))
- fs.chmodSync(currentNodeExecPath, '755')
- } else {
- fs.symlinkSync(process.execPath, currentNodeExecPath)
- }
- }
-
- if (!withDirOfCurrentNode) {
- // Ensure that current node interpreter will be found in the PATH,
- // so the PATH won't be prepended with its parent directory
- newPATH = [path.dirname(process.execPath), PATH].join(process.platform === 'win32' ? ';' : ':')
- }
-
- common.npm(['run-script', 'env'], {
- cwd: pkg,
- nodeExecPath: currentNodeExecPath,
- env: {
- PATH: newPATH,
- npm_config_scripts_prepend_node_path: prependNodePathSetting
- },
- stdio: [ 0, 'pipe', 'pipe' ]
- }, function (er, code, stdout, stderr) {
- if (er) throw er
- if (!stderr.match(/^(npm WARN.*)?\n*$/)) console.error(stderr)
- t.equal(code, 0, 'exit code')
- var lineMatch = function (line) {
- return /^PATH=/i.test(line)
- }
- // extract just the path value
- stdout = stdout.split(/\r?\n/)
- var observedPath = stdout.filter(lineMatch).pop().replace(/^PATH=/, '')
- var pathSplit = process.platform === 'win32' ? ';' : ':'
- var root = path.resolve(__dirname, '../..')
- var actual = observedPath.split(pathSplit).map(function (p) {
- if (p.indexOf(pkg) === 0) {
- p = '{{PKG}}' + p.substr(pkg.length)
- }
- if (p.indexOf(root) === 0) {
- p = '{{ROOT}}' + p.substr(root.length)
- }
- return p.replace(/\\/g, '/')
- })
- // spawn-wrap adds itself to the path when coverage is enabled
- actual = actual.filter(function (p) {
- return !p.match(/\.node-spawn-wrap/)
- })
-
- // get the ones we tacked on, then the system-specific requirements
- var expectedPaths = ['{{ROOT}}/node_modules/npm-lifecycle/node-gyp-bin',
- '{{PKG}}/node_modules/.bin']
-
- // Check that the behaviour matches the configuration that was actually
- // used by the child process, as the coverage tooling may set the
- // --scripts-prepend-node-path option on its own.
- var realPrependNodePathSetting = stdout.filter(function (line) {
- return line.match(/npm_config_scripts_prepend_node_path=(true|auto)/)
- }).length > 0
-
- if (prependNodePathSetting === 'warn-only') {
- if (symlinkedNode) {
- t.equal(stderr, '', 'does not spit out a warning')
- } else if (withDirOfCurrentNode) {
- t.match(stderr, /npm WARN lifecycle/, 'spit out a warning')
- t.match(stderr, /npm is using .*node-bin.my_bundled_node(.exe)?/, 'mention the path of the binary npm itself is using.')
- if (extraNode) {
- var regex = new RegExp(
- 'The node binary used for scripts is.*' +
- process.execPath.replace(/[/\\]/g, '.'))
- t.match(stderr, regex, 'reports the current binary vs conflicting')
- } else if (systemNode !== null) {
- var regexSystemNode = new RegExp(
- 'The node binary used for scripts is.*' +
- systemNode.replace(/[/\\]/g, '.')
- )
- t.match(stderr, regexSystemNode, 'reports the system binary vs conflicting')
- } else {
- t.match(stderr, /there is no node binary in the current PATH/, 'informs user that there is no node binary in PATH')
- }
- } else {
- t.same(stderr, '')
- }
- }
-
- if (withDirOfCurrentNode && realPrependNodePathSetting) {
- expectedPaths.push('{{PKG}}/node-bin/my_bundled_node')
- }
- var expect = expectedPaths.concat(newPATH.split(pathSplit)).map(function (p) {
- return p.replace(/\\/g, '/')
- })
- t.same(actual, expect)
- t.end()
- })
-}
diff --git a/deps/npm/test/tap/link.js b/deps/npm/test/tap/link.js
deleted file mode 100644
index 2d2d63de21..0000000000
--- a/deps/npm/test/tap/link.js
+++ /dev/null
@@ -1,205 +0,0 @@
-var mkdirp = require('mkdirp')
-var path = require('path')
-var test = require('tap').test
-var lstatSync = require('fs').lstatSync
-var writeFileSync = require('fs').writeFileSync
-
-var common = require('../common-tap.js')
-
-var link = path.join(common.pkg, 'link')
-var linkScoped = path.join(common.pkg, 'link-scoped')
-var linkInstall = path.join(common.pkg, 'link-install')
-var linkInside = path.join(linkInstall, 'node_modules', 'inside')
-var linkRoot = path.join(common.pkg, 'link-root')
-
-var config = 'prefix = ' + linkRoot
-var configPath = path.join(link, '_npmrc')
-
-var OPTS = {
- env: {
- 'npm_config_userconfig': configPath
- }
-}
-
-var readJSON = {
- name: 'foo',
- version: '1.0.0',
- description: '',
- main: 'index.js',
- scripts: {
- test: 'echo "Error: no test specified" && exit 1'
- },
- author: '',
- license: 'ISC'
-}
-
-var readScopedJSON = {
- name: '@scope/foo',
- version: '1.0.0',
- description: '',
- main: 'index.js',
- scripts: {
- test: 'echo "Error: no test specified" && exit 1'
- },
- author: '',
- license: 'ISC'
-}
-
-var installJSON = {
- name: 'bar',
- version: '1.0.0',
- description: '',
- main: 'index.js',
- scripts: {
- test: 'echo "Error: no test specified" && exit 1'
- },
- author: '',
- license: 'ISC'
-}
-
-var insideInstallJSON = {
- name: 'inside',
- version: '1.0.0',
- description: '',
- main: 'index.js',
- scripts: {
- test: 'echo "Error: no test specified" && exit 1'
- },
- author: '',
- license: 'ISC'
-}
-
-test('setup', function (t) {
- mkdirp.sync(linkRoot)
- mkdirp.sync(link)
- writeFileSync(
- path.join(link, 'package.json'),
- JSON.stringify(readJSON, null, 2)
- )
- mkdirp.sync(linkScoped)
- writeFileSync(
- path.join(linkScoped, 'package.json'),
- JSON.stringify(readScopedJSON, null, 2)
- )
- mkdirp.sync(linkInstall)
- writeFileSync(
- path.join(linkInstall, 'package.json'),
- JSON.stringify(installJSON, null, 2)
- )
- mkdirp.sync(linkInside)
- writeFileSync(
- path.join(linkInside, 'package.json'),
- JSON.stringify(insideInstallJSON, null, 2)
- )
- writeFileSync(configPath, config)
- common.npm(['ls', '-g', '--depth=0'], OPTS, function (err, c, out) {
- t.ifError(err)
- t.equal(c, 0, 'set up ok')
- t.notOk(out.match(/UNMET DEPENDENCY foo@/), "foo isn't in global")
- t.end()
- })
-})
-
-test('create global link', function (t) {
- process.chdir(link)
- common.npm(['link'], OPTS, function (err, c, out) {
- t.ifError(err, 'link has no error')
- common.npm(['ls', '-g'], OPTS, function (err, c, out, stderr) {
- t.ifError(err)
- t.equal(c, 0)
- t.equal(stderr, '', 'got expected stderr')
- t.has(out, /foo@1.0.0/, 'creates global link ok')
- t.end()
- })
- })
-})
-
-test('create global inside link', function (t) {
- process.chdir(linkInside)
- common.npm(['link'], OPTS, function (err, c, out) {
- t.ifError(err, 'link has no error')
- common.npm(['ls', '-g'], OPTS, function (err, c, out, stderr) {
- t.ifError(err)
- t.equal(c, 0)
- t.equal(stderr, '', 'got expected stderr')
- t.has(out, /inside@1.0.0/, 'creates global inside link ok')
- t.end()
- })
- })
-})
-
-test('create scoped global link', function (t) {
- process.chdir(linkScoped)
- common.npm(['link'], OPTS, function (err, c, out) {
- t.ifError(err, 'link has no error')
- common.npm(['ls', '-g'], OPTS, function (err, c, out, stderr) {
- t.ifError(err)
- t.equal(c, 0)
- t.equal(stderr, '', 'got expected stderr')
- t.has(out, /@scope[/]foo@1.0.0/, 'creates global link ok')
- t.end()
- })
- })
-})
-
-test('link-install the package', function (t) {
- process.chdir(linkInstall)
- common.npm(['link', 'foo'], OPTS, function (err) {
- t.ifError(err, 'link-install has no error')
- common.npm(['ls'], OPTS, function (err, c, out) {
- t.ifError(err)
- t.equal(c, 1)
- t.has(out, /foo@1.0.0/, 'link-install ok')
- t.end()
- })
- })
-})
-
-test('link-inside-install fails', function (t) {
- process.chdir(linkInstall)
- t.notOk(lstatSync(linkInside).isSymbolicLink(), 'directory for linked package is not a symlink to begin with')
- common.npm(['link', 'inside'], OPTS, function (err, code) {
- t.ifError(err, 'npm removed the linked package without error')
- t.notEqual(code, 0, 'link operation failed')
- t.notOk(lstatSync(linkInside).isSymbolicLink(), 'directory for linked package has not turned into a symlink')
- t.end()
- })
-})
-
-test('link-install the scoped package', function (t) {
- process.chdir(linkInstall)
- common.npm(['link', linkScoped], OPTS, function (err) {
- t.ifError(err, 'link-install has no error')
- common.npm(['ls'], OPTS, function (err, c, out) {
- t.ifError(err)
- t.equal(c, 1)
- t.has(out, /@scope[/]foo@1.0.0/, 'link-install ok')
- t.end()
- })
- })
-})
-
-test('ls the linked packages', function (t) {
- process.chdir(linkInstall)
- common.npm(['ls', '--link'], OPTS, function (err, c, out) {
- t.ifError(err, 'ls --link did not have an error')
- t.equal(c, 1)
- t.has(out, /@scope\/foo@1\.0\.0 ->/, 'output contains scoped link')
- t.has(out, /foo@1\.0\.0 ->/, 'output contains link')
- t.doesNotHave(out, /inside@1\.0\.0/, 'output does not contain unlinked dependency')
- t.end()
- })
-})
-
-test('cleanup', function (t) {
- process.chdir(common.pkg)
- common.npm(['rm', 'foo'], OPTS, function (err, code) {
- t.ifError(err, 'npm removed the linked package without error')
- t.equal(code, 0, 'cleanup foo in local ok')
- common.npm(['rm', '-g', 'foo'], OPTS, function (err, code) {
- t.ifError(err, 'npm removed the global package without error')
- t.equal(code, 0, 'cleanup foo in global ok')
- t.end()
- })
- })
-})
diff --git a/deps/npm/test/tap/local-args-relative-to-cwd.js b/deps/npm/test/tap/local-args-relative-to-cwd.js
deleted file mode 100644
index de95516e28..0000000000
--- a/deps/npm/test/tap/local-args-relative-to-cwd.js
+++ /dev/null
@@ -1,65 +0,0 @@
-'use strict'
-var fs = require('graceful-fs')
-var path = require('path')
-var test = require('tap').test
-var Tacks = require('tacks')
-var File = Tacks.File
-var Dir = Tacks.Dir
-var common = require('../common-tap.js')
-var testdir = common.pkg
-
-var fixture = new Tacks(
- Dir({
- example: Dir({
- }),
- mod1: Dir({
- 'package.json': File({
- name: 'mod1',
- version: '1.0.0'
- })
- }),
- node_modules: Dir({
- })
- })
-)
-
-function setup () {
- fixture.create(testdir)
-}
-
-function cleanup () {
- fixture.remove(testdir)
-}
-
-test('setup', function (t) {
- cleanup()
- setup()
- t.end()
-})
-
-function exists (file) {
- try {
- fs.statSync(file)
- return true
- } catch (ex) {
- return false
- }
-}
-
-test('local-args-relative-to-cwd', function (t) {
- var instdir = path.join(testdir, 'example')
- var config = ['--loglevel=error']
- common.npm(config.concat(['install', '../mod1']), {cwd: instdir}, function (err, code, stdout, stderr) {
- if (err) throw err
- t.comment(stdout.trim())
- t.comment(stderr.trim())
- t.is(code, 0, 'install ran ok')
- t.ok(exists(path.join(testdir, 'node_modules', 'mod1')), 'mod1 installed')
- t.end()
- })
-})
-
-test('cleanup', function (t) {
- cleanup()
- t.end()
-})
diff --git a/deps/npm/test/tap/locker.js b/deps/npm/test/tap/locker.js
deleted file mode 100644
index 1df6fda710..0000000000
--- a/deps/npm/test/tap/locker.js
+++ /dev/null
@@ -1,77 +0,0 @@
-var test = require('tap').test
-var path = require('path')
-var fs = require('graceful-fs')
-var crypto = require('crypto')
-var mkdirp = require('mkdirp')
-var npm = require('../../')
-var locker = require('../../lib/utils/locker.js')
-var lock = locker.lock
-var unlock = locker.unlock
-
-const common = require('../common-tap.js')
-var pkg = common.pkg
-var cache = path.join(pkg, '/cache')
-var tmp = path.join(pkg, '/tmp')
-var nm = path.join(pkg, '/node_modules')
-
-test('setup', function (t) {
- mkdirp.sync(cache)
- mkdirp.sync(tmp)
- t.end()
-})
-
-test('locking file puts lock in correct place', function (t) {
- npm.load({cache: cache, tmpdir: tmp}, function (er) {
- t.ifError(er, 'npm bootstrapped OK')
-
- var n = 'correct'
- var c = n.replace(/[^a-zA-Z0-9]+/g, '-').replace(/^-+|-+$/g, '')
- var p = path.resolve(nm, n)
- var h = crypto.createHash('sha1').update(p).digest('hex')
- var l = c.substr(0, 24) + '-' + h.substr(0, 16) + '.lock'
- var v = path.join(cache, '_locks', l)
-
- lock(nm, n, function (er) {
- t.ifError(er, 'locked path')
-
- fs.exists(v, function (found) {
- t.ok(found, 'lock found OK')
-
- unlock(nm, n, function (er) {
- t.ifError(er, 'unlocked path')
-
- fs.exists(v, function (found) {
- t.notOk(found, 'lock deleted OK')
- t.end()
- })
- })
- })
- })
- })
-})
-
-test('unlocking out of order errors out', function (t) {
- npm.load({cache: cache, tmpdir: tmp}, function (er) {
- t.ifError(er, 'npm bootstrapped OK')
-
- var n = 'busted'
- var c = n.replace(/[^a-zA-Z0-9]+/g, '-').replace(/^-+|-+$/g, '')
- var p = path.resolve(nm, n)
- var h = crypto.createHash('sha1').update(p).digest('hex')
- var l = c.substr(0, 24) + '-' + h.substr(0, 16) + '.lock'
- var v = path.join(cache, '_locks', l)
-
- fs.exists(v, function (found) {
- t.notOk(found, 'no lock to unlock')
-
- t.throws(function () {
- unlock(nm, n, function () {
- t.fail("shouldn't get here")
- t.end()
- })
- }, 'blew up as expected')
-
- t.end()
- })
- })
-})
diff --git a/deps/npm/test/tap/lockfile-empty-dep-value.js b/deps/npm/test/tap/lockfile-empty-dep-value.js
deleted file mode 100644
index 1e30889fcb..0000000000
--- a/deps/npm/test/tap/lockfile-empty-dep-value.js
+++ /dev/null
@@ -1,68 +0,0 @@
-'use strict'
-
-const common = require('../common-tap.js')
-const path = require('path')
-const test = require('tap').test
-
-const Tacks = require('tacks')
-const File = Tacks.File
-const Dir = Tacks.Dir
-
-const basedir = common.pkg
-const testdir = path.join(basedir, 'testdir')
-
-const fixture = new Tacks(Dir({
- cache: Dir(),
- global: Dir(),
- tmp: Dir(),
- testdir: Dir({
- 'package-lock.json': File({
- name: 'http-locks',
- version: '1.0.0',
- lockfileVersion: 1,
- requires: true,
- dependencies: {
- minimist: {}
- }
- }),
- 'package.json': File({
- name: 'http-locks',
- version: '1.0.0',
- dependencies: {
- minimist: common.registry + '/minimist/-/minimist-0.0.5.tgz'
- }
- })
- })
-}))
-
-function setup () {
- cleanup()
- fixture.create(basedir)
-}
-
-function cleanup () {
- fixture.remove(basedir)
-}
-
-test('setup', function (t) {
- setup()
- t.done()
-})
-
-test('raises error to regenerate the lock file', function (t) {
- common.npm(['install'], {cwd: testdir}, function (err, code, stdout, stderr) {
- if (err) throw err
- t.match(
- stderr,
- 'npm ERR! Something went wrong. Regenerate the package-lock.json with "npm install".',
- 'returns message to regenerate package-lock'
- )
-
- t.done()
- })
-})
-
-test('cleanup', function (t) {
- cleanup()
- t.done()
-})
diff --git a/deps/npm/test/tap/lockfile-http-deps.js b/deps/npm/test/tap/lockfile-http-deps.js
deleted file mode 100644
index b5eaa10760..0000000000
--- a/deps/npm/test/tap/lockfile-http-deps.js
+++ /dev/null
@@ -1,90 +0,0 @@
-'use strict'
-const fs = require('fs')
-var path = require('path')
-var test = require('tap').test
-var mr = require('npm-registry-mock')
-var Tacks = require('tacks')
-var File = Tacks.File
-var Dir = Tacks.Dir
-var common = require('../common-tap.js')
-
-var basedir = common.pkg
-var testdir = path.join(basedir, 'testdir')
-var cachedir = common.cache
-var globaldir = path.join(basedir, 'global')
-var tmpdir = path.join(basedir, 'tmp')
-
-var conf = {
- cwd: testdir,
- env: Object.assign({}, process.env, {
- npm_config_cache: cachedir,
- npm_config_tmp: tmpdir,
- npm_config_prefix: globaldir,
- npm_config_registry: common.registry,
- npm_config_loglevel: 'warn'
- })
-}
-
-var server
-var fixture = new Tacks(Dir({
- cache: Dir(),
- global: Dir(),
- tmp: Dir(),
- testdir: Dir({
- 'package-lock.json': File({
- name: 'http-locks',
- version: '1.0.0',
- lockfileVersion: 1,
- requires: true,
- dependencies: {
- minimist: {
- version: common.registry + '/minimist/-/minimist-0.0.5.tgz',
- integrity: 'sha1-16oye87PUY+RBqxrjwA/o7zqhWY='
- }
- }
- }),
- 'package.json': File({
- name: 'http-locks',
- version: '1.0.0',
- dependencies: {
- minimist: common.registry + '/minimist/-/minimist-0.0.5.tgz'
- }
- })
- })
-}))
-
-function setup () {
- cleanup()
- fixture.create(basedir)
-}
-
-function cleanup () {
- fixture.remove(basedir)
-}
-
-test('setup', function (t) {
- setup()
- mr({port: common.port, throwOnUnmatched: true}, function (err, s) {
- if (err) throw err
- server = s
- t.done()
- })
-})
-
-test('http deps in lock files', function (t) {
- common.npm(['install'], conf, function (err, code, stdout, stderr) {
- if (err) throw err
- t.is(code, 0, 'command ran ok')
- t.comment(stdout.trim())
- t.comment(stderr.trim())
- const minPackage = JSON.parse(fs.readFileSync(testdir + '/node_modules/minimist/package.json'))
- t.is(minPackage.version, '0.0.5', 'package version was maintained')
- t.done()
- })
-})
-
-test('cleanup', function (t) {
- server.close()
- cleanup()
- t.done()
-})
diff --git a/deps/npm/test/tap/logout-scoped.js b/deps/npm/test/tap/logout-scoped.js
deleted file mode 100644
index 114cc09da7..0000000000
--- a/deps/npm/test/tap/logout-scoped.js
+++ /dev/null
@@ -1,69 +0,0 @@
-var fs = require('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 = common.pkg
-var outfile = path.join(pkg, '_npmrc')
-var opts = { cwd: pkg }
-
-var contents = `foo=boo
-@bar:registry=http://localhost:${common.port}
-//localhost:${common.port}/:_authToken=glarb
-`
-
-function mocks (server) {
- server.delete('/-/user/token/glarb')
- .reply(200, {})
-}
-
-test('setup', function (t) {
- cleanup()
- setup()
- t.end()
-})
-
-test('npm logout', function (t) {
- mr({ port: common.port, plugin: mocks }, function (err, s) {
- if (err) throw err
-
- common.npm(
- [
- 'logout',
- '--registry', common.registry,
- '--scope', '@bar',
- '--loglevel', 'silent',
- '--userconfig', outfile
- ],
- opts,
- function (err, code) {
- t.ifError(err, 'no error output')
- t.notOk(code, 'exited OK')
-
- var config = fs.readFileSync(outfile, 'utf8')
- t.equal(config.trim(), 'foo=boo', 'creds gone')
- s.close()
- t.end()
- }
- )
- })
-})
-
-test('cleanup', function (t) {
- cleanup()
- t.end()
-})
-
-function setup () {
- mkdirp.sync(pkg)
- fs.writeFileSync(outfile, contents)
-}
-
-function cleanup () {
- rimraf.sync(pkg)
-}
diff --git a/deps/npm/test/tap/logout.js b/deps/npm/test/tap/logout.js
deleted file mode 100644
index 9218b4bf6f..0000000000
--- a/deps/npm/test/tap/logout.js
+++ /dev/null
@@ -1,67 +0,0 @@
-var fs = require('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 = common.pkg
-var outfile = path.join(pkg, '_npmrc')
-var opts = { cwd: pkg }
-
-var contents = `foo=boo
-//localhost:${common.port}/:_authToken=glarb
-`
-
-function mocks (server) {
- server.delete('/-/user/token/glarb')
- .reply(200, {})
-}
-
-test('setup', function (t) {
- cleanup()
- setup()
- t.end()
-})
-
-test('npm logout', function (t) {
- mr({ port: common.port, plugin: mocks }, function (err, s) {
- if (err) throw err
-
- common.npm(
- [
- 'logout',
- '--registry', common.registry,
- '--loglevel', 'silent',
- '--userconfig', outfile
- ],
- opts,
- function (err, code) {
- t.ifError(err, 'no error output')
- t.notOk(code, 'exited OK')
-
- var config = fs.readFileSync(outfile, 'utf8')
- t.notMatch(config, /localhost/, 'creds gone')
- s.close()
- t.end()
- }
- )
- })
-})
-
-test('cleanup', function (t) {
- cleanup()
- t.end()
-})
-
-function setup () {
- mkdirp.sync(pkg)
- fs.writeFileSync(outfile, contents)
-}
-
-function cleanup () {
- rimraf.sync(pkg)
-}
diff --git a/deps/npm/test/tap/ls-depth-cli.js b/deps/npm/test/tap/ls-depth-cli.js
deleted file mode 100644
index 55142b3ad1..0000000000
--- a/deps/npm/test/tap/ls-depth-cli.js
+++ /dev/null
@@ -1,196 +0,0 @@
-var fs = require('graceful-fs')
-var path = require('path')
-
-var Bluebird = require('bluebird')
-var mr = Bluebird.promisify(require('npm-registry-mock'))
-var test = require('tap').test
-
-var common = require('../common-tap')
-
-var pkg = common.pkg
-
-var EXEC_OPTS = {
- cwd: pkg,
- env: common.newEnv().extend({
- npm_config_registry: common.registry
- }),
- stdio: [0, 'pipe', 2]
-}
-
-var json = {
- name: 'ls-depth-cli',
- version: '0.0.0',
- dependencies: {
- 'test-package-with-one-dep': '0.0.0'
- }
-}
-
-test('setup', function (t) {
- fs.writeFileSync(
- path.join(pkg, 'package.json'),
- JSON.stringify(json, null, 2)
- )
- return mr({ port: common.port }).then((s) => {
- return common.npm(['install'], EXEC_OPTS).spread((c) => {
- t.is(c, 0)
- }).finally(() => s.close())
- })
-})
-
-test('npm ls --depth=0', function (t) {
- return common.npm(['ls', '--depth=0'], EXEC_OPTS).spread((c, out) => {
- t.equal(c, 0, 'ls ran without raising error code')
- t.has(
- out,
- /test-package-with-one-dep@0\.0\.0/,
- 'output contains test-package-with-one-dep@0.0.0'
- )
- t.doesNotHave(
- out,
- /test-package@0\.0\.0/,
- 'output not contains test-package@0.0.0'
- )
- })
-})
-
-test('npm ls --depth=1', function (t) {
- common.npm(
- ['ls', '--depth=1'],
- EXEC_OPTS,
- function (er, c, out) {
- t.ifError(er, 'npm ls ran without issue')
- t.equal(c, 0, 'ls ran without raising error code')
- t.has(
- out,
- /test-package-with-one-dep@0\.0\.0/,
- 'output contains test-package-with-one-dep@0.0.0'
- )
- t.has(
- out,
- /test-package@0\.0\.0/,
- 'output contains test-package@0.0.0'
- )
- t.end()
- }
- )
-})
-
-test('npm ls --depth=Infinity', function (t) {
- // travis has a preconfigured depth=0, in general we can not depend
- // on the default value in all environments, so explicitly set it here
- common.npm(
- ['ls', '--depth=Infinity'],
- EXEC_OPTS,
- function (er, c, out) {
- t.ifError(er, 'npm ls ran without issue')
- t.equal(c, 0, 'ls ran without raising error code')
- t.has(
- out,
- /test-package-with-one-dep@0\.0\.0/,
- 'output contains test-package-with-one-dep@0.0.0'
- )
- t.has(
- out,
- /test-package@0\.0\.0/,
- 'output contains test-package@0.0.0'
- )
- t.end()
- }
- )
-})
-
-test('npm ls --depth=0 --json', function (t) {
- common.npm(
- ['ls', '--depth=0', '--json'],
- EXEC_OPTS,
- function (er, c, out) {
- t.ifError(er, 'npm ls ran without issue')
- t.equal(c, 0, 'ls ran without raising error code')
- t.has(JSON.parse(out), {
- 'name': 'ls-depth-cli',
- 'version': '0.0.0',
- 'dependencies': {
- 'test-package-with-one-dep': {
- 'version': '0.0.0',
- 'resolved': 'http://localhost:' + common.port + '/test-package-with-one-dep/-/test-package-with-one-dep-0.0.0.tgz'
- }
- }
- })
- t.end()
- }
- )
-})
-
-test('npm ls --depth=Infinity --json', function (t) {
- // travis has a preconfigured depth=0, in general we can not depend
- // on the default value in all environments, so explicitly set it here
- common.npm(
- ['ls', '--depth=Infinity', '--json'],
- EXEC_OPTS,
- function (er, c, out) {
- t.ifError(er, 'npm ls ran without issue')
- t.equal(c, 0, 'ls ran without raising error code')
- t.has(JSON.parse(out), {
- 'name': 'ls-depth-cli',
- 'version': '0.0.0',
- 'dependencies': {
- 'test-package-with-one-dep': {
- 'version': '0.0.0',
- 'resolved': 'http://localhost:' + common.port + '/test-package-with-one-dep/-/test-package-with-one-dep-0.0.0.tgz',
- 'dependencies': {
- 'test-package': {
- 'version': '0.0.0',
- 'resolved': 'http://localhost:' + common.port + '/test-package/-/test-package-0.0.0.tgz'
- }
- }
- }
- }
- })
- t.end()
- }
- )
-})
-
-test('npm ls --depth=0 --parseable --long', function (t) {
- common.npm(
- ['ls', '--depth=0', '--parseable', '--long'],
- EXEC_OPTS,
- function (er, c, out) {
- t.ifError(er, 'npm ls ran without issue')
- t.equal(c, 0, 'ls ran without raising error code')
- t.has(
- out,
- /.*test-package-with-one-dep@0\.0\.0/,
- 'output contains test-package-with-one-dep'
- )
- t.doesNotHave(
- out,
- /.*test-package@0\.0\.0/,
- 'output not contains test-package'
- )
- t.end()
- }
- )
-})
-
-test('npm ls --depth=1 --parseable --long', function (t) {
- common.npm(
- ['ls', '--depth=1', '--parseable', '--long'],
- EXEC_OPTS,
- function (er, c, out) {
- t.ifError(er, 'npm ls ran without issue')
- t.equal(c, 0, 'ls ran without raising error code')
- t.has(
- out,
- /.*test-package-with-one-dep@0\.0\.0/,
- 'output contains test-package-with-one-dep'
- )
- t.has(
- out,
- /.*test-package@0\.0\.0/,
- 'output not contains test-package'
- )
- t.end()
- }
- )
-})
diff --git a/deps/npm/test/tap/ls-depth-unmet.js b/deps/npm/test/tap/ls-depth-unmet.js
deleted file mode 100644
index bf032efe9c..0000000000
--- a/deps/npm/test/tap/ls-depth-unmet.js
+++ /dev/null
@@ -1,157 +0,0 @@
-var fs = require('graceful-fs')
-var path = require('path')
-
-var mr = require('npm-registry-mock')
-var test = require('tap').test
-
-var common = require('../common-tap')
-
-var pkg = common.pkg
-
-var EXEC_OPTS = { cwd: pkg }
-
-var json = {
- name: 'ls-depth-umnet',
- author: 'Evan You',
- version: '0.0.0',
- dependencies: {
- 'test-package-with-one-dep': '0.0.0',
- underscore: '1.5.1',
- optimist: '0.6.0'
- }
-}
-
-test('setup', function (t) {
- fs.writeFileSync(
- path.join(pkg, 'package.json'),
- JSON.stringify(json, null, 2)
- )
- mr({ port: common.port }, function (er, s) {
- common.npm(
- [
- '--registry', common.registry,
- 'install', '--no-save', 'underscore@1.3.1', 'mkdirp', 'test-package-with-one-dep'
- ],
- EXEC_OPTS,
- function (er, c) {
- t.ifError(er, 'setup installation ran without issue')
- t.equal(c, 0)
- s.close()
- t.end()
- }
- )
- })
-})
-
-test('npm ls --depth=0', function (t) {
- common.npm(
- ['ls', '--depth=0'],
- EXEC_OPTS,
- function (er, c, out) {
- t.ifError(er, 'setup installation ran without issue')
- t.equal(c, 1, 'ls barfed')
- t.has(
- out,
- /UNMET DEPENDENCY optimist@0\.6\.0/,
- 'output contains optimist@0.6.0 and labeled as unmet dependency'
- )
- t.has(
- out,
- /mkdirp@0\.3\.5 extraneous/,
- 'output contains mkdirp@0.3.5 and labeled as extraneous'
- )
- t.has(
- out,
- /underscore@1\.3\.1 invalid/,
- 'output contains underscore@1.3.1 and labeled as invalid'
- )
- t.has(
- out,
- /test-package-with-one-dep@0\.0\.0\n/,
- 'output contains test-package-with-one-dep@0.0.0 and has no labels'
- )
- t.doesNotHave(
- out,
- /test-package@0\.0\.0/,
- 'output does not contain test-package@0.0.0 which is at depth=1'
- )
- t.end()
- }
- )
-})
-
-test('npm ls --depth=1', function (t) {
- common.npm(
- ['ls', '--depth=1'],
- EXEC_OPTS,
- function (er, c, out) {
- t.ifError(er, 'setup installation ran without issue')
- t.equal(c, 1, 'ls barfed')
- t.has(
- out,
- /UNMET DEPENDENCY optimist@0\.6\.0/,
- 'output contains optimist@0.6.0 and labeled as unmet dependency'
- )
- t.has(
- out,
- /mkdirp@0\.3\.5 extraneous/,
- 'output contains mkdirp@0.3.5 and labeled as extraneous'
- )
- t.has(
- out,
- /underscore@1\.3\.1 invalid/,
- 'output contains underscore@1.3.1 and labeled as invalid'
- )
- t.has(
- out,
- /test-package-with-one-dep@0\.0\.0\n/,
- 'output contains test-package-with-one-dep@0.0.0 and has no labels'
- )
- t.has(
- out,
- /test-package@0\.0\.0/,
- 'output contains test-package@0.0.0 which is at depth=1'
- )
- t.end()
- }
- )
-})
-
-test('npm ls --depth=Infinity', function (t) {
- // travis has a preconfigured depth=0, in general we can not depend
- // on the default value in all environments, so explicitly set it here
- common.npm(
- ['ls', '--depth=Infinity'],
- EXEC_OPTS,
- function (er, c, out) {
- t.ifError(er, 'setup installation ran without issue')
- t.equal(c, 1, 'ls barfed')
- t.has(
- out,
- /UNMET DEPENDENCY optimist@0\.6\.0/,
- 'output contains optimist@0.6.0 and labeled as unmet dependency'
- )
- t.has(
- out,
- /mkdirp@0\.3\.5 extraneous/,
- 'output contains mkdirp@0.3.5 and labeled as extraneous'
- )
- t.has(
- out,
- /underscore@1\.3\.1 invalid/,
- 'output contains underscore@1.3.1 and labeled as invalid'
- )
- t.has(
- out,
- /test-package-with-one-dep@0\.0\.0\n/,
- 'output contains test-package-with-one-dep@0.0.0 and has no labels'
- )
- t.has(
- out,
- /test-package@0\.0\.0/,
- 'output contains test-package@0.0.0 which is at depth=1'
- )
- t.end()
- }
- )
-})
diff --git a/deps/npm/test/tap/ls-env.js b/deps/npm/test/tap/ls-env.js
deleted file mode 100644
index 5d9d7cd06b..0000000000
--- a/deps/npm/test/tap/ls-env.js
+++ /dev/null
@@ -1,120 +0,0 @@
-var fs = require('graceful-fs')
-var path = require('path')
-
-var mr = require('npm-registry-mock')
-var test = require('tap').test
-
-var common = require('../common-tap')
-
-var pkg = common.pkg
-
-var EXEC_OPTS = { cwd: pkg }
-
-var json = {
- name: 'ls-env',
- version: '0.0.0',
- dependencies: {
- 'test-package-with-one-dep': '0.0.0'
- }
-}
-
-test('setup', function (t) {
- fs.writeFileSync(
- path.join(pkg, 'package.json'),
- JSON.stringify(json, null, 2)
- )
- mr({port: common.port}, function (er, s) {
- common.npm(
- [
- '--registry', common.registry,
- 'install'
- ],
- EXEC_OPTS,
- function (er, c) {
- t.ifError(er, 'install ran without issue')
- t.equal(c, 0)
- s.close()
- t.end()
- }
- )
- })
-})
-
-test('npm ls --dev', function (t) {
- common.npm(['ls', '--dev'], EXEC_OPTS, function (er, code, stdout) {
- t.ifError(er, 'ls --dev ran without issue')
- t.equal(code, 0)
- t.has(stdout, /(empty)/, 'output contains (empty)')
- t.end()
- })
-})
-
-test('npm ls --only=development', function (t) {
- common.npm(['ls', '--only=development'], EXEC_OPTS, function (er, code, stdout) {
- t.ifError(er, 'ls --only=development ran without issue')
- t.equal(code, 0)
- t.has(stdout, /(empty)/, 'output contains (empty)')
- t.end()
- })
-})
-
-test('npm ls --only=dev', function (t) {
- common.npm(['ls', '--only=dev'], EXEC_OPTS, function (er, code, stdout) {
- t.ifError(er, 'ls --only=dev ran without issue')
- t.equal(code, 0)
- t.has(stdout, /(empty)/, 'output contains (empty)')
- t.end()
- })
-})
-
-test('npm ls --production', function (t) {
- common.npm(['ls', '--production'], EXEC_OPTS, function (er, code, stdout) {
- t.ifError(er, 'ls --production ran without issue')
- t.notOk(code, 'npm exited ok')
- t.has(
- stdout,
- /test-package-with-one-dep@0\.0\.0/,
- 'output contains test-package-with-one-dep@0.0.0'
- )
- t.end()
- })
-})
-
-test('npm ls --prod', function (t) {
- common.npm(['ls', '--prod'], EXEC_OPTS, function (er, code, stdout) {
- t.ifError(er, 'ls --prod ran without issue')
- t.notOk(code, 'npm exited ok')
- t.has(
- stdout,
- /test-package-with-one-dep@0\.0\.0/,
- 'output contains test-package-with-one-dep@0.0.0'
- )
- t.end()
- })
-})
-
-test('npm ls --only=production', function (t) {
- common.npm(['ls', '--only=production'], EXEC_OPTS, function (er, code, stdout) {
- t.ifError(er, 'ls --only=production ran without issue')
- t.notOk(code, 'npm exited ok')
- t.has(
- stdout,
- /test-package-with-one-dep@0\.0\.0/,
- 'output contains test-package-with-one-dep@0.0.0'
- )
- t.end()
- })
-})
-
-test('npm ls --only=prod', function (t) {
- common.npm(['ls', '--only=prod'], EXEC_OPTS, function (er, code, stdout) {
- t.ifError(er, 'ls --only=prod ran without issue')
- t.notOk(code, 'npm exited ok')
- t.has(
- stdout,
- /test-package-with-one-dep@0\.0\.0/,
- 'output contains test-package-with-one-dep@0.0.0'
- )
- t.end()
- })
-})
diff --git a/deps/npm/test/tap/ls-l-depth-0.js b/deps/npm/test/tap/ls-l-depth-0.js
deleted file mode 100644
index 8e707a1d39..0000000000
--- a/deps/npm/test/tap/ls-l-depth-0.js
+++ /dev/null
@@ -1,100 +0,0 @@
-var writeFileSync = require('graceful-fs').writeFileSync
-var resolve = require('path').resolve
-
-var mkdirp = require('mkdirp')
-var Bluebird = require('bluebird')
-var mr = Bluebird.promisify(require('npm-registry-mock'))
-var test = require('tap').test
-var common = require('../common-tap.js')
-
-var pkg = common.pkg
-var dep = resolve(pkg, 'deps', 'glock')
-var modules = resolve(pkg, 'node_modules')
-
-var expected =
- '\n' +
- '│ ' + pkg + '\n' +
- '│ \n' +
- '└── glock@1.8.7\n' +
- ' an inexplicably hostile sample package\n' +
- ' git+https://github.com/npm/glo.ck.git\n' +
- ' https://glo.ck\n' +
- ' file:glock-1.8.7.tgz\n' +
- '\n'
-
-var EXEC_OPTS = { cwd: pkg }
-
-var fixture = {
- 'name': 'glock',
- 'version': '1.8.7',
- 'private': true,
- 'description': 'an inexplicably hostile sample package',
- 'homepage': 'https://glo.ck',
- 'repository': 'https://github.com/npm/glo.ck',
- 'dependencies': {
- 'underscore': '1.5.1'
- }
-}
-
-var deppack
-
-test('setup', function (t) {
- mkdirp.sync(modules)
- mkdirp.sync(dep)
-
- writeFileSync(resolve(dep, 'package.json'), JSON.stringify(fixture))
- return mr({ port: common.port }).then((s) => {
- t.parent.teardown(() => s.close())
- return common.npm(['pack', dep], EXEC_OPTS)
- }).spread((code, stdout) => {
- t.is(code, 0, 'pack')
- deppack = stdout.trim()
- })
-})
-
-test('#6311: npm ll --depth=0 duplicates listing', function (t) {
- common.npm(
- [
- '--loglevel', 'silent',
- '--registry', common.registry,
- '--parseable',
- 'install', deppack
- ],
- EXEC_OPTS,
- function (err, code, stdout, stderr) {
- if (err) throw err
- t.notOk(code, 'npm install exited cleanly')
- t.is(stderr, '', 'npm install ran silently')
- t.match(
- stdout.trim(),
- new RegExp(
- '^add\tunderscore\t1[.]5[.]1\tnode_modules[\\\\/]underscore\t\t[\n]' +
- 'add\tglock\t1[.]8[.]7\tnode_modules[\\\\/]glock$'
- ),
- 'got expected install output'
- )
-
- common.npm(
- [
- '--loglevel', 'silent',
- 'ls', '--long',
- '--unicode=true',
- '--depth', '0'
- ],
- EXEC_OPTS,
- function (err, code, stdout, stderr) {
- if (err) throw err
- t.is(code, 0, 'npm ll exited cleanly')
- t.is(stderr, '', 'npm ll ran silently')
- t.equal(
- stdout,
- expected,
- 'got expected package name'
- )
-
- t.end()
- }
- )
- }
- )
-})
diff --git a/deps/npm/test/tap/ls-no-results.js b/deps/npm/test/tap/ls-no-results.js
deleted file mode 100644
index 9792774c69..0000000000
--- a/deps/npm/test/tap/ls-no-results.js
+++ /dev/null
@@ -1,12 +0,0 @@
-var test = require('tap').test
-var spawn = require('child_process').spawn
-var node = process.execPath
-var npm = require.resolve('../../')
-var args = [ npm, 'ls', 'ceci n’est pas une package' ]
-test('ls exits non-zero when nothing found', function (t) {
- var child = spawn(node, args)
- child.on('exit', function (code) {
- t.notEqual(code, 0)
- t.end()
- })
-})
diff --git a/deps/npm/test/tap/ls-peer.js b/deps/npm/test/tap/ls-peer.js
deleted file mode 100644
index 05cc138225..0000000000
--- a/deps/npm/test/tap/ls-peer.js
+++ /dev/null
@@ -1,123 +0,0 @@
-'use strict'
-const path = require('path')
-const test = require('tap').test
-const Tacks = require('tacks')
-const File = Tacks.File
-const Dir = Tacks.Dir
-const common = require('../common-tap.js')
-
-const basedir = common.pkg
-const testdir = path.join(basedir, 'testdir')
-const cachedir = common.cache
-const globaldir = path.join(basedir, 'global')
-const tmpdir = path.join(basedir, 'tmp')
-
-const conf = {
- cwd: testdir,
- env: common.newEnv().extend({
- npm_config_cache: cachedir,
- npm_config_tmp: tmpdir,
- npm_config_prefix: globaldir,
- npm_config_registry: common.registry,
- npm_config_loglevel: 'warn'
- })
-}
-
-const fixture = new Tacks(Dir({
- cache: Dir(),
- global: Dir(),
- tmp: Dir(),
- testdir: Dir({
- 'package.json': File({
- name: 'fixture',
- version: '1.0.0',
- dependencies: {
- dep: 'file:dep-1.0.0.tgz',
- 'peer-dep': 'file:peer-dep-2.0.0.tgz'
- }
- }),
- // Source dir
- // dep: Dir({
- // 'package.json': File({
- // name: 'dep',
- // version: '1.0.0',
- // peerDependencies: {
- // 'peer-dep': 'file:peer-dep-1.0.0.tgz'
- // }
- // })
- // }),
- 'dep-1.0.0.tgz': File(Buffer.from(
- '1f8b0800000000000003ed8f3d0ec2300c853be71451661a1cd166e8cc45' +
- 'a2d654e1278d92c200eadd491a60ea462584946fb1f5fc9e655bd59e548f' +
- '5b9b2a3ffac1142b0300b2aae8921e1152d062574b10424a08bed0d4d10f' +
- '6b1fb2c4d58fca8553bedd937ea19ffa273c08a5cca80bb286b20e2ddb44' +
- 'e186ceebc1444d70e090548be8f668d174685a8d3e8c63fc3529633a040e' +
- 'fa8ccd5b28e7381ffb3b0bce894ce4d70f6732994c66e60975aec5690008' +
- '0000',
- 'hex'
- )),
- // Source dir
- // 'peer-dep': Dir({
- // 'package.json': File({
- // name: 'peer-dep',
- // version: '2.0.0'
- // })
- // }),
- 'peer-dep-1.0.0.tgz': File(Buffer.from(
- '1f8b08000000000000032b484cce4e4c4fd52f80d07a59c5f9790c540606' +
- '06066626260ad8c4c1c0d45c81c1d8d4ccc0d0d0cccc00a80ec830353500' +
- 'd2d4760836505a5c925804740aa5e640bca200a78708a8e6525050ca4bcc' +
- '4d55b252502a484d2dd24d492d50d2018996a5161567e6e781240cf50cf4' +
- '0c94b86ab906dab9a360148c8251300aa80400c1c67f6300080000',
- 'hex'
- )),
- 'peer-dep-2.0.0.tgz': File(Buffer.from(
- '1f8b08000000000000032b484cce4e4c4fd52f80d07a59c5f9790c540606' +
- '06066626260ad8c4c1c0d45c81c1d8d4ccc0d0d0cccc00a80ec830353500' +
- 'd2d4760836505a5c925804740aa5e640bca200a78708a8e6525050ca4bcc' +
- '4d55b252502a484d2dd24d492d50d2018996a5161567e6e781248cf40cf4' +
- '0c94b86ab906dab9a360148c8251300aa80400cb30060800080000',
- 'hex'
- ))
- })
-}))
-
-function setup () {
- cleanup()
- fixture.create(basedir)
-}
-
-function cleanup () {
- fixture.remove(basedir)
-}
-
-test('setup', t => {
- setup()
- return common.fakeRegistry.listen().then(() => common.npm(['install'], conf))
-})
-
-test('list warns about unmet peer dependency', t => {
- return common.npm(['ls'], conf).then(([code, stdout, stderr]) => {
- t.is(code, 1, 'command ran not ok')
- t.comment(stdout.trim())
- t.comment(stderr.trim())
- t.match(stdout, 'UNMET PEER DEPENDENCY peer-dep@2.0.0')
- t.match(stderr, 'npm ERR! peer dep missing: peer-dep@file:peer-dep-1.0.0.tgz, required by dep@1.0.0')
- })
-})
-
-test('list shows installed but unmet peer dependency', t => {
- return common.npm(['ls', 'peer-dep'], conf).then(([code, stdout, stderr]) => {
- t.is(code, 1, 'command ran not ok')
- t.comment(stdout.trim())
- t.comment(stderr.trim())
- t.match(stdout, 'UNMET PEER DEPENDENCY peer-dep@2.0.0')
- t.match(stderr, 'npm ERR! peer dep missing: peer-dep@file:peer-dep-1.0.0.tgz, required by dep@1.0.0')
- })
-})
-
-test('cleanup', t => {
- common.fakeRegistry.close()
- cleanup()
- t.done()
-})
diff --git a/deps/npm/test/tap/ls-production-and-dev.js b/deps/npm/test/tap/ls-production-and-dev.js
deleted file mode 100644
index 5836c8fc13..0000000000
--- a/deps/npm/test/tap/ls-production-and-dev.js
+++ /dev/null
@@ -1,157 +0,0 @@
-var fs = require('graceful-fs')
-var path = require('path')
-
-var mr = require('npm-registry-mock')
-var test = require('tap').test
-
-var common = require('../common-tap')
-
-var pkg = common.pkg
-
-var EXEC_OPTS = { cwd: pkg }
-
-var json = {
- name: 'ls-env',
- version: '0.0.0',
- dependencies: {
- 'test-package-with-one-dep': '0.0.0',
- 'test-repo-url-ssh': '0.0.1'
- },
- devDependencies: {
- 'test-package-with-one-dep': '0.0.0',
- 'test-repo-url-https': '0.0.1'
- }
-}
-
-test('setup', function (t) {
- fs.writeFileSync(
- path.join(pkg, 'package.json'),
- JSON.stringify(json, null, 2)
- )
- mr({port: common.port}, function (er, s) {
- common.npm(
- [
- '--registry', common.registry,
- 'install'
- ],
- EXEC_OPTS,
- function (er, c) {
- if (er) throw er
- t.equal(c, 0, 'install ran without issue')
- s.close()
- t.end()
- }
- )
- })
-})
-
-test('npm ls --dev', function (t) {
- common.npm(['ls', '--dev'], EXEC_OPTS, function (er, code, stdout) {
- if (er) throw er
- t.equal(code, 0, 'ls --dev ran without issue')
- t.has(
- stdout,
- /test-package-with-one-dep@0\.0\.0/,
- 'output contains test-package-with-one-dep@0.0.0'
- )
- t.has(
- stdout,
- /test-repo-url-https@0\.0\.1/,
- 'output contains test-repo-url-https@0.0.1'
- )
- t.doesNotHave(
- stdout,
- /test-repo-url-ssh@0\.0\.1/,
- 'output does NOT contain test-repo-url-ssh@0.0.1'
- )
- t.end()
- })
-})
-
-test('npm ls --only=development', function (t) {
- common.npm(['ls', '--only=development'], EXEC_OPTS, function (er, code, stdout) {
- if (er) throw er
- t.equal(code, 0, 'ls --only=development ran without issue')
- t.has(
- stdout,
- /test-package-with-one-dep@0\.0\.0/,
- 'output contains test-package-with-one-dep@0.0.0'
- )
- t.end()
- })
-})
-
-test('npm ls --only=dev', function (t) {
- common.npm(['ls', '--only=dev'], EXEC_OPTS, function (er, code, stdout) {
- if (er) throw er
- t.equal(code, 0, 'ls --only=dev ran without issue')
- t.has(
- stdout,
- /test-package-with-one-dep@0\.0\.0/,
- 'output contains test-package-with-one-dep@0.0.0'
- )
- t.end()
- })
-})
-
-test('npm ls --production', function (t) {
- common.npm(['ls', '--production'], EXEC_OPTS, function (er, code, stdout) {
- if (er) throw er
- t.equal(code, 0, 'ls --production ran without issue')
- t.has(
- stdout,
- /test-package-with-one-dep@0\.0\.0/,
- 'output contains test-package-with-one-dep@0.0.0'
- )
- t.has(
- stdout,
- /test-repo-url-ssh@0\.0\.1/,
- 'output contains test-repo-url-ssh@0.0.1'
- )
- t.doesNotHave(
- stdout,
- /test-repo-url-https@0\.0\.1/,
- 'output does NOT contain test-repo-url-https@0.0.1'
- )
- t.end()
- })
-})
-
-test('npm ls --prod', function (t) {
- common.npm(['ls', '--prod'], EXEC_OPTS, function (er, code, stdout) {
- if (er) throw er
- t.equal(code, 0, 'ls --prod ran without issue')
- t.has(
- stdout,
- /test-package-with-one-dep@0\.0\.0/,
- 'output contains test-package-with-one-dep@0.0.0'
- )
- t.end()
- })
-})
-
-test('npm ls --only=production', function (t) {
- common.npm(['ls', '--only=production'], EXEC_OPTS, function (er, code, stdout) {
- if (er) throw er
- t.equal(code, 0, 'ls --only=production ran without issue')
- t.has(
- stdout,
- /test-package-with-one-dep@0\.0\.0/,
- 'output contains test-package-with-one-dep@0.0.0'
- )
- t.end()
- })
-})
-
-test('npm ls --only=prod', function (t) {
- common.npm(['ls', '--only=prod'], EXEC_OPTS, function (er, code, stdout) {
- if (er) throw er
- t.equal(code, 0, 'ls --only=prod ran without issue')
- t.has(
- stdout,
- /test-package-with-one-dep@0\.0\.0/,
- 'output contains test-package-with-one-dep@0.0.0'
- )
- t.end()
- })
-})
diff --git a/deps/npm/test/tap/ls-top-errors.js b/deps/npm/test/tap/ls-top-errors.js
deleted file mode 100644
index 79a466fb12..0000000000
--- a/deps/npm/test/tap/ls-top-errors.js
+++ /dev/null
@@ -1,71 +0,0 @@
-'use strict'
-var fs = require('fs')
-var path = require('path')
-
-var test = require('tap').test
-var mkdirp = require('mkdirp')
-var rimraf = require('rimraf')
-
-var common = require('../common-tap')
-
-var pkg = common.pkg
-var pathModA = path.join(pkg, 'node_modules', 'moduleA')
-var pathModB = path.join(pkg, 'node_modules', 'moduleB')
-
-var modA = {
- name: 'moduleA',
- version: '1.0.0',
- _requiredBy: [ '#USER', '/moduleB' ],
- dependencies: {
- moduleB: '1.0.0'
- }
-}
-var modB = {
- name: 'moduleB',
- version: '1.0.0',
- _requiredBy: [ '/moduleA' ],
- dependencies: {
- moduleA: '1.0.0'
- }
-}
-
-function setup () {
- mkdirp.sync(pkg)
- fs.writeFileSync(
- path.join(pkg, 'package.json'),
- '{broken json'
- )
- mkdirp.sync(pathModA)
- fs.writeFileSync(
- path.join(pathModA, 'package.json'),
- JSON.stringify(modA, null, 2)
- )
- mkdirp.sync(pathModB)
- fs.writeFileSync(
- path.join(pathModB, 'package.json'),
- JSON.stringify(modB, null, 2)
- )
-}
-
-function cleanup () {
- rimraf.sync(pkg)
-}
-
-test('setup', function (t) {
- cleanup()
- setup()
- t.end()
-})
-
-test('ls-top-errors', function (t) {
- common.npm(['ls'], {cwd: pkg}, function (er, code, stdout, stderr) {
- t.ifErr(er, 'install finished successfully')
- t.match(stderr, /Failed to parse json/)
- t.end()
- })
-})
-
-test('cleanup', function (t) {
- cleanup()
- t.end()
-})
diff --git a/deps/npm/test/tap/ls.js b/deps/npm/test/tap/ls.js
deleted file mode 100644
index 9dd3779b3d..0000000000
--- a/deps/npm/test/tap/ls.js
+++ /dev/null
@@ -1,222 +0,0 @@
-'use strict'
-var test = require('tap').test
-var path = require('path')
-var rimraf = require('rimraf')
-var common = require('../common-tap.js')
-var basepath = common.pkg
-var fixturepath = path.resolve(basepath, 'npm-test-files')
-var pkgpath = path.resolve(fixturepath, 'npm-test-ls')
-var Tacks = require('tacks')
-var File = Tacks.File
-var Dir = Tacks.Dir
-
-test('ls without arg', function (t) {
- var fixture = new Tacks(
- Dir({
- 'npm-test-ls': Dir({
- 'package.json': File({
- name: 'npm-test-ls',
- version: '1.0.0',
- dependencies: {
- 'dep': 'file:../dep'
- }
- })
- }),
- 'dep': Dir({
- 'package.json': File({
- name: 'dep',
- version: '1.0.0'
- })
- })
- })
- )
- withFixture(t, fixture, function (done) {
- common.npm([
- 'ls', '--json'
- ], {
- cwd: pkgpath
- }, function (err, code, stdout, stderr) {
- t.ifErr(err, 'ls succeeded')
- t.equal(0, code, 'exit 0 on ls')
- var pkg = JSON.parse(stdout)
- var deps = pkg.dependencies
- t.ok(deps.dep, 'dep present')
- done()
- })
- })
-})
-
-test('ls with filter arg', function (t) {
- var fixture = new Tacks(
- Dir({
- 'npm-test-ls': Dir({
- 'package.json': File({
- name: 'npm-test-ls',
- version: '1.0.0',
- dependencies: {
- 'dep': 'file:../dep'
- }
- })
- }),
- 'dep': Dir({
- 'package.json': File({
- name: 'dep',
- version: '1.0.0'
- })
- }),
- 'otherdep': Dir({
- 'package.json': File({
- name: 'otherdep',
- version: '1.0.0'
- })
- })
- })
- )
- withFixture(t, fixture, function (done) {
- common.npm([
- 'ls', 'dep',
- '--json'
- ], {
- cwd: path.join(fixturepath, 'npm-test-ls')
- }, function (err, code, stdout, stderr) {
- t.ifErr(err, 'ls succeeded')
- t.equal(0, code, 'exit 0 on ls')
- var pkg = JSON.parse(stdout)
- var deps = pkg.dependencies
- t.ok(deps.dep, 'dep present')
- t.notOk(deps.otherdep, 'other dep not present')
- done()
- })
- })
-})
-
-test('ls with missing filtered arg', function (t) {
- var fixture = new Tacks(
- Dir({
- 'npm-test-ls': Dir({
- 'package.json': File({
- name: 'npm-test-ls',
- version: '1.0.0',
- dependencies: {
- 'dep': 'file:../dep'
- }
- })
- }),
- 'dep': Dir({
- 'package.json': File({
- name: 'dep',
- version: '1.0.0'
- })
- })
- })
- )
- withFixture(t, fixture, function (done) {
- common.npm([
- 'ls', 'notadep',
- '--json'
- ], {
- cwd: path.join(fixturepath, 'npm-test-ls')
- }, function (err, code, stdout, stderr) {
- t.ifErr(err, 'ls succeeded')
- t.equal(1, code, 'exit 1 on ls')
- var pkg = JSON.parse(stdout)
- var deps = pkg.dependencies
- t.notOk(deps, 'deps missing')
- t.done()
- })
- })
-})
-
-test('ls with prerelease pkg', function (t) {
- var fixture = new Tacks(
- Dir({
- 'npm-test-ls': Dir({
- 'package.json': File({
- name: 'npm-test-ls',
- version: '1.0.0',
- dependencies: {
- 'dep': 'file:../dep'
- }
- })
- }),
- 'dep': Dir({
- 'package.json': File({
- name: 'dep',
- version: '1.0.0-pre'
- })
- })
- })
- )
- withFixture(t, fixture, function (done) {
- common.npm([
- 'ls', 'dep',
- '--json'
- ], {
- cwd: path.join(fixturepath, 'npm-test-ls')
- }, function (err, code, stdout, stderr) {
- t.ifErr(err, 'ls succeeded')
- t.equal(0, code, 'exit 0 on ls')
- var pkg = JSON.parse(stdout)
- var deps = pkg.dependencies
- t.ok(deps.dep, 'dep present')
- t.done()
- })
- })
-})
-
-test('cleanup', function (t) {
- rimraf.sync(basepath)
- t.done()
-})
-
-test('ls parseable long', function (t) {
- var fixture = new Tacks(
- Dir({
- 'npm-test-ls': Dir({
- 'package.json': File({
- name: 'npm-test-ls',
- version: '1.0.0',
- dependencies: {
- 'dep': 'file:../dep'
- }
- })
- }),
- 'dep': Dir({
- 'package.json': File({
- name: 'dep',
- version: '1.0.0'
- })
- })
- })
- )
- withFixture(t, fixture, function (done) {
- common.npm([
- 'ls', '--parseable', '--long'
- ], {
- cwd: pkgpath
- }, function (err, code, stdout, stderr) {
- t.ifErr(err, 'ls succeeded')
- t.equal(0, code, 'exit 0 on ls')
- t.notMatch(stdout, /undefined/, 'must not output undefined for non-symlinked items')
- done()
- })
- })
-})
-
-function withFixture (t, fixture, tester) {
- fixture.create(fixturepath)
- common.npm(['install'], {
- cwd: path.join(fixturepath, 'npm-test-ls')
- }, checkAndTest)
- function checkAndTest (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()
- }
-}
diff --git a/deps/npm/test/tap/meta-test-flaky-root-ownership-test.js b/deps/npm/test/tap/meta-test-flaky-root-ownership-test.js
deleted file mode 100644
index 24dd9e3d95..0000000000
--- a/deps/npm/test/tap/meta-test-flaky-root-ownership-test.js
+++ /dev/null
@@ -1,20 +0,0 @@
-const t = require('tap')
-if (!process.getuid || process.getuid() !== 0 || !process.env.SUDO_UID || !process.env.SUDO_GID) {
- t.pass('this test only runs in sudo mode')
- t.end()
- process.exit(0)
-}
-
-const common = require('../common-tap.js')
-const fs = require('fs')
-const mkdirp = require('mkdirp')
-mkdirp.sync(common.cache + '/root/owned')
-fs.writeFileSync(common.cache + '/root/owned/file.txt', 'should be chowned')
-const chown = require('chownr')
-
-// this will fire after t.teardown() but before process.on('exit')
-setTimeout(() => {
- chown.sync(common.cache, +process.env.SUDO_UID, +process.env.SUDO_GID)
-}, 100)
-
-t.pass('this is fine')
diff --git a/deps/npm/test/tap/nerf-dart.js b/deps/npm/test/tap/nerf-dart.js
deleted file mode 100644
index d205e527cc..0000000000
--- a/deps/npm/test/tap/nerf-dart.js
+++ /dev/null
@@ -1,32 +0,0 @@
-// taken from https://raw.githubusercontent.com/indexzero/npm/bd3cad01fbd3ab481d2f5da441b9eead16029123/test/tap/config-nerf-dart.js
-// originally written by Charlie Robbins, https://github.com/indexzero
-var test = require('tap').test
-var toNerfDart = require('../../lib/config/nerf-dart.js')
-
-function validNerfDart (uri, valid) {
- if (!valid) valid = '//registry.npmjs.org/'
- test(uri, function (t) {
- t.equal(toNerfDart(uri), valid)
- t.end()
- })
-}
-
-validNerfDart('http://registry.npmjs.org')
-validNerfDart('http://registry.npmjs.org/some-package')
-validNerfDart('http://registry.npmjs.org/some-package?write=true')
-validNerfDart('http://user:pass@registry.npmjs.org/some-package?write=true')
-validNerfDart('http://registry.npmjs.org/#random-hash')
-validNerfDart('http://registry.npmjs.org/some-package#random-hash')
-
-validNerfDart(
- 'http://relative.couchapp.npm/design/-/rewrite/',
- '//relative.couchapp.npm/design/-/rewrite/'
-)
-validNerfDart(
- 'http://relative.couchapp.npm:8080/design/-/rewrite/',
- '//relative.couchapp.npm:8080/design/-/rewrite/'
-)
-validNerfDart(
- 'http://relative.couchapp.npm:8080/design/-/rewrite/some-package',
- '//relative.couchapp.npm:8080/design/-/rewrite/'
-)
diff --git a/deps/npm/test/tap/nested-extraneous.js b/deps/npm/test/tap/nested-extraneous.js
deleted file mode 100644
index 1764a41c75..0000000000
--- a/deps/npm/test/tap/nested-extraneous.js
+++ /dev/null
@@ -1,53 +0,0 @@
-var common = require('../common-tap.js')
-var test = require('tap').test
-var mkdirp = require('mkdirp')
-var fs = require('fs')
-var rimraf = require('rimraf')
-var path = require('path')
-
-var pkg = common.pkg
-var pj = {
- name: 'nested-extraneous',
- version: '1.2.3'
-}
-
-var dep = path.resolve(pkg, 'node_modules', 'dep')
-var deppj = {
- name: 'nested-extraneous-dep',
- version: '1.2.3',
- dependencies: {
- 'nested-extra-depdep': '*'
- }
-}
-
-var depdep = path.resolve(dep, 'node_modules', 'depdep')
-var depdeppj = {
- name: 'nested-extra-depdep',
- version: '1.2.3'
-}
-
-test('setup', function (t) {
- rimraf.sync(pkg)
- mkdirp.sync(depdep)
- fs.writeFileSync(path.resolve(pkg, 'package.json'), JSON.stringify(pj))
- fs.writeFileSync(path.resolve(dep, 'package.json'), JSON.stringify(deppj))
- fs.writeFileSync(path.resolve(depdep, 'package.json'), JSON.stringify(depdeppj))
- t.end()
-})
-
-test('test', function (t) {
- common.npm(['ls'], {
- cwd: pkg
- }, function (er, code, sto, ste) {
- if (er) throw er
- t.notEqual(code, 0)
- t.notSimilar(ste, /depdep/)
- t.notSimilar(sto, /depdep/)
- t.end()
- })
-})
-
-test('clean', function (t) {
- rimraf.sync(pkg)
- t.end()
-})
diff --git a/deps/npm/test/tap/no-global-warns.js b/deps/npm/test/tap/no-global-warns.js
deleted file mode 100644
index 1c39fd7954..0000000000
--- a/deps/npm/test/tap/no-global-warns.js
+++ /dev/null
@@ -1,65 +0,0 @@
-'use strict'
-var path = require('path')
-var test = require('tap').test
-var mkdirp = require('mkdirp')
-var writeFileSync = require('fs').writeFileSync
-var common = require('../common-tap.js')
-
-var base = common.pkg
-var mockGlobal = path.join(base, 'global')
-var toInstall = path.join(base, 'to-install')
-
-var config = 'prefix = ' + base
-var configPath = path.join(base, '_npmrc')
-
-// use a clean environment for this test
-// otherwise local dev-time npm settings can throw it off
-var OPTS = {
- env: Object.keys(process.env).filter(function (k) {
- return !/^npm_config_/i.test(k)
- }).reduce(function (set, k) {
- set[k] = process.env[k]
- return set
- }, {})
-}
-
-var installJSON = {
- name: 'to-install',
- version: '1.0.0',
- description: '',
- main: 'index.js',
- scripts: {
- test: 'echo "Error: no test specified" && exit 1'
- },
- author: '',
- license: 'ISC'
-}
-
-test('setup', function (t) {
- mkdirp.sync(mockGlobal)
- mkdirp.sync(toInstall)
- writeFileSync(
- path.join(toInstall, 'package.json'),
- JSON.stringify(installJSON, null, 2)
- )
- writeFileSync(configPath, config)
- t.end()
-})
-
-test('no-global-warns', function (t) {
- common.npm(
- [
- 'install', '-g',
- '--userconfig=' + configPath,
- toInstall
- ],
- OPTS,
- function (err, code, stdout, stderr) {
- t.ifError(err, 'installed w/o error')
- const preWarn = 'npm WARN You are using a pre-release version ' +
- 'of node and things may not work as expected'
- stderr = stderr.trim().replace(preWarn, '')
- t.is(stderr, '', 'no warnings printed to stderr')
- t.end()
- })
-})
diff --git a/deps/npm/test/tap/no-scan-full-global-dir.js b/deps/npm/test/tap/no-scan-full-global-dir.js
deleted file mode 100644
index 7501b881c9..0000000000
--- a/deps/npm/test/tap/no-scan-full-global-dir.js
+++ /dev/null
@@ -1,107 +0,0 @@
-'use strict'
-var fs = require('fs')
-var path = require('path')
-var test = require('tap').test
-var requireInject = require('require-inject')
-var npm = require('../../lib/npm.js')
-
-// XXX update this when rpt's realpath.js is extracted out
-var rptRealpath = require.resolve('read-package-tree/realpath.js')
-
-const common = require('../common-tap.js')
-const pkg = common.pkg
-var packages = {
- test: {package: {name: 'test'}, path: pkg, children: ['abc', 'def', 'ghi', 'jkl']},
- abc: {package: {name: 'abc'}, path: path.join(pkg, 'node_modules', 'abc')},
- def: {package: {name: 'def'}, path: path.join(pkg, 'node_modules', 'def')},
- ghi: {package: {name: 'ghi'}, path: path.join(pkg, 'node_modules', 'ghi')},
- jkl: {package: {name: 'jkl'}, path: path.join(pkg, 'node_modules', 'jkl')}
-}
-var dirs = {}
-var files = {}
-Object.keys(packages).forEach(function (name) {
- dirs[path.join(packages[name].path, 'node_modules')] = packages[name].children || []
- files[path.join(packages[name].path, 'package.json')] = packages[name].package
-})
-
-var mockReaddir = function (name, cb) {
- if (dirs[name]) return cb(null, dirs[name])
- var er = new Error('No such mock: ' + name)
- er.code = 'ENOENT'
- cb(er)
-}
-var mockReadPackageJson = function (file, cb) {
- if (files[file]) return cb(null, files[file])
- var er = new Error('No such mock: ' + file)
- er.code = 'ENOENT'
- cb(er)
-}
-var mockFs = Object.create(fs)
-mockFs.realpath = function (dir, cb) {
- return cb(null, dir)
-}
-
-const mockRptRealpath = path => Promise.resolve(path)
-
-test('setup', function (t) {
- npm.load(function () {
- t.pass('npm loaded')
- t.end()
- })
-})
-
-test('installer', function (t) {
- t.plan(1)
- var installer = requireInject('../../lib/install.js', {
- 'fs': mockFs,
- 'readdir-scoped-modules': mockReaddir,
- 'read-package-json': mockReadPackageJson,
- 'mkdirp': function (path, cb) { cb() },
- [rptRealpath]: mockRptRealpath
- })
-
- var Installer = installer.Installer
- class TestInstaller extends Installer {
- constructor (where, dryrun, args) {
- super(where, dryrun, args)
- this.global = true
- }
- loadArgMetadata (cb) {
- this.args = this.args.map(function (arg) { return {name: arg} })
- cb()
- }
- }
-
- var inst = new TestInstaller(pkg, false, ['def', 'abc'])
- inst.loadCurrentTree(function () {
- var kids = inst.currentTree.children.map(function (child) { return child.package.name })
- t.isDeeply(kids, ['abc', 'def'])
- t.end()
- })
-})
-
-test('uninstaller', function (t) {
- t.plan(1)
- var uninstaller = requireInject('../../lib/uninstall.js', {
- 'fs': mockFs,
- 'readdir-scoped-modules': mockReaddir,
- 'read-package-json': mockReadPackageJson,
- 'mkdirp': function (path, cb) { cb() },
- [rptRealpath]: mockRptRealpath
- })
-
- var Uninstaller = uninstaller.Uninstaller
- class TestUninstaller extends Uninstaller {
- constructor (where, dryrun, args) {
- super(where, dryrun, args)
- this.global = true
- }
- }
-
- var uninst = new TestUninstaller(pkg, false, ['ghi', 'jkl'])
- uninst.loadCurrentTree(function () {
- var kids = uninst.currentTree.children.map(function (child) { return child.package.name })
- t.isDeeply(kids, ['ghi', 'jkl'])
- t.end()
- })
-})
diff --git a/deps/npm/test/tap/noargs-install-config-save.js b/deps/npm/test/tap/noargs-install-config-save.js
deleted file mode 100644
index cb1af408ab..0000000000
--- a/deps/npm/test/tap/noargs-install-config-save.js
+++ /dev/null
@@ -1,76 +0,0 @@
-var common = require('../common-tap.js')
-var test = require('tap').test
-var fs = require('fs')
-var rimraf = require('rimraf')
-var mkdirp = require('mkdirp')
-
-var mr = require('npm-registry-mock')
-
-var pkg = common.pkg
-
-function writePackageJson () {
- rimraf.sync(pkg)
- mkdirp.sync(pkg)
- mkdirp.sync(pkg + '/cache')
-
- fs.writeFileSync(pkg + '/package.json', JSON.stringify({
- 'author': 'Rocko Artischocko',
- 'name': 'noargs',
- 'version': '0.0.0',
- 'devDependencies': {
- 'underscore': '1.3.1'
- }
- }), 'utf8')
-}
-
-var env = {
- 'npm_config_save': true,
- 'npm_config_registry': common.registry,
- 'npm_config_cache': pkg + '/cache',
- HOME: process.env.HOME,
- Path: process.env.PATH,
- PATH: process.env.PATH
-}
-var OPTS = {
- cwd: pkg,
- env: env
-}
-
-test('does not update the package.json with empty arguments', function (t) {
- writePackageJson()
- t.plan(2)
-
- mr({ port: common.port }, function (er, s) {
- common.npm('install', OPTS, function (er, code, stdout, stderr) {
- if (er) throw er
- t.is(code, 0)
- if (code !== 0) {
- console.error('#', stdout)
- console.error('#', stderr)
- }
- var text = JSON.stringify(fs.readFileSync(pkg + '/package.json', 'utf8'))
- s.close()
- t.equal(text.indexOf('"dependencies'), -1, 'dependencies do not exist in file')
- })
- })
-})
-
-test('updates the package.json (adds dependencies) with an argument', function (t) {
- writePackageJson()
- t.plan(2)
-
- mr({ port: common.port }, function (er, s) {
- common.npm(['install', 'underscore', '-P'], OPTS, function (er, code, stdout, stderr) {
- if (er) throw er
- t.is(code, 0)
- s.close()
- var text = JSON.stringify(fs.readFileSync(pkg + '/package.json', 'utf8'))
- t.notEqual(text.indexOf('"dependencies'), -1, 'dependencies exist in file')
- })
- })
-})
-
-test('cleanup', function (t) {
- rimraf.sync(pkg)
- t.end()
-})
diff --git a/deps/npm/test/tap/node-modules-path-munge.js b/deps/npm/test/tap/node-modules-path-munge.js
deleted file mode 100644
index fb116806c8..0000000000
--- a/deps/npm/test/tap/node-modules-path-munge.js
+++ /dev/null
@@ -1,39 +0,0 @@
-var common = require('../common-tap.js')
-var t = require('tap')
-var fs = require('fs')
-var rimraf = require('rimraf')
-var mkdirp = require('mkdirp')
-var path = require('path')
-var dir = path.join(common.pkg, 'my_node_modules')
-var script = process.platform === 'win32' ? 'echo %PATH%' : 'echo $PATH'
-
-t.test('setup', function (t) {
- rimraf.sync(dir)
- mkdirp.sync(dir)
- fs.writeFileSync(dir + '/package.json', JSON.stringify({
- name: 'my_node_modules',
- version: '1.2.3',
- scripts: {
- test: script
- }
- }))
- t.end()
-})
-
-t.test('verify PATH is munged right', function (t) {
- common.npm(['test'], { cwd: dir }, function (err, code, stdout, stderr) {
- if (err) {
- throw err
- }
- t.equal(code, 0, 'exit ok')
- t.notOk(stderr, 'should have no stderr')
- var expect = path.resolve(dir, 'node_modules', '.bin').toLowerCase()
- t.contains(stdout.toLowerCase(), expect)
- t.end()
- })
-})
-
-t.test('cleanup', function (t) {
- rimraf.sync(dir)
- t.end()
-})
diff --git a/deps/npm/test/tap/normalize-package-explode.js b/deps/npm/test/tap/normalize-package-explode.js
deleted file mode 100644
index 57faec8b60..0000000000
--- a/deps/npm/test/tap/normalize-package-explode.js
+++ /dev/null
@@ -1,26 +0,0 @@
-'use strict'
-var test = require('tap').test
-var log = require('npmlog')
-var npm = require('../../lib/npm.js')
-
-var idealTree = {
- package: {
- name: 'a b c',
- version: '3.what'
- },
- children: [],
- warnings: []
-}
-
-test('setup', function (t) {
- npm.load({}, t.end)
-})
-
-test('validate-tree', function (t) {
- log.disableProgress()
- var validateTree = require('../../lib/install/validate-tree.js')
- validateTree(idealTree, log.newGroup('validate'), function (er) {
- t.pass("we didn't crash")
- t.end()
- })
-})
diff --git a/deps/npm/test/tap/npm-api-not-loaded-error.js b/deps/npm/test/tap/npm-api-not-loaded-error.js
deleted file mode 100644
index 8bf2635038..0000000000
--- a/deps/npm/test/tap/npm-api-not-loaded-error.js
+++ /dev/null
@@ -1,48 +0,0 @@
-var test = require('tap').test
-const common = require('../common-tap.js')
-var npm = require('../..')
-var path = require('path')
-var rimraf = require('rimraf')
-var npmrc = path.join(common.pkg, 'npmrc')
-var fs = require('fs')
-
-test('setup', function (t) {
- fs.writeFileSync(npmrc, 'foo = bar\n', 'ascii')
- t.end()
-})
-
-test('calling set/get on config pre-load should throw', function (t) {
- var threw = true
- try {
- npm.config.get('foo')
- threw = false
- } catch (er) {
- t.equal(er.message, 'npm.load() required')
- } finally {
- t.ok(threw, 'get before load should throw')
- }
-
- threw = true
- try {
- npm.config.set('foo', 'bar')
- threw = false
- } catch (er) {
- t.equal(er.message, 'npm.load() required')
- } finally {
- t.ok(threw, 'set before load should throw')
- }
-
- npm.load({ userconfig: npmrc }, function (er) {
- if (er) throw er
-
- t.equal(npm.config.get('foo'), 'bar')
- npm.config.set('foo', 'baz')
- t.equal(npm.config.get('foo'), 'baz')
- t.end()
- })
-})
-
-test('cleanup', function (t) {
- rimraf.sync(npmrc)
- t.end()
-})
diff --git a/deps/npm/test/tap/onload.js b/deps/npm/test/tap/onload.js
deleted file mode 100644
index 4750fa6f88..0000000000
--- a/deps/npm/test/tap/onload.js
+++ /dev/null
@@ -1,39 +0,0 @@
-var path = require('path')
-var test = require('tap').test
-var rimraf = require('rimraf')
-var common = require('../common-tap.js')
-var opts = { cwd: common.pkg }
-var binDir = '../../node_modules/.bin'
-var fixture = path.resolve(__dirname, binDir)
-var onload = path.resolve(__dirname, '../fixtures/onload.js')
-
-test('setup', function (t) {
- rimraf.sync(path.join(common.pkg, 'node_modules'))
- t.end()
-})
-
-test('npm bin with valid onload script', function (t) {
- var args = ['--onload', onload, 'bin']
- common.npm(args, opts, function (err, code, stdout, stderr) {
- t.ifError(err, 'bin ran without issue')
- t.equal(stderr.trim(), 'called onload')
- t.equal(code, 0, 'exit ok')
- t.equal(stdout, fixture + '\n')
- t.end()
- })
-})
-
-test('npm bin with invalid onload script', function (t) {
- var onloadScript = onload + 'jsfd'
- var args = ['--onload', onloadScript, '--loglevel=warn', 'bin']
- common.npm(args, opts, function (err, code, stdout, stderr) {
- t.ifError(err, 'bin ran without issue')
- t.match(stderr, /npm WARN onload-script failed to require onload script/)
- t.match(stderr, /MODULE_NOT_FOUND/)
- t.notEqual(stderr.indexOf(onloadScript), -1)
- t.equal(code, 0, 'exit ok')
- var res = path.resolve(stdout)
- t.equal(res, fixture + '\n')
- t.end()
- })
-})
diff --git a/deps/npm/test/tap/optional-metadep-rollback-collision.js b/deps/npm/test/tap/optional-metadep-rollback-collision.js
deleted file mode 100644
index b62d63d7f7..0000000000
--- a/deps/npm/test/tap/optional-metadep-rollback-collision.js
+++ /dev/null
@@ -1,188 +0,0 @@
-'use strict'
-/* eslint-disable camelcase */
-var fs = require('graceful-fs')
-var path = require('path')
-
-var mkdirp = require('mkdirp')
-var test = require('tap').test
-
-var common = require('../common-tap.js')
-
-var pkg = common.pkg
-var deps = path.resolve(pkg, 'deps')
-var opdep = path.resolve(pkg, 'node_modules', 'opdep')
-var cache = common.cache
-var createServer = require('http').createServer
-var mr = require('npm-registry-mock')
-var serverPort = 27991
-
-var json = {
- name: 'optional-metadep-rollback-collision',
- version: '1.0.0',
- description: 'let\'s just see about that race condition',
- optionalDependencies: {
- opdep: 'file:./deps/opdep'
- }
-}
-
-var d1 = {
- name: 'd1',
- version: '1.0.0',
- description: 'I FAIL CONSTANTLY',
- scripts: {
- preinstall: 'sleep 1'
- },
- dependencies: {
- foo: 'http://localhost:' + serverPort + '/'
- }
-}
-
-var d2 = {
- name: 'd2',
- version: '1.0.0',
- description: 'how do you *really* know you exist?',
- scripts: {
- postinstall: 'node blart.js'
- },
- dependencies: {
- 'request': '^0.9.0',
- mkdirp: '^0.3.5',
- wordwrap: '^0.0.2'
- }
-}
-
-var opdep_json = {
- name: 'opdep',
- version: '1.0.0',
- description: 'To explode, of course!',
- main: 'index.js',
- dependencies: {
- d1: 'file:../d1',
- d2: 'file:../d2'
- }
-}
-
-var blart = `
-var rando = require('crypto').randomBytes
-var resolve = require('path').resolve
-
-var mkdirp = require('mkdirp')
-var rimraf = require('rimraf')
-var writeFile = require('graceful-fs').writeFile
-
-var BASEDIR = resolve(__dirname, 'arena')
-
-var keepItGoingLouder = {}
-var writers = 0
-var errors = 0
-
-function gensym () { return rando(16).toString('hex') }
-
-function writeAlmostForever (filename) {
- if (!keepItGoingLouder[filename]) {
- writers--
- if (writers < 1) return done()
- } else {
- writeFile(filename, keepItGoingLouder[filename], function (err) {
- if (err) errors++
-
- writeAlmostForever(filename)
- })
- }
-}
-
-function done () {
- rimraf(BASEDIR, function () {
- if (errors > 0) console.log('not ok - %d errors', errors)
- else console.log('ok')
- })
-}
-
-mkdirp(BASEDIR, function go () {
- for (var i = 0; i < 16; i++) {
- var filename = resolve(BASEDIR, gensym() + '.txt')
-
- keepItGoingLouder[filename] = ''
- for (var j = 0; j < 512; j++) keepItGoingLouder[filename] += filename
-
- writers++
- writeAlmostForever(filename)
- }
-
- setTimeout(function viktor () {
- // kill all the writers
- keepItGoingLouder = {}
- }, 3 * 1000)
-})
-`
-
-test('setup', function (t) {
- const badServer = createServer(function (req, res) {
- setTimeout(function () {
- res.writeHead(404)
- res.end()
- }, 1000)
- }).listen(serverPort, () => t.parent.teardown(() => badServer.close()))
-
- mkdirp.sync(pkg)
- fs.writeFileSync(
- path.join(pkg, 'package.json'),
- JSON.stringify(json, null, 2)
- )
-
- mkdirp.sync(path.join(deps, 'd1'))
- fs.writeFileSync(
- path.join(deps, 'd1', 'package.json'),
- JSON.stringify(d1, null, 2)
- )
-
- mkdirp.sync(path.join(deps, 'd2'))
- fs.writeFileSync(
- path.join(deps, 'd2', 'package.json'),
- JSON.stringify(d2, null, 2)
- )
- fs.writeFileSync(path.join(deps, 'd2', 'blart.js'), blart)
-
- mkdirp.sync(path.join(deps, 'opdep'))
- fs.writeFileSync(
- path.join(deps, 'opdep', 'package.json'),
- JSON.stringify(opdep_json, null, 2)
- )
- mr({ port: common.port }, function (er, server) {
- t.parent.teardown(() => server.close())
- t.end()
- })
-})
-
-test('go go test racer', t => common.npm(
- [
- '--prefix', pkg,
- '--fetch-retries', '0',
- '--loglevel', 'error',
- '--no-progress',
- '--registry', common.registry,
- '--parseable',
- '--cache', cache,
- 'install'
- ],
- {
- cwd: pkg,
- env: {
- PATH: process.env.PATH,
- Path: process.env.Path
- },
- stdio: 'pipe'
- }
-).spread((code, stdout, stderr) => {
- t.comment(stdout.trim())
- t.comment(stderr.trim())
- t.is(code, 0, 'npm install exited with code 0')
- t.notOk(/not ok/.test(stdout), 'should not contain the string \'not ok\'')
-}))
-
-test('verify results', function (t) {
- t.throws(function () {
- fs.statSync(opdep)
- })
- t.end()
-})
diff --git a/deps/npm/test/tap/org.js b/deps/npm/test/tap/org.js
deleted file mode 100644
index 7315cf0b6f..0000000000
--- a/deps/npm/test/tap/org.js
+++ /dev/null
@@ -1,136 +0,0 @@
-'use strict'
-
-var test = require('tap').test
-var common = require('../common-tap.js')
-
-var mr = common.fakeRegistry.compat
-
-var server
-
-test('setup', function (t) {
- mr({port: common.port}, function (err, s) {
- t.ifError(err, 'registry mocked successfully')
- server = s
- t.end()
- })
-})
-
-const names = ['add', 'set']
-const roles = ['developer', 'admin', 'owner']
-
-names.forEach(function (name) {
- test('org ' + name + ' [orgname] [username]: defaults to developer', function (t) {
- const membershipData = {
- org: {
- name: 'myorg',
- size: 1
- },
- user: 'myuser',
- role: 'developer'
- }
- server.put('/-/org/myorg/user', JSON.stringify({
- user: 'myuser'
- })).reply(200, membershipData)
- common.npm([
- 'org', 'add', 'myorg', 'myuser',
- '--json',
- '--registry', common.registry,
- '--loglevel', 'silent'
- ], {}, function (err, code, stdout, stderr) {
- t.ifError(err, 'npm org')
-
- t.equal(code, 0, 'exited OK')
- t.equal(stderr, '', 'no error output')
-
- t.same(JSON.parse(stdout), membershipData)
- t.end()
- })
- })
-
- roles.forEach(function (role) {
- test('org ' + name + ' [orgname] [username]: accepts role ' + role, function (t) {
- const membershipData = {
- org: {
- name: 'myorg',
- size: 1
- },
- user: 'myuser',
- role: role
- }
- server.put('/-/org/myorg/user', JSON.stringify({
- user: 'myuser'
- })).reply(200, membershipData)
- common.npm([
- 'org', name, 'myorg', 'myuser',
- '--json',
- '--registry', common.registry,
- '--loglevel', 'silent'
- ], {}, function (err, code, stdout, stderr) {
- t.ifError(err, 'npm org')
-
- t.equal(code, 0, 'exited OK')
- t.equal(stderr, '', 'no error output')
-
- t.same(JSON.parse(stdout), membershipData)
- t.end()
- })
- })
- })
-})
-
-test('org rm [orgname] [username]', function (t) {
- const membershipData = {
- otheruser: 'admin'
- }
- server.delete('/-/org/myorg/user', JSON.stringify({
- user: 'myuser'
- })).reply(204, {})
- server.get('/-/org/myorg/user')
- .reply(200, membershipData)
- common.npm([
- 'org', 'rm', 'myorg', 'myuser',
- '--json',
- '--registry', common.registry,
- '--loglevel', 'silent'
- ], {}, function (err, code, stdout, stderr) {
- t.ifError(err, 'npm org')
-
- t.equal(code, 0, 'exited OK')
- t.equal(stderr, '', 'no error output')
- t.deepEqual(JSON.parse(stdout), {
- user: 'myuser',
- org: 'myorg',
- deleted: true,
- userCount: 1
- }, 'got useful info')
- t.end()
- })
-})
-
-test('org ls [orgname]', function (t) {
- const membershipData = {
- username: 'admin',
- username2: 'foo'
- }
- server.get('/-/org/myorg/user')
- .reply(200, membershipData)
- common.npm([
- 'org', 'ls', 'myorg',
- '--json',
- '--registry', common.registry,
- '--loglevel', 'silent'
- ], {}, function (err, code, stdout, stderr) {
- t.ifError(err, 'npm org')
- t.equal(code, 0, 'exited OK')
- t.equal(stderr, '', 'no error output')
- t.same(JSON.parse(stdout), membershipData, 'outputs members')
- t.end()
- })
-})
-
-test('cleanup', function (t) {
- t.pass('cleaned up')
- server.done()
- server.close()
- t.end()
-})
diff --git a/deps/npm/test/tap/outdated-bad-read-tree.js b/deps/npm/test/tap/outdated-bad-read-tree.js
deleted file mode 100644
index eb4bac36ef..0000000000
--- a/deps/npm/test/tap/outdated-bad-read-tree.js
+++ /dev/null
@@ -1,21 +0,0 @@
-'use strict'
-var test = require('tap').test
-var requireInject = require('require-inject')
-var npm = require('../../lib/npm.js')
-
-test('setup', function (t) {
- npm.load({progress: false}, t.end)
-})
-
-test('outdated', function (t) {
- var rptError = new Error('read-package-tree')
- var outdated = requireInject('../../lib/outdated.js', {
- 'read-package-tree': function (dir, cb) {
- cb(rptError)
- }
- })
- outdated([], function (err) {
- t.is(err, rptError)
- t.end()
- })
-})
diff --git a/deps/npm/test/tap/outdated-color.js b/deps/npm/test/tap/outdated-color.js
deleted file mode 100644
index 11c967650f..0000000000
--- a/deps/npm/test/tap/outdated-color.js
+++ /dev/null
@@ -1,75 +0,0 @@
-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 = common.pkg
-
-var EXEC_OPTS = { cwd: pkg }
-
-function hasControlCodes (str) {
- return str.length !== ansiTrim(str).length
-}
-
-function ansiTrim (str) {
- var r = new RegExp('\x1b(?:\\[(?:\\d+[ABCDEFGJKSTm]|\\d+;\\d+[Hfm]|' +
- '\\d+;\\d+;\\d+m|6n|s|u|\\?25[lh])|\\w)', 'g')
- return str.replace(r, '')
-}
-
-var json = {
- name: 'outdated-color',
- description: 'fixture',
- version: '0.0.1',
- dependencies: {
- underscore: '1.3.1'
- }
-}
-
-test('setup', function (t) {
- cleanup()
- mkdirp.sync(pkg)
- fs.writeFileSync(
- path.join(pkg, 'package.json'),
- JSON.stringify(json, null, 2)
- )
-
- process.chdir(pkg)
- t.end()
-})
-
-// note hard to automate tests for color = true
-// as npm kills the color config when it detects
-// it's not running in a tty
-test('does not use ansi styling', function (t) {
- t.plan(4)
- mr({ port: common.port }, function (er, s) { // create mock registry.
- common.npm(
- [
- '--registry', common.registry,
- 'outdated', 'underscore'
- ],
- EXEC_OPTS,
- function (err, code, stdout) {
- t.ifError(err)
- t.is(code, 1, 'npm outdated exited with code 1')
- t.ok(stdout, stdout.length)
- t.ok(!hasControlCodes(stdout))
- s.close()
- })
- })
-})
-
-test('cleanup', function (t) {
- cleanup()
- t.end()
-})
-
-function cleanup () {
- rimraf.sync(pkg)
-}
diff --git a/deps/npm/test/tap/outdated-depth.js b/deps/npm/test/tap/outdated-depth.js
deleted file mode 100644
index 368d32230a..0000000000
--- a/deps/npm/test/tap/outdated-depth.js
+++ /dev/null
@@ -1,76 +0,0 @@
-var fs = require('graceful-fs')
-var path = require('path')
-
-var mr = require('npm-registry-mock')
-var test = require('tap').test
-
-var npm = require('../../')
-var common = require('../common-tap')
-
-var pkg = common.pkg
-
-var json = {
- name: 'outdated-depth',
- version: '1.2.3',
- dependencies: {
- underscore: '1.3.1',
- 'npm-test-peer-deps': '0.0.0'
- }
-}
-
-test('setup', function (t) {
- fs.writeFileSync(
- path.join(pkg, 'package.json'),
- JSON.stringify(json, null, 2)
- )
- process.chdir(pkg)
-
- t.end()
-})
-
-test('outdated depth zero', function (t) {
- var expected = [
- pkg,
- 'underscore',
- '1.3.1',
- '1.3.1',
- '1.5.1',
- '1.3.1',
- null
- ]
-
- mr({ port: common.port }, function (er, s) {
- npm.load(
- {
- depth: 0,
- loglevel: 'silent',
- registry: common.registry
- },
- function () {
- npm.install('.', function (er) {
- if (er) throw new Error(er)
- npm.outdated(function (err, d) {
- if (err) {
- throw err
- }
- t.is(process.exitCode, 1, 'exit code set to 1')
- process.exitCode = 0
- t.deepEqual(d[0], expected)
- t.equal(d.length, 1)
- npm.config.set('depth', 1)
- npm.outdated(function (err, d) {
- t.equal(d.length, 2)
- if (err) {
- throw err
- }
- t.is(process.exitCode, 1, 'exit code set to 1')
- process.exitCode = 0
- s.close()
- t.end()
- })
- })
- })
- }
- )
- })
-})
diff --git a/deps/npm/test/tap/outdated-git.js b/deps/npm/test/tap/outdated-git.js
deleted file mode 100644
index 15db1a30c7..0000000000
--- a/deps/npm/test/tap/outdated-git.js
+++ /dev/null
@@ -1,61 +0,0 @@
-var path = require('path')
-
-var test = require('tap').test
-var mkdirp = require('mkdirp')
-var fs = require('graceful-fs')
-var rimraf = require('rimraf')
-
-var common = require('../common-tap.js')
-var npm = require('../../')
-
-// config
-var pkg = common.pkg
-var cache = common.cache
-var json = {
- name: 'outdated-git',
- author: 'Rocko Artischocko',
- description: 'fixture',
- version: '0.0.1',
- main: 'index.js',
- dependencies: {
- 'foo-github': 'robertkowalski/foo',
- 'foo-private': 'git://github.com/robertkowalski/foo-private.git',
- 'foo-private-credentials': 'git://user:pass@github.com/robertkowalski/foo-private.git'
- }
-}
-
-test('setup', function (t) {
- setup()
- t.end()
-})
-
-test('discovers new versions in outdated', function (t) {
- process.chdir(pkg)
- t.plan(7)
- npm.load({cache: cache, registry: common.registry, loglevel: 'silent'}, function () {
- npm.commands.outdated([], function (er, d) {
- t.ifError(er, 'npm outdated completed successfully')
- t.is(process.exitCode, 1, 'exitCode set to 1')
- process.exitCode = 0
- t.equal(d[0][3], 'git')
- t.equal(d[0][4], 'git')
- t.equal(d[0][5], 'github:robertkowalski/foo')
- t.equal(d[1][5], 'git://github.com/robertkowalski/foo-private.git')
- t.equal(d[2][5], 'git://user:pass@github.com/robertkowalski/foo-private.git')
- })
- })
-})
-
-test('cleanup', function (t) {
- cleanup()
- t.end()
-})
-
-function setup () {
- mkdirp.sync(cache)
- fs.writeFileSync(path.join(pkg, 'package.json'), JSON.stringify(json, null, 2), 'utf8')
-}
-
-function cleanup () {
- rimraf.sync(pkg)
-}
diff --git a/deps/npm/test/tap/outdated-json.js b/deps/npm/test/tap/outdated-json.js
deleted file mode 100644
index 77db52cc72..0000000000
--- a/deps/npm/test/tap/outdated-json.js
+++ /dev/null
@@ -1,123 +0,0 @@
-var fs = require('graceful-fs')
-var path = require('path')
-
-var mr = require('npm-registry-mock')
-var test = require('tap').test
-
-var common = require('../common-tap.js')
-var server
-
-var pkg = common.pkg
-
-var EXEC_OPTS = { cwd: pkg }
-
-var json = {
- name: 'outdated-json',
- author: 'Rockbert',
- version: '0.0.0',
- dependencies: {
- underscore: '~1.3.1'
- },
- devDependencies: {
- request: '~0.9.0'
- }
-}
-
-var expected = {
- underscore: {
- current: '1.3.3',
- wanted: '1.3.3',
- latest: '1.5.1',
- location: 'node_modules' + path.sep + 'underscore'
- },
- request: {
- current: '0.9.5',
- wanted: '0.9.5',
- latest: '2.27.0',
- location: 'node_modules' + path.sep + 'request'
- }
-}
-
-test('setup', function (t) {
- fs.writeFileSync(
- path.join(pkg, 'package.json'),
- JSON.stringify(json, null, 2)
- )
- process.chdir(pkg)
- mr({ port: common.port }, function (er, s) {
- t.ifError(er, 'mock registry should never fail to start')
- server = s
- common.npm(
- [
- '--registry', common.registry,
- '--silent',
- 'install'
- ],
- EXEC_OPTS,
- function (err, code) {
- t.ifError(err, 'npm install ran without issue')
- t.notOk(code, 'npm install ran without raising error code')
-
- t.end()
- }
- )
- })
-})
-
-test('it should log json data', function (t) {
- common.npm(
- [
- '--registry', common.registry,
- '--silent',
- '--json',
- 'outdated'
- ],
- EXEC_OPTS,
- function (err, code, stdout) {
- t.ifError(err, 'npm outdated ran without error')
- t.is(code, 1, 'npm outdated exited with code 1')
- var out
- t.doesNotThrow(function () {
- out = JSON.parse(stdout)
- }, 'output correctly parsed as JSON')
- t.deepEqual(out, expected)
-
- t.end()
- }
- )
-})
-
-test('it should log json data even when the list is empty', function (t) {
- common.npm(
- [
- 'rm',
- 'request',
- 'underscore'
- ],
- EXEC_OPTS,
- function (er, code, stdout) {
- t.ifError(er, 'run without error')
- t.is(code, 0, 'successful exit status')
- common.npm(
- [
- '--registry', common.registry,
- '--silent',
- '--json',
- 'outdated'
- ],
- EXEC_OPTS,
- function (er, code, stdout) {
- t.ifError(er, 'run without error')
- t.is(code, 0, 'successful exit status')
- t.same(JSON.parse(stdout), {}, 'got an empty object printed')
- t.end()
- }
- )
- }
- )
-})
-
-test('cleanup', function (t) {
- server.close()
- t.end()
-})
diff --git a/deps/npm/test/tap/outdated-latest.js b/deps/npm/test/tap/outdated-latest.js
deleted file mode 100644
index 073b71da91..0000000000
--- a/deps/npm/test/tap/outdated-latest.js
+++ /dev/null
@@ -1,109 +0,0 @@
-'use strict'
-const path = require('path')
-const test = require('tap').test
-const mr = require('npm-registry-mock')
-const Tacks = require('tacks')
-const File = Tacks.File
-const Dir = Tacks.Dir
-const common = require('../common-tap.js')
-
-const basedir = common.pkg
-const testdir = path.join(basedir, 'testdir')
-const cachedir = common.cache
-const globaldir = path.join(basedir, 'global')
-const tmpdir = path.join(basedir, 'tmp')
-
-const conf = {
- cwd: testdir,
- env: Object.assign({}, process.env, {
- npm_config_cache: cachedir,
- npm_config_tmp: tmpdir,
- npm_config_prefix: globaldir,
- npm_config_registry: common.registry,
- npm_config_loglevel: 'warn'
- })
-}
-
-function exampleManifest (version) {
- return {
- name: 'example',
- version: version
- }
-}
-
-const examplePackument = {
- 'name': 'example',
- 'dist-tags': {
- 'latest': '1.2.4',
- 'beta': '1.2.6'
- },
- 'versions': {
- '1.2.0': exampleManifest('1.2.0'),
- '1.2.1': exampleManifest('1.2.1'),
- '1.2.2': exampleManifest('1.2.2'),
- '1.2.3': exampleManifest('1.2.3'),
- '1.2.4': exampleManifest('1.2.4'),
- '1.2.5': exampleManifest('1.2.5'),
- '1.2.6': exampleManifest('1.2.6')
- }
-}
-
-const fixture = new Tacks(Dir({
- cache: Dir(),
- global: Dir(),
- tmp: Dir(),
- testdir: Dir({
- node_modules: Dir({
- example: Dir({
- 'package.json': File({
- name: 'example',
- version: '1.2.3'
- })
- })
- }),
- 'package.json': File({
- name: 'outdated-latest',
- version: '1.0.0',
- dependencies: {
- example: '^1.2.0'
- }
- })
- })
-}))
-
-function setup () {
- cleanup()
- fixture.create(basedir)
-}
-
-function cleanup () {
- fixture.remove(basedir)
-}
-
-let server
-
-test('setup', function (t) {
- setup()
- mr({port: common.port, throwOnUnmatched: true}, function (err, s) {
- if (err) throw err
- server = s
- server.get('/example').reply(200, examplePackument)
- t.done()
- })
-})
-
-test('example', function (t) {
- return common.npm(['outdated', '--json'], conf).spread((code, stdout, stderr) => {
- t.is(code, 1, 'files ARE outdated!')
- const result = JSON.parse(stdout.trim())
- t.comment(stderr.trim())
- // your assertions here
- t.like(result, {example: {current: '1.2.3', wanted: '1.2.4', latest: '1.2.4'}}, 'got latest, not beta')
- })
-})
-
-test('cleanup', function (t) {
- server.close()
- cleanup()
- t.done()
-})
diff --git a/deps/npm/test/tap/outdated-long.js b/deps/npm/test/tap/outdated-long.js
deleted file mode 100644
index 8cd2ceadb9..0000000000
--- a/deps/npm/test/tap/outdated-long.js
+++ /dev/null
@@ -1,93 +0,0 @@
-var fs = require('graceful-fs')
-var path = require('path')
-
-var mr = require('npm-registry-mock')
-var test = require('tap').test
-
-var common = require('../common-tap.js')
-var npm = require('../../')
-
-// config
-var pkg = common.pkg
-var cache = common.cache
-
-var json = {
- name: 'outdated-long',
- description: 'fixture',
- version: '0.0.1',
- dependencies: {
- underscore: '1.3.1'
- }
-}
-
-test('setup', function (t) {
- fs.writeFileSync(
- path.join(pkg, 'package.json'),
- JSON.stringify(json, null, 2)
- )
-
- process.chdir(pkg)
- t.end()
-})
-
-test('it should not throw', function (t) {
- var originalLog = console.log
-
- var output = []
- var expOut = [
- 'add\tunderscore\t1.3.1\tnode_modules/underscore\t\t',
- path.resolve(pkg, 'node_modules', 'underscore') +
- ':underscore@1.3.1' +
- ':underscore@1.3.1' +
- ':underscore@1.5.1' +
- ':dependencies'
- ]
-
- var expData = [
- [
- pkg,
- 'underscore',
- '1.3.1',
- '1.3.1',
- '1.5.1',
- '1.3.1',
- 'dependencies'
- ]
- ]
-
- console.log = function () {
- output.push.apply(output, arguments)
- }
- mr({ port: common.port }, function (er, s) {
- npm.load(
- {
- cache: cache,
- loglevel: 'silent',
- parseable: true,
- registry: common.registry
- },
- function () {
- npm.install('.', function (err) {
- t.ifError(err, 'install success')
- npm.config.set('long', true)
- // since it's possible for the homepage of a package to change, after the
- // install we read the value from the package.json directly to specify our
- // expected output.
- expOut[1] = expOut[1] + ':' + JSON.parse(fs.readFileSync(path.resolve(pkg, 'node_modules', 'underscore', 'package.json'))).homepage
- npm.outdated(function (er, d) {
- t.ifError(err, 'npm outdated ran without error')
- t.is(process.exitCode, 1, 'exit code set to 1')
- process.exitCode = 0
- console.log = originalLog
- output[0] = output[0].replace(/\\/g, '/')
- t.same(output, expOut)
- t.same(d, expData)
-
- s.close()
- t.end()
- })
- })
- }
- )
- })
-})
diff --git a/deps/npm/test/tap/outdated-remote.js b/deps/npm/test/tap/outdated-remote.js
deleted file mode 100644
index e6cbd0e8ac..0000000000
--- a/deps/npm/test/tap/outdated-remote.js
+++ /dev/null
@@ -1,89 +0,0 @@
-'use strict'
-const path = require('path')
-const test = require('tap').test
-const Tacks = require('tacks')
-const File = Tacks.File
-const Dir = Tacks.Dir
-const common = require('../common-tap.js')
-
-const basedir = common.pkg
-const testdir = path.join(basedir, 'testdir')
-const cachedir = common.cache
-const globaldir = path.join(basedir, 'global')
-const tmpdir = path.join(basedir, 'tmp')
-
-const conf = {
- cwd: testdir,
- env: common.newEnv().extend({
- npm_config_cache: cachedir,
- npm_config_tmp: tmpdir,
- npm_config_prefix: globaldir,
- npm_config_registry: common.registry,
- npm_config_loglevel: 'warn'
- })
-}
-
-const fixture = new Tacks(Dir({
- cache: Dir(),
- global: Dir(),
- tmp: Dir(),
- testdir: Dir({
- node_modules: Dir({
- 'foo-http': Dir({
- 'package.json': File({
- name: 'foo-http',
- version: '1.0.0'
- })
- }),
- 'foo-https': Dir({
- 'package.json': File({
- name: 'foo-https',
- version: '1.0.0'
- })
- })
- }),
- 'package.json': File({
- name: 'outdated-remote',
- version: '1.0.0',
- dependencies: {
- 'foo-http': 'http://example.com/foo.tar.gz',
- 'foo-https': 'https://example.com/foo.tar.gz'
- }
- })
- })
-}))
-
-function setup () {
- fixture.create(basedir)
-}
-
-test('setup', t => {
- setup()
- return common.fakeRegistry.listen()
-})
-
-test('discovers new versions in outdated', t => {
- return common.npm(['outdated', '--json'], conf).then(([code, stdout, stderr]) => {
- t.is(code, 1, 'npm outdated completed successfully')
- t.comment(stdout.trim())
- t.comment(stderr.trim())
- const data = JSON.parse(stdout)
- t.same(data['foo-http'], {
- current: '1.0.0',
- wanted: 'remote',
- latest: 'remote',
- location: ''
- })
- t.same(data['foo-https'], {
- current: '1.0.0',
- wanted: 'remote',
- latest: 'remote',
- location: ''
- })
- })
-})
-
-test('cleanup', t => {
- common.fakeRegistry.close()
- t.done()
-})
diff --git a/deps/npm/test/tap/outdated-symlink.js b/deps/npm/test/tap/outdated-symlink.js
deleted file mode 100644
index 5ec089758a..0000000000
--- a/deps/npm/test/tap/outdated-symlink.js
+++ /dev/null
@@ -1,133 +0,0 @@
-'use strict'
-const path = require('path')
-const test = require('tap').test
-const mr = require('npm-registry-mock')
-const Tacks = require('tacks')
-const File = Tacks.File
-const Symlink = Tacks.Symlink
-const Dir = Tacks.Dir
-const common = require('../common-tap.js')
-
-const basedir = common.pkg
-const testdir = path.join(basedir, 'testdir')
-const cachedir = common.cache
-const globaldir = path.join(basedir, 'global')
-const tmpdir = path.join(basedir, 'tmp')
-
-const conf = {
- cwd: path.join(testdir, 'main'),
- env: Object.assign({}, process.env, {
- npm_config_cache: cachedir,
- npm_config_tmp: tmpdir,
- npm_config_prefix: globaldir,
- npm_config_registry: common.registry,
- npm_config_loglevel: 'warn'
- })
-}
-
-let server
-const fixture = new Tacks(Dir({
- cache: Dir(),
- global: Dir(),
- tmp: Dir(),
- testdir: Dir({
- broken: Dir({
- 'package.json': File({
- name: 'broken',
- version: '1.0.0'
- })
- }),
- main: Dir({
- node_modules: Dir({
- unbroken: Symlink('/testdir/unbroken')
- }),
- 'package-lock.json': File({
- name: 'main',
- version: '1.0.0',
- lockfileVersion: 1,
- requires: true,
- dependencies: {
- broken: {
- version: 'file:../broken'
- },
- unbroken: {
- version: 'file:../unbroken'
- }
- }
- }),
- 'package.json': File({
- name: 'main',
- version: '1.0.0',
- dependencies: {
- broken: 'file:../broken',
- unbroken: 'file:../unbroken'
- }
- })
- }),
- unbroken: Dir({
- 'package.json': File({
- name: 'unbroken',
- version: '1.0.0'
- })
- })
- })
-}))
-
-function setup () {
- cleanup()
- fixture.create(basedir)
-}
-
-function cleanup () {
- fixture.remove(basedir)
-}
-
-test('setup', function (t) {
- setup()
- mr({port: common.port, throwOnUnmatched: true}, function (err, s) {
- if (err) throw err
- server = s
- t.done()
- })
-})
-
-test('outdated sees broken links', function (t) {
- common.npm(['outdated', '--json'], conf, function (err, code, stdout, stderr) {
- if (err) throw err
- t.is(code, 1, 'command ran not ok')
- t.comment(stderr.trim())
- t.comment(stdout.trim())
- t.same(JSON.parse(stdout), {
- broken: {
- wanted: 'linked',
- latest: 'linked',
- location: ''
- }
- })
- t.done()
- })
-})
-
-test('outdated with long output sees broken links', function (t) {
- common.npm(['outdated', '--long', '--json'], conf, function (err, code, stdout, stderr) {
- if (err) throw err
- t.is(code, 1, 'command ran not ok')
- t.comment(stderr.trim())
- t.comment(stdout.trim())
- t.same(JSON.parse(stdout), {
- broken: {
- wanted: 'linked',
- latest: 'linked',
- type: 'dependencies',
- location: ''
- }
- })
- t.done()
- })
-})
-
-test('cleanup', function (t) {
- server.close()
- cleanup()
- t.done()
-})
diff --git a/deps/npm/test/tap/outdated.js b/deps/npm/test/tap/outdated.js
deleted file mode 100644
index e64b7b0f81..0000000000
--- a/deps/npm/test/tap/outdated.js
+++ /dev/null
@@ -1,123 +0,0 @@
-var fs = require('graceful-fs')
-var path = require('path')
-
-var mr = require('npm-registry-mock')
-var test = require('tap').test
-
-var npm = require('../../')
-var common = require('../common-tap.js')
-
-// config
-var pkg = common.pkg
-var cache = common.cache
-var originalLog
-
-var json = {
- name: 'outdated',
- description: 'fixture',
- version: '0.0.1',
- dependencies: {
- underscore: '1.3.1',
- async: '0.2.9',
- checker: '0.5.1'
- }
-}
-
-test('setup', function (t) {
- originalLog = console.log
- fs.writeFileSync(
- path.join(pkg, 'package.json'),
- JSON.stringify(json, null, 2)
- )
-
- process.chdir(pkg)
- t.end()
-})
-
-test('it should not throw', function (t) {
- var output = []
- var expOut = [
- path.resolve(pkg, 'node_modules', 'async') +
- ':async@0.2.9' +
- ':async@0.2.9' +
- ':async@0.2.10' +
- '\n' +
- path.resolve(pkg, 'node_modules', 'checker') +
- ':checker@0.5.1' +
- ':checker@0.5.1' +
- ':checker@0.5.2' +
- '\n' +
- path.resolve(pkg, 'node_modules', 'underscore') +
- ':underscore@1.3.1' +
- ':underscore@1.3.1' +
- ':underscore@1.5.1'
- ]
-
- var expData = [
- [
- pkg,
- 'async',
- '0.2.9',
- '0.2.9',
- '0.2.10',
- '0.2.9',
- null
- ],
- [
- pkg,
- 'checker',
- '0.5.1',
- '0.5.1',
- '0.5.2',
- '0.5.1',
- null
- ],
- [
- pkg,
- 'underscore',
- '1.3.1',
- '1.3.1',
- '1.5.1',
- '1.3.1',
- null
- ]
- ]
-
- console.log = function () {}
- mr({ port: common.port }, function (er, s) {
- npm.load(
- {
- cache: cache,
- loglevel: 'silent',
- parseable: true,
- registry: common.registry
- },
- function () {
- npm.install('.', function (err) {
- t.ifError(err, 'install success')
- console.log = function () {
- output.push.apply(output, arguments)
- }
- npm.outdated(function (er, d) {
- t.ifError(err, 'outdated completed without error')
- t.equals(process.exitCode, 1, 'exitCode set to 1')
- process.exitCode = 0
- output = output.map(function (x) { return x.replace(/\r/g, '') })
- console.log = originalLog
-
- t.same(output, expOut)
- t.same(d, expData)
-
- s.close()
- t.end()
- })
- })
- }
- )
- })
-})
-
-test('cleanup', function (t) {
- console.log = originalLog
- t.end()
-})
diff --git a/deps/npm/test/tap/override-bundled.js b/deps/npm/test/tap/override-bundled.js
deleted file mode 100644
index 7f87c0999f..0000000000
--- a/deps/npm/test/tap/override-bundled.js
+++ /dev/null
@@ -1,191 +0,0 @@
-'use strict'
-var Bluebird = require('bluebird')
-var test = require('tap').test
-var fs = require('fs')
-var mkdirp = require('mkdirp')
-var rimraf = require('rimraf')
-var path = require('path')
-var common = require('../common-tap.js')
-
-var testname = path.basename(__filename, '.js')
-var testdir = common.pkg
-var testmod = path.resolve(testdir, 'top-test')
-var testtgz = testmod + '-1.0.0.tgz'
-
-var bundleupdatesrc = path.resolve(testmod, 'bundle-update')
-var bundleupdatetgz = bundleupdatesrc + '-1.0.0.tgz'
-var bundleupdateNEW = path.resolve(bundleupdatesrc, 'NEW')
-var bundleupdateNEWpostinstall = path.resolve(testdir, 'node_modules', 'bundle-update', 'NEW')
-var bundleupdatebad = path.resolve(testmod, 'node_modules', 'bundle-update')
-
-var bundlekeepsrc = path.resolve(testmod, 'bundle-keep')
-var bundlekeeptgz = bundlekeepsrc + '-1.0.0.tgz'
-var bundlekeep = path.resolve(testmod, 'node_modules', 'bundle-keep')
-var bundlekeepOLD = path.resolve(bundlekeep, 'OLD')
-var bundlekeepOLDpostinstall = path.resolve(testdir, 'node_modules', 'top-test', 'node_modules', 'bundle-keep', 'OLD')
-
-var bundledeepsrc = path.resolve(testmod, 'bundle-deep')
-var bundledeeptgz = bundledeepsrc + '-1.0.0.tgz'
-var bundledeep = path.resolve(testmod, 'node_modules', 'bundle-deep')
-var bundledeepOLD = path.resolve(bundledeep, 'OLD')
-var bundledeepOLDpostinstall = path.resolve(testdir, 'node_modules', 'top-test', 'node_modules', 'bundle-deep', 'OLD')
-
-var bundledeepupdatesrc = path.resolve(testmod, 'bundle-deep-update')
-var bundledeepupdatetgz = bundledeepupdatesrc + '-1.0.0.tgz'
-var bundledeepupdate = path.resolve(bundledeep, 'node_modules', 'bundle-deep-update')
-var bundledeepupdateNEW = path.resolve(bundledeepupdatesrc, 'NEW')
-var bundledeepupdateNEWpostinstall = path.resolve(testdir, 'node_modules', 'bundle-deep-update', 'NEW')
-
-var testjson = {
- dependencies: {'top-test': 'file:' + testtgz}
-}
-
-var testmodjson = {
- name: 'top-test',
- version: '1.0.0',
- dependencies: {
- 'bundle-update': bundleupdatetgz,
- 'bundle-keep': bundlekeeptgz,
- 'bundle-deep': bundledeeptgz
- },
- bundledDependencies: ['bundle-update', 'bundle-keep', 'bundle-deep'],
- files: ['OLD', 'NEW']
-}
-var bundlejson = {
- name: 'bundle-update',
- version: '1.0.0',
- files: ['OLD', 'NEW']
-}
-
-var bundlekeepjson = {
- name: 'bundle-keep',
- version: '1.0.0',
- _requested: {
- rawSpec: bundlekeeptgz
- },
- _resolved: bundlekeeptgz,
- _shasum: 'baadf00d',
- files: ['OLD', 'NEW']
-
-}
-var bundledeepjson = {
- name: 'bundle-deep',
- version: '1.0.0',
- dependencies: {
- 'bundle-deep-update': bundledeepupdatetgz
- },
- _requested: {
- rawSpec: bundledeeptgz
- },
- _resolved: bundlekeeptgz,
- _shasum: 'deadbeef',
- files: ['OLD', 'NEW']
-
-}
-
-var bundledeepupdatejson = {
- version: '1.0.0',
- name: 'bundle-deep-update',
- files: ['OLD', 'NEW']
-
-}
-
-function writepjs (dir, content) {
- fs.writeFileSync(path.join(dir, 'package.json'), JSON.stringify(content, null, 2))
-}
-
-function setup () {
- mkdirp.sync(testdir)
- writepjs(testdir, testjson)
- mkdirp.sync(testmod)
- writepjs(testmod, testmodjson)
-
- mkdirp.sync(bundleupdatesrc)
- writepjs(bundleupdatesrc, bundlejson)
- fs.writeFileSync(bundleupdateNEW, '')
- mkdirp.sync(bundleupdatebad)
- writepjs(bundleupdatebad, bundlejson)
-
- mkdirp.sync(bundlekeepsrc)
- writepjs(bundlekeepsrc, bundlekeepjson)
- mkdirp.sync(bundlekeep)
- writepjs(bundlekeep, bundlekeepjson)
- fs.writeFileSync(bundlekeepOLD, '')
-
- mkdirp.sync(bundledeepsrc)
- writepjs(bundledeepsrc, bundledeepjson)
- mkdirp.sync(bundledeep)
- writepjs(bundledeep, bundledeepjson)
- fs.writeFileSync(bundledeepOLD, '')
-
- mkdirp.sync(bundledeepupdatesrc)
- writepjs(bundledeepupdatesrc, bundledeepupdatejson)
- mkdirp.sync(bundledeepupdate)
- writepjs(bundledeepupdate, bundledeepupdatejson)
- fs.writeFileSync(bundledeepupdateNEW, '')
-}
-
-function cleanup () {
- rimraf.sync(testdir)
-}
-
-test('setup', function (t) {
- cleanup()
- setup()
- return Bluebird.all([
- common.npm(['pack', bundleupdatesrc], {cwd: path.dirname(bundleupdatetgz), stdio: 'inherit'}),
- common.npm(['pack', bundlekeepsrc], {cwd: path.dirname(bundlekeeptgz), stdio: 'inherit'}),
- common.npm(['pack', bundledeepupdatesrc], {cwd: path.dirname(bundledeepupdatetgz), stdio: 'inherit'})
- ]).map((result) => result[0]).spread((bundleupdate, bundlekeep, bundledeepupdate) => {
- t.is(bundleupdate, 0, 'bundleupdate')
- t.is(bundlekeep, 0, 'bundlekeep')
- t.is(bundledeepupdate, 0, 'bundledeepupdate')
- }).then(() => {
- return common.npm(['pack', bundledeepsrc], {cwd: path.dirname(bundledeeptgz), stdio: 'inherit'})
- }).spread((code) => {
- t.is(code, 0, 'bundledeep')
- return common.npm(['pack', testmod], {cwd: path.dirname(testtgz), stdio: 'inherit'})
- }).spread((code) => {
- t.is(code, 0, 'testmod')
- })
-})
-
-test('bundled', function (t) {
- common.npm(['install', '--loglevel=verbose'], {cwd: testdir}, function (err, code, stdout, stderr) {
- if (err) throw err
- t.plan(9)
- t.is(code, 0, 'npm itself completed ok')
-
- // This tests that after the install we have a freshly installed version
- // of `bundle-update` (in alignment with the package.json), instead of the
- // version that was bundled with `top-test`.
- // If npm doesn't do this, and selects the bundled version, things go very
- // wrong because npm thinks it has a different module (with different
- // metadata) installed in that location and will go off and try to do
- // _things_ to it. Things like chmod in particular, which in turn results
- // in the dreaded ENOENT errors.
- t.like(stderr, new RegExp('npm WARN ' + testname), "didn't stomp on other warnings")
- t.like(stderr, /npm verb.*bundle-update/, 'included update warning about bundled dep')
- t.like(stderr, /npm verb.*bundle-deep-update/, 'included update warning about deeply bundled dep')
- t.like(stderr, /npm WARN top-test@1\.0\.0 had bundled packages that do not match/, 'single grouped warning')
- fs.stat(bundleupdateNEWpostinstall, function (missing) {
- t.ok(!missing, 'package.json overrode bundle')
- })
- fs.stat(bundledeepupdateNEWpostinstall, function (missing) {
- t.ok(!missing, 'deep package.json overrode bundle')
- })
- // Relatedly, when upgrading, if a bundled module is replacing an existing
- // module we want to choose the bundled version, not the version we're replacing.
- fs.stat(bundlekeepOLDpostinstall, function (missing) {
- t.ok(!missing, 'no override when package.json matches')
- })
- fs.stat(bundledeepOLDpostinstall, function (missing) {
- t.ok(!missing, 'deep no override when package.json matches')
- })
- })
-})
-
-test('cleanup', function (t) {
- cleanup()
- t.end()
-})
diff --git a/deps/npm/test/tap/owner.js b/deps/npm/test/tap/owner.js
deleted file mode 100644
index 622b272852..0000000000
--- a/deps/npm/test/tap/owner.js
+++ /dev/null
@@ -1,159 +0,0 @@
-var mr = require('npm-registry-mock')
-var test = require('tap').test
-
-var common = require('../common-tap.js')
-var basedir = common.pkg
-var cachedir = common.cache
-
-var server
-
-var EXEC_OPTS = {
- cwd: basedir,
- stdio: [0, 'pipe', 2],
- env: common.newEnv().extend({
- npm_config_cache: cachedir
- })
-}
-
-var jashkenas = {
- name: 'jashkenas',
- email: 'jashkenas@gmail.com'
-}
-
-var othiym23 = {
- name: 'othiym23',
- email: 'forrest@npmjs.com'
-}
-
-var bcoe = {
- name: 'bcoe',
- email: 'ben@npmjs.com'
-}
-
-function shrt (user) {
- return user.name + ' <' + user.email + '>\n'
-}
-
-function mocks (server) {
- server.get('/-/user/org.couchdb.user:othiym23')
- .many().reply(200, othiym23)
-
- // test 1
- server.get('/underscore')
- .reply(200, { _id: 'underscore', _rev: 1, maintainers: [jashkenas] })
- server.put(
- '/underscore/-rev/1',
- { _id: 'underscore', _rev: 1, maintainers: [jashkenas, othiym23] },
- {}
- ).reply(200, { _id: 'underscore', _rev: 2, maintainers: [jashkenas, othiym23] })
-
- // test 2
- server.get('/@xxx%2fscoped')
- .reply(200, { _id: '@xxx/scoped', _rev: 1, maintainers: [bcoe] })
- server.put(
- '/@xxx%2fscoped/-rev/1',
- { _id: '@xxx/scoped', _rev: 1, maintainers: [bcoe, othiym23] },
- {}
- ).reply(200, { _id: '@xxx/scoped', _rev: 2, maintainers: [bcoe, othiym23] })
-
- // test 3
- server.get('/underscore')
- .reply(200, { _id: 'underscore', _rev: 2, maintainers: [jashkenas, othiym23] })
-
- // test 4
- server.get('/underscore')
- .reply(200, { _id: 'underscore', _rev: 2, maintainers: [jashkenas, othiym23] })
- server.put(
- '/underscore/-rev/2',
- { _id: 'underscore', _rev: 2, maintainers: [jashkenas] },
- {}
- ).reply(200, { _id: 'underscore', _rev: 3, maintainers: [jashkenas] })
-}
-
-test('setup', function (t) {
- mr({ port: common.port, plugin: mocks }, function (er, s) {
- server = s
- t.end()
- })
-})
-
-test('npm owner add', function (t) {
- common.npm(
- [
- '--loglevel', 'warn',
- '--registry', common.registry,
- 'owner', 'add', 'othiym23', 'underscore'
- ],
- EXEC_OPTS,
- function (err, code, stdout, stderr) {
- t.ifError(err, 'npm owner add ran without error')
- t.notOk(code, 'npm owner add exited cleanly')
- t.notOk(stderr, 'npm owner add ran silently')
- t.equal(stdout, '+ othiym23 (underscore)\n', 'got expected add output')
-
- t.end()
- }
- )
-})
-
-test('npm owner add (scoped)', function (t) {
- common.npm(
- [
- '--loglevel', 'silent',
- '--registry', common.registry,
- 'owner', 'add', 'othiym23', '@xxx/scoped'
- ],
- EXEC_OPTS,
- function (err, code, stdout, stderr) {
- t.ifError(err, 'npm owner add (scoped) ran without error')
- t.notOk(code, 'npm owner add (scoped) exited cleanly')
- t.notOk(stderr, 'npm owner add (scoped) ran silently')
- t.equal(stdout, '+ othiym23 (@xxx/scoped)\n', 'got expected scoped add output')
-
- t.end()
- }
- )
-})
-
-test('npm owner ls', function (t) {
- common.npm(
- [
- '--loglevel', 'silent',
- '--registry', common.registry,
- 'owner', 'ls', 'underscore'
- ],
- EXEC_OPTS,
- function (err, code, stdout, stderr) {
- t.ifError(err, 'npm owner ls ran without error')
- t.notOk(code, 'npm owner ls exited cleanly')
- t.notOk(stderr, 'npm owner ls ran silently')
- t.equal(stdout, shrt(jashkenas) + shrt(othiym23), 'got expected ls output')
-
- t.end()
- }
- )
-})
-
-test('npm owner rm', function (t) {
- common.npm(
- [
- '--loglevel', 'silent',
- '--registry', common.registry,
- 'owner', 'rm', 'othiym23', 'underscore'
- ],
- EXEC_OPTS,
- function (err, code, stdout, stderr) {
- t.ifError(err, 'npm owner rm ran without error')
- t.notOk(code, 'npm owner rm exited cleanly')
- t.notOk(stderr, 'npm owner rm ran silently')
- t.equal(stdout, '- othiym23 (underscore)\n', 'got expected rm output')
-
- t.end()
- }
- )
-})
-
-test('cleanup', function (t) {
- server.close()
- t.end()
-})
diff --git a/deps/npm/test/tap/pack-files-and-ignores.js b/deps/npm/test/tap/pack-files-and-ignores.js
deleted file mode 100644
index 4d9b97a32a..0000000000
--- a/deps/npm/test/tap/pack-files-and-ignores.js
+++ /dev/null
@@ -1,707 +0,0 @@
-'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 tar = require('tar')
-var basepath = common.pkg
-var fixturepath = path.resolve(basepath, 'npm-test-files')
-var targetpath = path.resolve(basepath, 'target')
-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({
- included: File('')
- })
- })
- )
- withFixture(t, fixture, function (done) {
- t.notOk(fileExists('ignore'), 'toplevel file excluded')
- t.ok(fileExists('include'), 'unignored file included')
- t.ok(fileExists('sub/included'), '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 by default', function (t) {
- var fixture = new Tacks(
- Dir({
- 'package.json': File({
- name: 'npm-test-files',
- version: '1.2.5'
- }),
- '.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(''),
- 'core': Dir({core: File(''), foo: File('')}),
- '.DS_Store': Dir({foo: File('')}),
- '._ohno': File(''),
- '._ohnoes': Dir({noes: File('')}),
- 'foo.orig': File(''),
- 'package-lock.json': 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.ok(fileExists('core'), 'core/ included')
- t.ok(fileExists('core/foo'), 'core/foo included')
- t.notOk(fileExists('core/core'), 'core/core not included')
- t.notOk(fileExists('.DS_Store'), '.DS_Store not included')
- t.notOk(fileExists('.DS_Store/foo'), '.DS_Store/foo not included')
- t.notOk(fileExists('._ohno'), '._ohno not included')
- t.notOk(fileExists('._ohnoes'), '._ohnoes not included')
- t.notOk(fileExists('foo.orig'), 'foo.orig not included')
- t.notOk(fileExists('package-lock.json'), 'package-lock.json not included')
- done()
- })
-})
-
-test('default-ignored files can be explicitly included', 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',
- 'core',
- '.DS_Store',
- '._ohno',
- '._ohnoes',
- 'foo.orig',
- 'package-lock.json'
- ]
- }),
- '.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(''),
- 'core': Dir({core: File(''), foo: File('')}),
- '.DS_Store': Dir({foo: File('')}),
- '._ohno': File(''),
- '._ohnoes': Dir({noes: File('')}),
- 'foo.orig': File(''),
- 'package-lock.json': File('')
- })
- )
- withFixture(t, fixture, function (done) {
- t.notOk(fileExists('.git'), '.git should never be included')
- t.ok(fileExists('.svn'), '.svn included')
- t.ok(fileExists('CVS'), 'CVS included')
- t.ok(fileExists('.hg'), '.hg included')
- t.ok(fileExists('.lock-wscript'), '.lock-wscript included')
- t.ok(fileExists('.wafpickle-0'), '.wafpickle-0 included')
- t.ok(fileExists('.wafpickle-5'), '.wafpickle-5 included')
- t.ok(fileExists('.wafpickle-50'), '.wafpickle-50 included')
- t.ok(fileExists('build/config.gypi'), 'build/config.gypi included')
- t.ok(fileExists('npm-debug.log'), 'npm-debug.log included')
- t.ok(fileExists('.npmrc'), '.npmrc included')
- t.ok(fileExists('.foo.swp'), '.foo.swp included')
- t.ok(fileExists('core'), 'core/ included')
- t.ok(fileExists('core/foo'), 'core/foo included')
- t.ok(fileExists('core/core'), 'core/core included')
- t.ok(fileExists('.DS_Store'), '.DS_Store included')
- t.ok(fileExists('._ohno'), '._ohno included')
- t.ok(fileExists('._ohnoes'), '._ohnoes included')
- t.ok(fileExists('foo.orig'), 'foo.orig included')
- t.ok(fileExists('package-lock.json'), 'package-lock.json 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',
- 'history',
- 'HistorY',
- 'HistorY.md',
- 'license',
- 'licence',
- 'LICENSE',
- 'LICENCE'
- ),
- 'README': File(''),
- 'Readme': File(''),
- 'readme.md': File(''),
- 'readme.randomext': File(''),
- 'changelog': File(''),
- 'CHAngelog': File(''),
- 'ChangeLOG.txt': File(''),
- 'history': File(''),
- 'HistorY': File(''),
- 'HistorY.md': 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('unconditional inclusion does not capture modules', function (t) {
- var fixture = new Tacks(
- Dir({
- 'package.json': File({
- name: 'npm-test-files',
- version: '1.2.5'
- }),
- 'node_modules': Dir({
- 'readme': Dir({ 'file': File('') }),
- 'README': Dir({ 'file': File('') }),
- 'licence': Dir({ 'file': File('') }),
- 'license': Dir({ 'file': File('') }),
- 'history': Dir({ 'file': File('') }),
- 'History': Dir({ 'file': File('') }),
- 'changelog': Dir({ 'file': File('') }),
- 'ChangeLOG': Dir({ 'file': File('') })
- })
- })
- )
- withFixture(t, fixture, function (done) {
- t.notOk(fileExists('node_modules/readme/file'), 'readme module not included')
- t.notOk(fileExists('node_modules/README/file'), 'README module not included')
- t.notOk(fileExists('node_modules/licence/file'), 'licence module not included')
- t.notOk(fileExists('node_modules/license/file'), 'license module not included')
- t.notOk(fileExists('node_modules/history/file'), 'history module not included')
- t.notOk(fileExists('node_modules/History/file'), 'History module not included')
- t.notOk(fileExists('node_modules/changelog/file'), 'changelog module not included')
- t.notOk(fileExists('node_modules/ChangeLOG/file'), 'ChangeLOG module not 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()
- })
-})
-
-test('file that starts with @ sign included normally', (t) => {
- const fixture = new Tacks(
- Dir({
- 'package.json': File({
- name: 'npm-test-files',
- version: '1.2.5'
- }),
- '@sub1': Dir({
- sub: Dir({
- include1: File('')
- })
- }),
- sub2: Dir({
- '@include': File(''),
- '@sub3': Dir({
- include1: File('')
- })
- })
- })
- )
- withFixture(t, fixture, function (done) {
- t.ok(fileExists('@sub1/sub/include1'), '@ dir included')
-
- t.ok(fileExists('sub2/@include'), '@ file included')
- t.ok(fileExists('sub2/@sub3/include1'), 'nested @ dir included')
-
- done()
- })
-})
-
-function fileExists (file) {
- try {
- return !!fs.statSync(path.resolve(targetpath, 'package', file))
- } catch (_) {
- return false
- }
-}
-
-function withFixture (t, fixture, tester) {
- fixture.create(fixturepath)
- mkdirp.sync(targetpath)
- common.npm(['pack', fixturepath], {cwd: basepath}, extractAndCheck)
- function extractAndCheck (err, code) {
- if (err) throw err
- t.is(code, 0, 'pack went ok')
- extractTarball(checkTests)
- }
- function checkTests (err) {
- if (err) throw err
- tester(removeAndDone)
- }
- function removeAndDone (err) {
- if (err) throw err
- fixture.remove(fixturepath)
- rimraf.sync(basepath)
- t.done()
- }
-}
-
-function extractTarball (cb) {
- // Unpack to disk so case-insensitive filesystems are consistent
- tar.extract({
- file: basepath + '/npm-test-files-1.2.5.tgz',
- cwd: targetpath,
- sync: true
- })
-
- cb()
-}
diff --git a/deps/npm/test/tap/pack-scoped.js b/deps/npm/test/tap/pack-scoped.js
deleted file mode 100644
index 06d02297fd..0000000000
--- a/deps/npm/test/tap/pack-scoped.js
+++ /dev/null
@@ -1,81 +0,0 @@
-// verify that prepublish runs on pack and publish
-var test = require('tap').test
-var common = require('../common-tap')
-var fs = require('graceful-fs')
-var join = require('path').join
-var mkdirp = require('mkdirp')
-var rimraf = require('rimraf')
-
-var pkg = common.pkg
-var manifest = join(pkg, 'package.json')
-var tmp = join(pkg, 'tmp')
-var cache = common.cache
-
-var data = {
- name: '@scope/generic-package',
- version: '90000.100001.5'
-}
-
-test('setup', function (t) {
- var n = 0
-
- rimraf.sync(pkg)
-
- mkdirp(pkg, then())
- mkdirp(cache, then())
- mkdirp(tmp, then())
-
- function then () {
- n++
- return function (er) {
- t.ifError(er)
- if (--n === 0) next()
- }
- }
-
- function next () {
- fs.writeFile(manifest, JSON.stringify(data), 'ascii', done)
- }
-
- function done (er) {
- t.ifError(er)
-
- t.pass('setup done')
- t.end()
- }
-})
-
-test('test', function (t) {
- var env = {
- 'npm_config_cache': cache,
- 'npm_config_tmp': tmp,
- 'npm_config_prefix': pkg,
- 'npm_config_global': 'false'
- }
-
- for (var i in process.env) {
- if (!/^npm_config_/.test(i)) env[i] = process.env[i]
- }
-
- common.npm([
- 'pack',
- '--loglevel', 'warn'
- ], {
- cwd: pkg,
- env: env
- }, function (err, code, stdout, stderr) {
- t.ifErr(err, 'npm pack finished without error')
- t.equal(code, 0, 'npm pack exited ok')
- t.notOk(stderr, 'got stderr data: ' + JSON.stringify('' + stderr))
- stdout = stdout.trim()
- var regex = new RegExp('scope-generic-package-90000.100001.5.tgz', 'ig')
- t.ok(stdout.match(regex), 'found package')
- t.end()
- })
-})
-
-test('cleanup', function (t) {
- rimraf.sync(pkg)
- t.pass('cleaned up')
- t.end()
-})
diff --git a/deps/npm/test/tap/pack.js b/deps/npm/test/tap/pack.js
deleted file mode 100644
index 23c8296d00..0000000000
--- a/deps/npm/test/tap/pack.js
+++ /dev/null
@@ -1,199 +0,0 @@
-'use strict'
-
-const BB = require('bluebird')
-
-const test = require('tap').test
-const common = require('../common-tap')
-const fs = BB.promisifyAll(require('graceful-fs'))
-const path = require('path')
-const rimraf = BB.promisify(require('rimraf'))
-const Tacks = require('tacks')
-
-const Dir = Tacks.Dir
-const File = Tacks.File
-
-const testDir = common.pkg
-const tmp = path.join(testDir, 'tmp')
-const cache = common.cache
-
-test('basic pack', (t) => {
- const fixture = new Tacks(new Dir({
- 'package.json': new File({
- name: 'generic-package',
- version: '90000.100001.5'
- })
- }))
- return rimraf(testDir)
- .then(() => fixture.create(testDir))
- .then(() => common.npm([
- 'pack',
- '--loglevel', 'notice',
- '--cache', cache,
- '--tmp', tmp,
- '--prefix', testDir,
- '--no-global'
- ], {
- cwd: testDir
- }))
- .spread((code, stdout, stderr) => {
- t.equal(code, 0, 'npm pack exited ok')
- t.match(stderr, /notice\s+\d+[a-z]+\s+package\.json/gi, 'mentions package.json')
- t.match(stdout, /generic-package-90000\.100001\.5\.tgz/ig, 'found pkg')
- return fs.statAsync(
- path.join(testDir, 'generic-package-90000.100001.5.tgz')
- )
- })
- .then((stat) => t.ok(stat, 'tarball written to cwd'))
- .then(() => rimraf(testDir))
-})
-
-test('pack with bundled', (t) => {
- const fixture = new Tacks(new Dir({
- 'package.json': new File({
- name: 'generic-package',
- version: '90000.100001.5',
- dependencies: {
- '@bundle/dep': '^1.0.0',
- 'regular-dep': '^1.0.0'
- },
- bundleDependencies: [
- '@bundle/dep',
- 'regular-dep'
- ]
- }),
- 'node_modules': new Dir({
- 'regular-dep': new Dir({
- 'package.json': new File({
- name: 'regular-dep',
- version: '1.0.0'
- })
- }),
- '@bundle': new Dir({
- 'dep': new Dir({
- 'package.json': new File({
- name: '@bundle/dep',
- version: '1.0.0'
- })
- })
- })
- })
- }))
- return rimraf(testDir)
- .then(() => fixture.create(testDir))
- .then(() => common.npm([
- 'pack',
- '--loglevel', 'notice',
- '--cache', cache,
- '--tmp', tmp,
- '--prefix', testDir,
- '--no-global'
- ], {
- cwd: testDir
- }))
- .spread((code, stdout, stderr) => {
- t.equal(code, 0, 'npm pack exited ok')
- t.match(stderr, /notice\s+\d+[a-z]+\s+package\.json/gi, 'mentions package.json')
- t.match(stderr, /notice\s+regular-dep/, 'regular dep mentioned')
- t.match(stderr, /notice\s+@bundle\/dep/, 'bundled dep mentioned')
- })
- .then(() => rimraf(testDir))
-})
-
-test('pack --dry-run', (t) => {
- const fixture = new Tacks(new Dir({
- 'package.json': new File({
- name: 'generic-package',
- version: '90000.100001.5'
- })
- }))
- return rimraf(testDir)
- .then(() => fixture.create(testDir))
- .then(() => common.npm([
- 'pack',
- '--dry-run',
- '--loglevel', 'notice',
- '--cache', cache,
- '--tmp', tmp,
- '--prefix', testDir,
- '--no-global'
- ], {
- cwd: testDir
- }))
- .spread((code, stdout, stderr) => {
- t.equal(code, 0, 'npm pack exited ok')
- t.match(stdout, /generic-package-90000\.100001\.5\.tgz/ig, 'found pkg')
- return fs.statAsync(
- path.join(testDir, 'generic-package-90000.100001.5.tgz')
- )
- .then(
- () => { throw new Error('should have failed') },
- (err) => t.equal(err.code, 'ENOENT', 'no tarball written!')
- )
- })
- .then(() => rimraf(testDir))
-})
-
-test('pack --json', (t) => {
- const fixture = new Tacks(new Dir({
- 'package.json': new File({
- name: 'generic-package',
- version: '90000.100001.5'
- })
- }))
- return rimraf(testDir)
- .then(() => fixture.create(testDir))
- .then(() => common.npm([
- 'pack',
- '--dry-run',
- '--json',
- '--loglevel', 'notice',
- '--cache', cache,
- '--tmp', tmp,
- '--prefix', testDir,
- '--no-global'
- ], {
- cwd: testDir
- }))
- .spread((code, stdout, stderr) => {
- t.equal(code, 0, 'npm pack exited ok')
- t.equal(stderr.trim(), '', 'no notice output')
- t.similar(JSON.parse(stdout), [{
- filename: 'generic-package-90000.100001.5.tgz',
- files: [{path: 'package.json'}],
- entryCount: 1
- }], 'pack details output as valid json')
- })
- .then(() => rimraf(testDir))
-})
-
-test('postpack', (t) => {
- const fixture = new Tacks(new Dir({
- 'package.json': new File({
- name: 'generic-package',
- version: '90000.100001.5',
- scripts: {
- postpack: 'node -e "var fs = require(\'fs\'); fs.openSync(\'postpack-step\', \'w+\'); if (!fs.existsSync(\'generic-package-90000.100001.5.tgz\')) { throw new Error(\'tar archive does not exist on postpack\') }"'
- }
- })
- }))
-
- return rimraf(testDir)
- .then(() => fixture.create(testDir))
- .then(() => common.npm([
- 'pack',
- '--loglevel', 'notice',
- '--cache', cache,
- '--tmp', tmp,
- '--prefix', testDir,
- '--no-global'
- ], {
- cwd: testDir
- }))
- .spread((code, stdout, stderr) => {
- t.equal(code, 0, 'npm pack exited ok')
- return fs.statAsync(
- path.join(testDir, 'postpack-step')
- )
- })
- .then(() => rimraf(testDir))
-})
diff --git a/deps/npm/test/tap/peer-deps.js b/deps/npm/test/tap/peer-deps.js
deleted file mode 100644
index 558fe9c4e6..0000000000
--- a/deps/npm/test/tap/peer-deps.js
+++ /dev/null
@@ -1,52 +0,0 @@
-var fs = require('graceful-fs')
-var path = require('path')
-
-var mr = require('npm-registry-mock')
-var test = require('tap').test
-
-var common = require('../common-tap.js')
-var npm = require('../../')
-
-var pkg = common.pkg
-
-var expected = [ 'peer dep missing: request@0.9.x, required by npm-test-peer-deps@0.0.0' ]
-
-var json = {
- author: 'Domenic Denicola',
- name: 'npm-test-peer-deps-installer',
- version: '0.0.0',
- dependencies: {
- 'npm-test-peer-deps': '*'
- }
-}
-
-function setup (cb) {
- fs.writeFileSync(
- path.join(pkg, 'package.json'),
- JSON.stringify(json, null, 2)
- )
- process.chdir(pkg)
-
- var opts = { cache: common.cache, registry: common.registry }
- npm.load(opts, cb)
-}
-
-test('installs the peer dependency directory structure', function (t) {
- 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.problems, expected)
- s.close()
- t.end()
- })
- })
- })
- })
-})
diff --git a/deps/npm/test/tap/pick-manifest-from-registry-metadata.js b/deps/npm/test/tap/pick-manifest-from-registry-metadata.js
deleted file mode 100644
index 3af354aed3..0000000000
--- a/deps/npm/test/tap/pick-manifest-from-registry-metadata.js
+++ /dev/null
@@ -1,145 +0,0 @@
-'use strict'
-var test = require('tap').test
-
-var pickManifest = require('../../lib/utils/pick-manifest-from-registry-metadata.js')
-
-test('basic carat range selection', function (t) {
- var metadata = {
- 'dist-tags': {
- 'example': '1.1.0'
- },
- versions: {
- '1.0.0': { version: '1.0.0' },
- '1.0.1': { version: '1.0.1' },
- '1.0.2': { version: '1.0.2' },
- '1.1.0': { version: '1.1.0' },
- '2.0.0': { version: '2.0.0' }
- }
- }
- var versions = Object.keys(metadata.versions)
- var selected = pickManifest('^1.0.0', 'latest', versions, metadata)
- t.equal(selected.manifest.version, '1.1.0', 'picked the right manifest using ^')
- t.equal(selected.resolvedTo, '1.1.0', 'resolved using version match')
- selected = pickManifest('^1.0.0', 'example', versions, metadata)
- t.equal(selected.manifest.version, '1.1.0', 'picked the right manifest using ^')
- t.equal(selected.resolvedTo, 'example', 'resolved using tag')
- t.end()
-})
-
-test('basic tilde range selection', function (t) {
- var metadata = {
- 'dist-tags': {
- 'example': '1.1.0'
- },
- versions: {
- '1.0.0': { version: '1.0.0' },
- '1.0.1': { version: '1.0.1' },
- '1.0.2': { version: '1.0.2' },
- '1.1.0': { version: '1.1.0' },
- '2.0.0': { version: '2.0.0' }
- }
- }
- var versions = Object.keys(metadata.versions)
- var selected = pickManifest('~1.0.0', 'latest', versions, metadata)
- t.equal(selected.manifest.version, '1.0.2', 'picked the right manifest using ~')
- t.equal(selected.resolvedTo, '1.0.2', 'resolved using version match')
- t.end()
-})
-
-test('basic mathematical range selection', function (t) {
- var metadata = {
- 'dist-tags': {},
- versions: {
- '1.0.0': { version: '1.0.0' },
- '1.0.1': { version: '1.0.1' },
- '1.0.2': { version: '1.0.2' },
- '2.0.0': { version: '2.0.0' }
- }
- }
- var versions = Object.keys(metadata.versions)
- var selected = pickManifest('>=1.0.0 <2', 'example', versions, metadata)
- t.equal(selected.manifest.version, '1.0.2', 'picked the right manifest using mathematical range')
- t.equal(selected.resolvedTo, '1.0.2', 'resolved using version match')
- t.end()
-})
-
-test('basic version selection', function (t) {
- var metadata = {
- 'dist-tags': {},
- versions: {
- '1.0.0': { version: '1.0.0' },
- '1.0.1': { version: '1.0.1' },
- '1.0.2': { version: '1.0.2' },
- '2.0.0': { version: '2.0.0' }
- }
- }
- var versions = Object.keys(metadata.versions)
- var selected = pickManifest('1.0.0', 'latest', versions, metadata)
- t.equal(selected.manifest.version, '1.0.0', 'picked the right manifest using specific version')
- t.equal(selected.resolvedTo, '1.0.0', 'resolved using version match')
- t.end()
-})
-
-test('nothing if range does not match anything', function (t) {
- var metadata = {
- 'dist-tags': {},
- versions: {
- '1.0.0': { version: '1.0.0' },
- '2.0.0': { version: '2.0.0' },
- '2.0.5': { version: '2.0.5' }
- }
- }
- var versions = Object.keys(metadata.versions)
- var selected = pickManifest('^2.1.0', 'latest', versions, metadata)
- t.equal(selected, undefined, 'no manifest matched')
- t.end()
-})
-
-test('if `defaultTag` matches a given range, use it', function (t) {
- var metadata = {
- 'dist-tags': {
- foo: '1.0.1'
- },
- versions: {
- '1.0.0': { version: '1.0.0' },
- '1.0.1': { version: '1.0.1' },
- '1.0.2': { version: '1.0.2' },
- '2.0.0': { version: '2.0.0' }
- }
- }
- var versions = Object.keys(metadata.versions)
- var selected = pickManifest('^1.0.0', 'foo', versions, metadata)
- t.equal(selected.manifest.version, '1.0.1', 'picked the version for foo')
- t.equal(selected.resolvedTo, 'foo', 'resolved using tag')
-
- selected = pickManifest('^2.0.0', 'foo', versions, metadata)
- t.equal(selected.manifest.version, '2.0.0', 'no match, no foo')
- t.equal(selected.resolvedTo, '2.0.0', 'resolved using version match')
-
- t.end()
-})
-
-test('* ranges use `defaultTag` if no versions match', function (t) {
- var metadata = {
- 'dist-tags': {
- beta: '2.0.0-beta.0'
- },
- versions: {
- '1.0.0-pre.0': { version: '1.0.0-pre.0' },
- '1.0.0-pre.1': { version: '1.0.0-pre.1' },
- '2.0.0-beta.0': { version: '2.0.0-beta.0' },
- '2.0.0-beta.1': { version: '2.0.0-beta.1' }
- }
- }
- var versions = Object.keys(metadata.versions)
- var selected = pickManifest('*', 'beta', versions, metadata)
- t.equal(selected.manifest.version, '2.0.0-beta.0', 'used defaultTag for all-prerelease splat.')
- t.equal(selected.resolvedTo, 'beta', 'resolved using tag')
- t.end()
-})
-
-test('no result if metadata has no versions', function (t) {
- var selected = pickManifest('^1.0.0', 'latest', [], {'dist-tags': {}, versions: {}})
- t.equal(selected, undefined, 'no versions, no result')
- t.end()
-})
diff --git a/deps/npm/test/tap/ping.js b/deps/npm/test/tap/ping.js
deleted file mode 100644
index 3687b05bd4..0000000000
--- a/deps/npm/test/tap/ping.js
+++ /dev/null
@@ -1,95 +0,0 @@
-var fs = require('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 = common.pkg
-var opts = { cwd: pkg }
-
-var outfile = path.join(pkg, '_npmrc')
-
-var contents = function () {
-}.toString().split('\n').slice(1, -1).join('\n')
-
-var pingResponse = {
- host: 'registry.npmjs.org',
- ok: true,
- username: null,
- peer: 'example.com'
-}
-
-function mocks (server) {
- server.get('/-/ping?write=true').reply(200, JSON.stringify(pingResponse))
-}
-
-test('setup', function (t) {
- cleanup()
- setup()
- t.end()
-})
-
-test('npm ping', function (t) {
- mr({ port: common.port, plugin: mocks }, function (err, s) {
- if (err) throw err
-
- common.npm([
- 'ping',
- '--registry', common.registry,
- '--loglevel', 'notice',
- '--userconfig', outfile
- ], opts, function (err, code, stdout, stderr) {
- s.close()
- t.ifError(err, 'command completed')
- t.notOk(code, 'exited OK')
-
- t.match(stderr, /PING/, 'ping notification output')
- t.match(stderr, /PONG/, 'pong response output')
- t.end()
- })
- })
-})
-
-test('npm ping --json', function (t) {
- mr({ port: common.port, plugin: mocks }, function (err, s) {
- if (err) throw err
-
- common.npm([
- 'ping',
- '--json',
- '--registry', common.registry,
- '--loglevel', 'notice',
- '--userconfig', outfile
- ], opts, function (err, code, stdout, stderr) {
- s.close()
- t.ifError(err, 'command completed')
- t.notOk(code, 'exited OK')
-
- const json = JSON.parse(stdout.trim())
- t.similar(json, {
- registry: common.registry,
- details: pingResponse
- }, 'JSON info returned')
- t.equal(typeof json.time, 'number', 'got a timestamp')
- t.end()
- })
- })
-})
-
-test('cleanup', function (t) {
- cleanup()
- t.end()
-})
-
-function setup () {
- mkdirp.sync(pkg)
- fs.writeFileSync(outfile, contents)
-}
-
-function cleanup () {
- rimraf.sync(pkg)
-}
diff --git a/deps/npm/test/tap/prepare.js b/deps/npm/test/tap/prepare.js
deleted file mode 100644
index d096600073..0000000000
--- a/deps/npm/test/tap/prepare.js
+++ /dev/null
@@ -1,89 +0,0 @@
-// verify that prepare runs on pack and publish
-var common = require('../common-tap')
-var test = require('tap').test
-var fs = require('graceful-fs')
-var join = require('path').join
-var mkdirp = require('mkdirp')
-var rimraf = require('rimraf')
-
-var pkg = common.pkg
-var tmp = join(pkg, 'tmp')
-var cache = common.cache
-
-test('setup', function (t) {
- var n = 0
- cleanup()
- mkdirp(pkg, then())
- mkdirp(cache, then())
- mkdirp(tmp, then())
- function then () {
- n++
- return function (er) {
- if (er) throw er
- if (--n === 0) next()
- }
- }
-
- function next () {
- fs.writeFile(join(pkg, 'package.json'), JSON.stringify({
- name: 'npm-test-prepare',
- version: '1.2.5',
- scripts: { prepare: 'echo ok' }
- }), 'ascii', function (er) {
- if (er) throw er
-
- t.pass('setup done')
- t.end()
- })
- }
-})
-
-test('test', function (t) {
- var env = {
- 'npm_config_cache': cache,
- 'npm_config_tmp': tmp,
- 'npm_config_prefix': pkg,
- 'npm_config_global': 'false'
- }
-
- for (var i in process.env) {
- if (!/^npm_config_/.test(i)) {
- env[i] = process.env[i]
- }
- }
-
- common.npm([
- 'pack',
- '--loglevel', 'warn'
- ], {
- cwd: pkg,
- env: env,
- nodeExecPath: process.execPath
- }, function (err, code, stdout, stderr) {
- t.equal(code, 0, 'pack finished successfully')
- t.ifErr(err, 'pack finished successfully')
-
- t.notOk(stderr, 'got stderr data:' + JSON.stringify('' + stderr))
- var c = stdout.trim()
- var regex = new RegExp(
- '> npm-test-prepare@1.2.5 prepare [^\\r\\n]+\\r?\\n' +
- '> echo ok\\r?\\n' +
- '\\r?\\n' +
- 'ok\\r?\\n' +
- 'npm-test-prepare-1.2.5.tgz', 'ig'
- )
-
- t.match(c, regex)
- t.end()
- })
-})
-
-test('cleanup', function (t) {
- cleanup()
- t.pass('cleaned up')
- t.end()
-})
-
-function cleanup () {
- rimraf.sync(pkg)
-}
diff --git a/deps/npm/test/tap/prepublish-only.js b/deps/npm/test/tap/prepublish-only.js
deleted file mode 100644
index 988d507c63..0000000000
--- a/deps/npm/test/tap/prepublish-only.js
+++ /dev/null
@@ -1,136 +0,0 @@
-// verify that prepublishOnly runs _only_ on publish
-var join = require('path').join
-
-var mr = require('npm-registry-mock')
-var test = require('tap').test
-var Tacks = require('tacks')
-var File = Tacks.File
-var Dir = Tacks.Dir
-var path = require('path')
-
-var common = require('../common-tap')
-
-var pkg = common.pkg
-var cachedir = common.cache
-var tmpdir = join(pkg, 'tmp')
-
-var env = {
- 'npm_config_cache': cachedir,
- 'npm_config_tmp': tmpdir,
- 'npm_config_global': 'false'
-}
-
-for (var i in process.env) {
- if (!/^npm_config_/.test(i)) {
- env[i] = process.env[i]
- }
-}
-
-var server
-
-var fixture = new Tacks(Dir({
- cache: Dir(),
- tmp: Dir(),
- '.npmrc': File([
- 'progress=false',
- 'registry=' + common.registry,
- '//localhost:1337/:username=username',
- '//localhost:1337/:_authToken=deadbeeffeed'
- ].join('\n') + '\n'),
- helper: Dir({
- 'script.js': File([
- '#!/usr/bin/env node\n',
- 'console.log("ok")\n'
- ].join('\n') + '\n'
- ),
- 'package.json': File({
- name: 'helper',
- version: '6.6.6',
- bin: './script.js'
- })
- }),
- 'package.json': File({
- name: 'npm-test-prepublish-only',
- version: '1.2.5',
- dependencies: {
- 'helper': 'file:./helper'
- },
- scripts: {
- build: 'helper',
- prepublishOnly: 'node ' + path.resolve(__dirname, '../../') + ' run build'
- }
- })
-}))
-
-test('setup', function (t) {
- fixture.create(pkg)
- mr({port: common.port, throwOnUnmatched: true}, function (err, s) {
- t.ifError(err, 'registry mocked successfully')
- server = s
- common.npm(
- [
- 'install',
- '--loglevel', 'error',
- '--cache', cachedir,
- '--tmp', tmpdir
- ],
- {
- cwd: pkg,
- env: env
- },
- function (err, code, stdout, stderr) {
- t.equal(code, 0, 'install exited OK')
- t.ifErr(err, 'installed successfully')
-
- t.notOk(stderr, 'got stderr data:' + JSON.stringify('' + stderr))
-
- t.end()
- }
- )
- })
-})
-
-test('test', function (t) {
- server.filteringRequestBody(function () { return true })
- .put('/npm-test-prepublish-only', true)
- .reply(201, {ok: true})
-
- common.npm(
- [
- 'publish',
- '--loglevel', 'warn',
- '--scripts-prepend-node-path'
- ],
- {
- cwd: pkg,
- env: env
- },
- function (err, code, stdout, stderr) {
- t.equal(code, 0, 'publish ran without error')
- t.ifErr(err, 'published successfully')
-
- t.notOk(stderr, 'got stderr data:' + JSON.stringify('' + stderr))
- var c = stdout.trim()
- var regex = new RegExp(
- '> npm-test-prepublish-only@1.2.5 prepublishOnly [^\\r\\n]+\\r?\\n' +
- '> .* run build\\r?\\n' +
- '\\r?\\n' +
- '\\r?\\n' +
- '> npm-test-prepublish-only@1.2.5 build [^\\r\\n]+\\r?\\n' +
- '> helper\\r?\\n' +
- '\\r?\\n' +
- 'ok\\r?\\n' +
- '\\+ npm-test-prepublish-only@1.2.5', 'ig'
- )
-
- t.match(c, regex)
- t.end()
- }
- )
-})
-
-test('cleanup', function (t) {
- server.close()
- t.pass('cleaned up')
- t.end()
-})
diff --git a/deps/npm/test/tap/prepublish.js b/deps/npm/test/tap/prepublish.js
deleted file mode 100644
index e561d057f2..0000000000
--- a/deps/npm/test/tap/prepublish.js
+++ /dev/null
@@ -1,118 +0,0 @@
-// verify that prepublish runs on install, pack, and publish
-var common = require('../common-tap')
-var test = require('tap').test
-var fs = require('graceful-fs')
-var join = require('path').join
-var mkdirp = require('mkdirp')
-var rimraf = require('rimraf')
-
-var pkg = common.pkg
-var tmp = join(pkg, 'tmp')
-var cache = common.cache
-
-test('setup', function (t) {
- var n = 0
- cleanup()
- mkdirp(pkg, then())
- mkdirp(cache, then())
- mkdirp(tmp, then())
- function then () {
- n++
- return function (er) {
- if (er) throw er
- if (--n === 0) next()
- }
- }
-
- function next () {
- fs.writeFile(join(pkg, 'package.json'), JSON.stringify({
- name: 'npm-test-prepublish',
- version: '1.2.5',
- scripts: { prepublish: 'echo ok' }
- }), 'ascii', function (er) {
- if (er) throw er
-
- t.pass('setup done')
- t.end()
- })
- }
-})
-
-test('prepublish deprecation warning on `npm pack`', function (t) {
- var env = {
- 'npm_config_cache': cache,
- 'npm_config_tmp': tmp,
- 'npm_config_prefix': pkg,
- 'npm_config_global': 'false'
- }
-
- for (var i in process.env) {
- if (!/^npm_config_/.test(i)) {
- env[i] = process.env[i]
- }
- }
-
- common.npm([
- 'pack',
- '--loglevel', 'warn'
- ], { cwd: pkg, env: env }, function (err, code, stdout, stderr) {
- t.equal(code, 0, 'pack finished successfully')
- t.ifErr(err, 'pack finished successfully')
-
- t.match(stderr, /`prepublish` scripts are deprecated/)
- var c = stdout.trim()
- var regex = new RegExp('' +
- '> npm-test-prepublish@1.2.5 prepublish [^\\r\\n]+\\r?\\n' +
- '> echo ok\\r?\\n' +
- '\\r?\\n' +
- 'ok\\r?\\n' +
- 'npm-test-prepublish-1.2.5.tgz', 'ig')
-
- t.match(c, regex)
- t.end()
- })
-})
-
-test('prepublish deprecation warning on `npm install`', function (t) {
- var env = {
- 'npm_config_cache': cache,
- 'npm_config_tmp': tmp,
- 'npm_config_prefix': pkg,
- 'npm_config_global': 'false'
- }
-
- for (var i in process.env) {
- if (!/^npm_config_/.test(i)) {
- env[i] = process.env[i]
- }
- }
-
- common.npm([
- 'install',
- '--loglevel', 'warn'
- ], { cwd: pkg, env: env }, function (err, code, stdout, stderr) {
- t.equal(code, 0, 'pack finished successfully')
- t.ifErr(err, 'pack finished successfully')
-
- t.match(stderr, /`prepublish` scripts are deprecated/)
- var c = stdout.trim()
- var regex = new RegExp('' +
- '> npm-test-prepublish@1.2.5 prepublish [^\\r\\n]+\\r?\\n' +
- '> echo ok\\r?\\n' +
- '\\r?\\n' +
- 'ok' +
- '', 'ig')
-
- t.match(c, regex)
- t.end()
- })
-})
-test('cleanup', function (t) {
- cleanup()
- t.pass('cleaned up')
- t.end()
-})
-
-function cleanup () {
- rimraf.sync(pkg)
-}
diff --git a/deps/npm/test/tap/process-logger.js b/deps/npm/test/tap/process-logger.js
deleted file mode 100644
index 45c4e708cc..0000000000
--- a/deps/npm/test/tap/process-logger.js
+++ /dev/null
@@ -1,12 +0,0 @@
-'use strict'
-const test = require('tap').test
-require('../../lib/npm.js')
-
-test('process logging', (t) => {
- t.ok(process.listenerCount('log') >= 1, `log listener attached ${process.listenerCount('log')} >= 1`)
- t.doesNotThrow(() => process.emit('log', 'error', 'test', 'this'), 'logging does not throw')
- t.doesNotThrow(() => process.emit('log', 2348), 'invalid args do not throw')
- t.doesNotThrow(() => process.emit('log', null), 'null does not throw')
- t.doesNotThrow(() => process.emit('log', {}), 'obj does not throw')
- t.done()
-})
diff --git a/deps/npm/test/tap/progress-config.js b/deps/npm/test/tap/progress-config.js
deleted file mode 100644
index 92468004f2..0000000000
--- a/deps/npm/test/tap/progress-config.js
+++ /dev/null
@@ -1,87 +0,0 @@
-'use strict'
-var test = require('tap').test
-var log = require('npmlog')
-var fs = require('graceful-fs')
-const common = require('../common-tap.js')
-var configName = common.pkg + '/npmrc'
-
-// We use requireInject to get a fresh copy of
-// the npm singleton each time we require it.
-// If we didn't, we'd have shared state between
-// these various tests.
-var requireInject = require('require-inject')
-
-// Make sure existing environment vars don't muck up the test
-process.env = {}
-// Pretend that stderr is a tty regardless, so we can get consistent
-// results.
-process.stderr.isTTY = true
-
-test('setup', function (t) {
- fs.writeFileSync(configName, '')
- t.done()
-})
-
-function getFreshNpm () {
- return requireInject.withEmptyCache('../../lib/npm.js', {npmlog: log})
-}
-
-test('disabled', function (t) {
- t.plan(1)
- var npm = getFreshNpm()
- npm.load({userconfig: configName, progress: false}, function () {
- t.is(log.progressEnabled, false, 'should be disabled')
- })
-})
-
-test('enabled', function (t) {
- t.plan(1)
- var npm = getFreshNpm()
- npm.load({userconfig: configName, progress: true}, function () {
- t.is(log.progressEnabled, true, 'should be enabled')
- })
-})
-
-test('default', function (t) {
- t.plan(1)
- var npm = getFreshNpm()
- npm.load({userconfig: configName}, function () {
- t.is(log.progressEnabled, true, 'should be enabled')
- })
-})
-
-test('default-travis', function (t) {
- t.plan(1)
- process.env.TRAVIS = 'true'
- var npm = getFreshNpm()
- npm.load({userconfig: configName}, function () {
- t.is(log.progressEnabled, false, 'should be disabled')
- delete process.env.TRAVIS
- })
-})
-
-test('default-ci', function (t) {
- t.plan(1)
- process.env.CI = 'true'
- var npm = getFreshNpm()
- npm.load({userconfig: configName}, function () {
- t.is(log.progressEnabled, false, 'should be disabled')
- delete process.env.CI
- })
-})
-
-test('unicode-true', function (t) {
- var npm = getFreshNpm()
- npm.load({userconfig: configName, unicode: true}, function () {
- t.is(log.gauge._theme.hasUnicode, true, 'unicode will be selected')
- t.done()
- })
-})
-
-test('unicode-false', function (t) {
- var npm = getFreshNpm()
- npm.load({userconfig: configName, unicode: false}, function () {
- t.is(log.gauge._theme.hasUnicode, false, 'unicode will NOT be selected')
- t.done()
- })
-})
diff --git a/deps/npm/test/tap/prune-dev-dep-cycle.js b/deps/npm/test/tap/prune-dev-dep-cycle.js
deleted file mode 100644
index e226ac6d32..0000000000
--- a/deps/npm/test/tap/prune-dev-dep-cycle.js
+++ /dev/null
@@ -1,85 +0,0 @@
-'use strict'
-var fs = require('fs')
-var test = require('tap').test
-var Tacks = require('tacks')
-var File = Tacks.File
-var Dir = Tacks.Dir
-var common = require('../common-tap.js')
-var testdir = common.pkg
-
-var fixture = new Tacks(
- Dir({
- node_modules: Dir({
- 'a': Dir({
- 'package.json': File({
- _requested: {
- rawSpec: 'file:///mods/a'
- },
- dependencies: {
- 'b': 'file:///mods/b'
- },
- name: 'a',
- version: '1.0.0'
- })
- }),
- 'b': Dir({
- 'package.json': File({
- _requested: {
- rawSpec: 'file:///mods/b'
- },
- dependencies: {
- 'a': 'file:///mods/a'
- },
- name: 'b',
- version: '1.0.0'
- })
- })
- }),
- 'package.json': File({
- name: 'test',
- version: '1.0.0',
- devDependencies: {
- 'a': 'file:///mods/a'
- }
- })
- })
-)
-
-function setup () {
- cleanup()
- fixture.create(testdir)
-}
-
-function cleanup () {
- fixture.remove(testdir)
-}
-
-test('setup', function (t) {
- setup()
- t.end()
-})
-
-function readdir (dir) {
- try {
- return fs.readdirSync(dir)
- } catch (ex) {
- if (ex.code === 'ENOENT') return []
- throw ex
- }
-}
-
-test('prune cycle in dev deps', function (t) {
- common.npm(['prune', '--production', '--json'], {cwd: testdir}, function (err, code, stdout, stderr) {
- if (err) throw err
- t.is(code, 0, 'prune finished successfully')
- t.like(JSON.parse(stdout), {removed: [{name: 'a'}, {name: 'b'}]}, 'removed the right modules')
- var dirs = readdir(testdir + '/node_modules').sort()
- t.same(dirs, [])
- t.end()
- })
-})
-
-test('cleanup', function (t) {
- cleanup()
- t.end()
-})
diff --git a/deps/npm/test/tap/prune-dev-dep-with-bins.js b/deps/npm/test/tap/prune-dev-dep-with-bins.js
deleted file mode 100644
index a75652f9a1..0000000000
--- a/deps/npm/test/tap/prune-dev-dep-with-bins.js
+++ /dev/null
@@ -1,103 +0,0 @@
-'use strict'
-var fs = require('fs')
-var test = require('tap').test
-var Tacks = require('tacks')
-var File = Tacks.File
-var Dir = Tacks.Dir
-var common = require('../common-tap.js')
-var testdir = common.pkg
-
-var fixture = new Tacks(
- Dir({
- node_modules: Dir({
- 'yes': Dir({
- 'package.json': File({
- _requested: {
- rawSpec: 'file:///mods/yes'
- },
- dependencies: {},
- bin: {
- 'yes': 'yes.js'
- },
- name: 'yes',
- version: '1.0.0'
- }),
- 'yes.js': File('while (true) { console.log("y") }')
- }),
- '.bin': Dir({
- // verbose, but needed for `read-cmd-shim` to properly identify which
- // package this belongs to
- 'yes': File(
- '#!/bin/sh\n' +
- 'basedir=$(dirname "$(echo "$0" | sed -e \'s,\\\\,/,g\')")\n' +
- '\n' +
- 'case `uname` in\n' +
- ' *CYGWIN*) basedir=`cygpath -w "$basedir"`;;\n' +
- 'esac\n' +
- '\n' +
- 'if [ -x "$basedir/node" ]; then\n' +
- ' "$basedir/node" "$basedir/../yes/yes.js" "$@"\n' +
- ' ret=$?\n' +
- 'else\n' +
- ' node "$basedir/../yes/yes.js" "$@"\n' +
- ' ret=$?\n' +
- 'fi\n' +
- 'exit $ret\n'),
- 'yes.cmd': File(
- '@IF EXIST "%~dp0\node.exe" (\n' +
- '"%~dp0\\node.exe" "%~dp0\\..\\yes\\yes.js" %*\n' +
- ') ELSE (\n' +
- '@SETLOCAL\n' +
- '@SET PATHEXT=%PATHEXT:;.JS;=;%\n' +
- 'node "%~dp0\\..\\yes\\yes.js" %*')
- })
- }),
- 'package.json': File({
- name: 'test',
- version: '1.0.0',
- devDependencies: {
- 'yes': 'file:///mods/yes'
- }
- })
- })
-)
-
-function setup () {
- cleanup()
- fixture.create(testdir)
-}
-
-function cleanup () {
- fixture.remove(testdir)
-}
-
-test('setup', function (t) {
- setup()
- t.end()
-})
-
-function readdir (dir) {
- try {
- return fs.readdirSync(dir)
- } catch (ex) {
- if (ex.code === 'ENOENT') return []
- throw ex
- }
-}
-
-test('prune cycle in dev deps', function (t) {
- common.npm(['prune', '--production', '--json'], {cwd: testdir}, function (err, code, stdout, stderr) {
- if (err) throw err
- t.is(code, 0, 'prune finished successfully')
- t.like(JSON.parse(stdout), {removed: [{name: 'yes'}]}, 'removed the right modules')
- var dirs = readdir(testdir + '/node_modules').sort()
- // bindirs are never removed, it's ok for them to remain after prune
- t.same(dirs, ['.bin'])
- t.end()
- })
-})
-
-test('cleanup', function (t) {
- cleanup()
- t.end()
-})
diff --git a/deps/npm/test/tap/prune-with-dev-dep-duplicate.js b/deps/npm/test/tap/prune-with-dev-dep-duplicate.js
deleted file mode 100644
index 7e7632b489..0000000000
--- a/deps/npm/test/tap/prune-with-dev-dep-duplicate.js
+++ /dev/null
@@ -1,103 +0,0 @@
-var fs = require('fs')
-var path = require('path')
-
-var mr = require('npm-registry-mock')
-var test = require('tap').test
-
-var common = require('../common-tap')
-var server
-
-var pkg = common.pkg
-var cache = common.cache
-
-var json = {
- name: 'prune-with-dev-dep-duplicate',
- description: 'fixture',
- version: '0.0.1',
- main: 'index.js',
- dependencies: {
- 'test-package': '0.0.0'
- },
- devDependencies: {
- 'test-package': '0.0.0'
- }
-}
-
-var EXEC_OPTS = {
- cwd: pkg,
- npm_config_depth: 'Infinity'
-}
-
-test('setup', function (t) {
- fs.writeFileSync(
- path.join(pkg, 'package.json'),
- JSON.stringify(json, null, 2)
- )
- mr({ port: common.port }, function (er, s) {
- server = s
- t.end()
- })
-})
-
-function readdir (dir) {
- try {
- return fs.readdirSync(dir)
- } catch (ex) {
- if (ex.code === 'ENOENT') return []
- throw ex
- }
-}
-
-test('npm install also=dev', function (t) {
- common.npm([
- 'install',
- '--cache', cache,
- '--registry', common.registry,
- '--loglevel', 'silent',
- '--also=dev'
- ], EXEC_OPTS, function (err, code, stdout, stderr) {
- if (err) throw err
- t.notOk(code, 'exit ok')
- t.notOk(stderr, 'Should not get data on stderr: ' + stderr)
- var dirs = readdir(pkg + '/node_modules').sort()
- t.same(dirs, [ 'test-package' ].sort())
- t.end()
- })
-})
-
-test('npm prune also=dev', function (t) {
- common.npm([
- 'prune',
- '--loglevel', 'silent',
- '--also=dev'
- ], EXEC_OPTS, function (err, code, stdout, stderr) {
- if (err) throw err
- t.notOk(code, 'exit ok')
- t.notOk(stderr, 'Should not get data on stderr: ' + stderr)
- var dirs = readdir(pkg + '/node_modules').sort()
- t.same(dirs, [ 'test-package' ])
- t.end()
- })
-})
-
-test('npm prune only=prod', function (t) {
- common.npm([
- 'prune',
- '--loglevel', 'silent',
- '--only=prod',
- '--json'
- ], EXEC_OPTS, function (err, code, stdout, stderr) {
- if (err) throw err
- t.notOk(code, 'exit ok')
- t.isDeeply(JSON.parse(stdout).removed, [], 'removed nothing')
- var dirs = readdir(pkg + '/node_modules').sort()
- t.same(dirs, [ 'test-package' ])
- t.end()
- })
-})
-
-test('cleanup', function (t) {
- server.close()
- t.pass('cleaned up')
- t.end()
-})
diff --git a/deps/npm/test/tap/prune-with-only-dev-deps.js b/deps/npm/test/tap/prune-with-only-dev-deps.js
deleted file mode 100644
index 6ea1bcf64b..0000000000
--- a/deps/npm/test/tap/prune-with-only-dev-deps.js
+++ /dev/null
@@ -1,114 +0,0 @@
-var fs = require('fs')
-var path = require('path')
-
-var mkdirp = require('mkdirp')
-var mr = require('npm-registry-mock')
-var test = require('tap').test
-
-var common = require('../common-tap')
-var server
-
-var pkg = common.pkg
-var cache = common.cache
-
-var json = {
- name: 'prune-with-only-dev-deps',
- description: 'fixture',
- version: '0.0.1',
- main: 'index.js',
- devDependencies: {
- 'test-package-with-one-dep': '0.0.0',
- 'test-package': '0.0.0'
- }
-}
-
-var EXEC_OPTS = {
- cwd: pkg,
- npm_config_depth: 'Infinity'
-}
-
-test('setup', function (t) {
- mkdirp.sync(cache)
- fs.writeFileSync(
- path.join(pkg, 'package.json'),
- JSON.stringify(json, null, 2)
- )
- mr({ port: common.port }, function (er, s) {
- server = s
- t.end()
- })
-})
-
-test('npm install', function (t) {
- common.npm([
- 'install',
- '--cache', cache,
- '--registry', common.registry,
- '--loglevel', 'silent',
- '--production', 'false'
- ], EXEC_OPTS, function (err, code, stdout, stderr) {
- t.ifErr(err, 'install finished successfully')
- t.notOk(code, 'exit ok')
- t.notOk(stderr, 'Should not get data on stderr: ' + stderr)
- t.end()
- })
-})
-
-function readdir (dir) {
- try {
- return fs.readdirSync(dir)
- } catch (ex) {
- if (ex.code === 'ENOENT') return []
- throw ex
- }
-}
-
-test('verify installs', function (t) {
- var dirs = readdir(pkg + '/node_modules').sort()
- t.same(dirs, [ 'test-package', 'test-package-with-one-dep' ].sort())
- t.end()
-})
-
-test('npm prune', function (t) {
- common.npm([
- 'prune',
- '--loglevel', 'silent',
- '--production', 'false'
- ], EXEC_OPTS, function (err, code, stdout, stderr) {
- t.ifErr(err, 'prune finished successfully')
- t.notOk(code, 'exit ok')
- t.notOk(stderr, 'Should not get data on stderr: ' + stderr)
- t.end()
- })
-})
-
-test('verify installs', function (t) {
- var dirs = readdir(pkg + '/node_modules').sort()
- t.same(dirs, [ 'test-package', 'test-package-with-one-dep' ])
- t.end()
-})
-
-test('npm prune', function (t) {
- common.npm([
- 'prune',
- '--loglevel', 'silent',
- '--production',
- '--json'
- ], EXEC_OPTS, function (err, code, stdout, stderr) {
- t.ifErr(err, 'prune finished successfully')
- t.notOk(code, 'exit ok')
- t.like(JSON.parse(stdout), {removed: [{name: 'test-package'}, {name: 'test-package-with-one-dep'}]})
- t.end()
- })
-})
-
-test('verify installs', function (t) {
- var dirs = readdir(pkg + '/node_modules').sort()
- t.same(dirs, [])
- t.end()
-})
-
-test('cleanup', function (t) {
- server.close()
- t.end()
-})
diff --git a/deps/npm/test/tap/prune.js b/deps/npm/test/tap/prune.js
deleted file mode 100644
index ce2a300b1a..0000000000
--- a/deps/npm/test/tap/prune.js
+++ /dev/null
@@ -1,121 +0,0 @@
-var fs = require('fs')
-var path = require('path')
-
-var mr = require('npm-registry-mock')
-var test = require('tap').test
-
-var common = require('../common-tap')
-var server
-
-var pkg = common.pkg
-var cache = common.cache
-
-var json = {
- name: 'prune',
- description: 'fixture',
- version: '0.0.1',
- main: 'index.js',
- dependencies: {
- underscore: '1.3.1'
- },
- devDependencies: {
- mkdirp: '*'
- }
-}
-
-var EXEC_OPTS = {
- cwd: pkg,
- npm_config_depth: 'Infinity'
-}
-
-test('setup', function (t) {
- fs.writeFileSync(
- path.join(pkg, 'package.json'),
- JSON.stringify(json, null, 2)
- )
- mr({ port: common.port }, function (er, s) {
- server = s
- t.end()
- })
-})
-
-test('npm install', function (t) {
- common.npm([
- 'install',
- '--cache', cache,
- '--registry', common.registry,
- '--loglevel', 'silent',
- '--production', 'false'
- ], EXEC_OPTS, function (err, code, stdout, stderr) {
- if (err) throw err
- t.notOk(code, 'exit ok')
- t.notOk(stderr, 'Should not get data on stderr: ' + stderr)
- t.end()
- })
-})
-
-test('npm install test-package', function (t) {
- common.npm([
- 'install', 'test-package',
- '--cache', cache,
- '--registry', common.registry,
- '--no-save',
- '--loglevel', 'silent',
- '--production', 'false'
- ], EXEC_OPTS, function (err, code, stdout, stderr) {
- if (err) throw err
- t.notOk(code, 'exit ok')
- t.notOk(stderr, 'Should not get data on stderr: ' + stderr)
- t.end()
- })
-})
-
-test('setup: verify installs', function (t) {
- var dirs = fs.readdirSync(pkg + '/node_modules').sort()
- t.same(dirs, [ 'test-package', 'mkdirp', 'underscore' ].sort())
- t.end()
-})
-
-test('dev: npm prune', function (t) {
- common.npm([
- 'prune',
- '--loglevel', 'silent',
- '--production', 'false'
- ], EXEC_OPTS, function (err, code, stdout, stderr) {
- if (err) throw err
- t.notOk(code, 'exit ok')
- t.notOk(stderr, 'Should not get data on stderr: ' + stderr)
- t.end()
- })
-})
-
-test('dev: verify installs', function (t) {
- var dirs = fs.readdirSync(pkg + '/node_modules').sort()
- t.same(dirs, [ 'mkdirp', 'underscore' ])
- t.end()
-})
-
-test('production: npm prune', function (t) {
- common.npm([
- 'prune',
- '--loglevel', 'silent',
- '--parseable',
- '--production'
- ], EXEC_OPTS, function (err, code, stdout) {
- if (err) throw err
- t.notOk(code, 'exit ok')
- t.equal(stdout.trim().replace(/\\/g, '/'), 'remove\tmkdirp\t0.3.5\tnode_modules/mkdirp')
- t.end()
- })
-})
-
-test('pruduction: verify installs', function (t) {
- var dirs = fs.readdirSync(pkg + '/node_modules').sort()
- t.same(dirs, [ 'underscore' ])
- t.end()
-})
-
-test('cleanup', function (t) {
- server.close()
- t.end()
-})
diff --git a/deps/npm/test/tap/publish-access-scoped.js b/deps/npm/test/tap/publish-access-scoped.js
deleted file mode 100644
index 7b9a3ecb59..0000000000
--- a/deps/npm/test/tap/publish-access-scoped.js
+++ /dev/null
@@ -1,65 +0,0 @@
-var fs = require('fs')
-var path = require('path')
-
-var test = require('tap').test
-var mr = require('npm-registry-mock')
-var common = require('../common-tap')
-var server
-
-var pkg = common.pkg
-
-test('setup', function (t) {
- mr({port: common.port, throwOnUnmatched: true}, function (err, s) {
- t.ifError(err, 'registry mocked successfully')
- t.pass('setup done')
- server = s
- t.end()
- })
-})
-
-test('scoped packages pass public access if set', function (t) {
- server.filteringRequestBody(function (body) {
- t.doesNotThrow(function () {
- var parsed = JSON.parse(body)
- t.equal(parsed.access, 'public', 'access level is correct')
- }, 'converted body back into object')
- return true
- }).put('/@bigco%2fpublish-access', true).reply(201, {ok: true})
-
- fs.writeFile(
- path.join(pkg, 'package.json'),
- JSON.stringify({
- name: '@bigco/publish-access',
- version: '1.2.5',
- public: true
- }),
- 'ascii',
- function (er) {
- t.ifError(er, 'package file written')
- common.npm(
- [
- 'publish',
- '--access', 'public',
- '--cache', common.cache,
- '--loglevel', 'silly',
- '--registry', common.registry
- ],
- {
- cwd: pkg
- },
- function (er) {
- t.ifError(er, 'published without error')
-
- server.done()
- t.end()
- }
- )
- }
- )
-})
-
-test('cleanup', function (t) {
- process.chdir(__dirname)
- server.close()
- t.end()
-})
diff --git a/deps/npm/test/tap/publish-access-unscoped-restricted-fails.js b/deps/npm/test/tap/publish-access-unscoped-restricted-fails.js
deleted file mode 100644
index f615fa60f2..0000000000
--- a/deps/npm/test/tap/publish-access-unscoped-restricted-fails.js
+++ /dev/null
@@ -1,38 +0,0 @@
-var fs = require('fs')
-var path = require('path')
-
-var test = require('tap').test
-var mkdirp = require('mkdirp')
-var rimraf = require('rimraf')
-var common = require('../common-tap.js')
-
-var pkg = common.pkg
-
-test('setup', function (t) {
- mkdirp.sync(pkg)
- fs.writeFileSync(
- path.join(pkg, 'package.json'),
- JSON.stringify({
- name: 'publish-access',
- version: '1.2.5'
- }))
- t.pass('setup done')
- t.end()
-})
-
-test('unscoped packages cannot be restricted', function (t) {
- var args = ['--access=restricted', '--loglevel=warn', '--registry=' + common.registry]
- var opts = {stdio: [0, 1, 'pipe'], cwd: pkg}
- common.npm(['publish'].concat(args), opts, function (err, code, stdout, stderr) {
- if (err) throw err
- t.notEqual(code, 0, 'publish not successful')
- t.match(stderr, "Can't restrict access to unscoped packages.")
-
- t.end()
- })
-})
-
-test('cleanup', function (t) {
- rimraf.sync(pkg)
- t.end()
-})
diff --git a/deps/npm/test/tap/publish-access-unscoped.js b/deps/npm/test/tap/publish-access-unscoped.js
deleted file mode 100644
index a7ea8e6694..0000000000
--- a/deps/npm/test/tap/publish-access-unscoped.js
+++ /dev/null
@@ -1,65 +0,0 @@
-var fs = require('fs')
-var path = require('path')
-
-var test = require('tap').test
-var mr = require('npm-registry-mock')
-var common = require('../common-tap')
-var server
-
-var pkg = common.pkg
-
-test('setup', function (t) {
- mr({port: common.port, throwOnUnmatched: true}, function (err, s) {
- t.ifError(err, 'registry mocked successfully')
- t.pass('setup done')
- server = s
- t.end()
- })
-})
-
-test('unscoped packages can be explicitly set as public', function (t) {
- server.filteringRequestBody(function (body) {
- t.doesNotThrow(function () {
- var parsed = JSON.parse(body)
- t.equal(parsed.access, 'public', 'access level is correct')
- }, 'converted body back into object')
- return true
- }).put('/publish-access', true).reply(201, {ok: true})
-
- fs.writeFile(
- path.join(pkg, 'package.json'),
- JSON.stringify({
- name: 'publish-access',
- version: '1.2.5',
- public: true
- }),
- 'ascii',
- function (er) {
- t.ifError(er, 'package file written')
- common.npm(
- [
- 'publish',
- '--access', 'public',
- '--cache', common.cache,
- '--loglevel', 'silly',
- '--registry', common.registry
- ],
- {
- cwd: pkg
- },
- function (er) {
- t.ifError(er, 'published without error')
-
- server.done()
- t.end()
- }
- )
- }
- )
-})
-
-test('cleanup', function (t) {
- process.chdir(__dirname)
- server.close()
- t.end()
-})
diff --git a/deps/npm/test/tap/publish-config.js b/deps/npm/test/tap/publish-config.js
deleted file mode 100644
index 0d6406316b..0000000000
--- a/deps/npm/test/tap/publish-config.js
+++ /dev/null
@@ -1,69 +0,0 @@
-'use strict'
-
-const common = require('../common-tap.js')
-const test = require('tap').test
-const fs = require('fs')
-const pkg = common.pkg
-
-fs.writeFileSync(pkg + '/package.json', JSON.stringify({
- name: 'npm-test-publish-config',
- version: '1.2.3',
- publishConfig: {
- registry: common.registry
- }
-}), 'utf8')
-
-fs.writeFileSync(pkg + '/fixture_npmrc',
- '//localhost:' + common.port + '/:email = fancy@feast.net\n' +
- '//localhost:' + common.port + '/:username = fancy\n' +
- '//localhost:' + common.port + '/:_password = ' + Buffer.from('feast').toString('base64'))
-
-test(function (t) {
- let child
- t.plan(5)
- require('http').createServer(function (req, res) {
- t.pass('got request on the fakey fake registry')
- let body = ''
- req.on('data', (d) => { body += d })
- req.on('end', () => {
- this.close()
- res.statusCode = 500
- res.end(JSON.stringify({
- error: 'sshhh. naptime nao. \\^O^/ <(YAWWWWN!)'
- }))
- t.match(body, /"beta"/, 'got expected tag')
- child.kill('SIGINT')
- })
- }).listen(common.port, () => {
- t.pass('server is listening')
-
- // don't much care about listening to the child's results
- // just wanna make sure it hits the server we just set up.
- //
- // there are plenty of other tests to verify that publish
- // itself functions normally.
- //
- // Make sure that we don't sit around waiting for lock files
- child = common.npm([
- 'publish',
- '--userconfig=' + pkg + '/fixture_npmrc',
- '--tag=beta',
- '--loglevel', 'error'
- ], {
- cwd: pkg,
- env: {
- 'npm_config_cache_lock_stale': 1000,
- 'npm_config_cache_lock_wait': 1000,
- HOME: process.env.HOME,
- Path: process.env.PATH,
- PATH: process.env.PATH,
- USERPROFILE: process.env.USERPROFILE
- }
- }, function (err, code, stdout, stderr) {
- t.comment(stdout)
- t.comment(stderr)
- t.ifError(err, 'publish command finished successfully')
- t.notOk(code, 'npm install exited with code 0')
- })
- })
-})
diff --git a/deps/npm/test/tap/publish-invalid-semver-tag.js b/deps/npm/test/tap/publish-invalid-semver-tag.js
deleted file mode 100644
index 9c2f40813b..0000000000
--- a/deps/npm/test/tap/publish-invalid-semver-tag.js
+++ /dev/null
@@ -1,76 +0,0 @@
-var common = require('../common-tap.js')
-var test = require('tap').test
-var npm = require('../../lib/npm.js')
-var mkdirp = require('mkdirp')
-var path = require('path')
-var fs = require('fs')
-var mr = require('npm-registry-mock')
-
-var PKG_DIR = common.pkg
-let cacheIteration = 0
-let CACHE_DIR
-
-var DEFAULT_PKG = {
- 'name': 'examples',
- 'version': '1.2.3'
-}
-
-const isRoot = process.getuid && process.getuid() === 0
-const sudoUID = isRoot ? +process.env.SUDO_UID : null
-const sudoGID = isRoot ? +process.env.SUDO_GID : null
-const { chownSync } = require('fs')
-function resetPackage (options) {
- CACHE_DIR = path.resolve(common.cache, '' + cacheIteration++)
- mkdirp.sync(CACHE_DIR)
- npm.config.set('cache', CACHE_DIR)
-
- if (isRoot && sudoUID && sudoGID) {
- chownSync(CACHE_DIR, sudoUID, sudoGID)
- }
-
- fs.writeFileSync(path.resolve(PKG_DIR, 'package.json'), JSON.stringify(DEFAULT_PKG))
-}
-
-test('setup', function (t) {
- mkdirp.sync(PKG_DIR)
- process.chdir(PKG_DIR)
-
- mr({ port: common.port }, function (er, server) {
- if (er) {
- throw er
- }
- t.parent.teardown(() => server.close())
- npm.load({
- cache: common.cache,
- registry: common.registry,
- cwd: PKG_DIR
- }, function (err) {
- if (err) {
- throw err
- }
- t.end()
- })
- })
-})
-
-test('attempt publish with semver-like version', function (t) {
- resetPackage({})
-
- npm.config.set('tag', 'v1.x')
- npm.commands.publish([], function (err) {
- t.notEqual(err, null)
- t.same(err.message, 'Tag name must not be a valid SemVer range: v1.x')
- t.end()
- })
-})
-
-test('attempt publish with semver-like version', function (t) {
- resetPackage({})
-
- npm.config.set('tag', '1.2.3')
- npm.commands.publish([], function (err) {
- t.notEqual(err, null)
- t.same(err.message, 'Tag name must not be a valid SemVer range: 1.2.3')
- t.end()
- })
-})
diff --git a/deps/npm/test/tap/publish-scoped.js b/deps/npm/test/tap/publish-scoped.js
deleted file mode 100644
index 82873688cd..0000000000
--- a/deps/npm/test/tap/publish-scoped.js
+++ /dev/null
@@ -1,81 +0,0 @@
-var fs = require('fs')
-var path = require('path')
-
-var test = require('tap').test
-var common = require('../common-tap')
-var mr = require('npm-registry-mock')
-
-var pkg = common.pkg
-
-var server
-
-function setup () {
- fs.writeFileSync(
- path.join(pkg, 'package.json'),
- JSON.stringify({
- name: '@bigco/publish-organized',
- version: '1.2.5'
- }, null, 2),
- 'ascii')
-}
-
-test('setup', function (t) {
- setup()
- mr({port: common.port, throwOnUnmatched: true}, function (err, s) {
- t.ifError(err, 'registry mocked successfully')
- server = s
- t.end()
- })
-})
-
-test('npm publish should honor scoping', function (t) {
- server.filteringRequestBody(verify)
- .put('/@bigco%2fpublish-organized', true)
- .reply(201, {ok: true})
-
- var configuration = [
- 'progress=false',
- 'cache=' + common.cache,
- 'registry=http://nonexistent.lvh.me',
- '//localhost:' + common.port + '/:username=username',
- '//localhost:' + common.port + '/:_password=' + Buffer.from('password').toString('base64'),
- '//localhost:' + common.port + '/:email=' + 'ogd@aoaioxxysz.net',
- '@bigco:registry=' + common.registry
- ]
- var configFile = path.join(pkg, '.npmrc')
-
- fs.writeFileSync(configFile, configuration.join('\n') + '\n')
-
- common.npm(['publish'], {'cwd': pkg, nodeExecPath: process.execPath}, function (err, code, stdout, stderr) {
- if (err) throw err
- t.is(code, 0, 'published without error')
- server.done()
- t.end()
- })
-
- function verify (body) {
- t.doesNotThrow(function () {
- var parsed = JSON.parse(body)
- var current = parsed.versions['1.2.5']
- t.equal(
- current._npmVersion,
- require(path.resolve(__dirname, '../../package.json')).version,
- 'npm version is correct'
- )
-
- t.equal(
- current._nodeVersion,
- process.versions.node,
- 'node version is correct'
- )
- }, 'converted body back into object')
-
- return true
- }
-})
-
-test('cleanup', function (t) {
- server.close()
- process.chdir(__dirname)
- t.end()
-})
diff --git a/deps/npm/test/tap/publish.js b/deps/npm/test/tap/publish.js
deleted file mode 100644
index 453abcecd4..0000000000
--- a/deps/npm/test/tap/publish.js
+++ /dev/null
@@ -1,162 +0,0 @@
-'use strict'
-
-const BB = require('bluebird')
-
-const common = require('../common-tap')
-const fs = require('fs')
-const mr = BB.promisify(require('npm-registry-mock'))
-const path = require('path')
-const test = require('tap').test
-
-const testDir = common.pkg
-
-function setup () {
- fs.writeFileSync(
- path.join(testDir, 'package.json'),
- JSON.stringify({
- name: 'publish-organized',
- version: '1.2.5'
- }, null, 2),
- 'utf8'
- )
-
- fs.writeFileSync(
- path.join(testDir, 'index.js'),
- 'hello',
- 'utf8'
- )
-}
-
-let port = common.port
-function withServer (cb) {
- return mr({port: port++, throwOnUnmatched: true})
- .tap(cb)
- .then((server) => {
- server.done()
- return server.close()
- })
-}
-
-test('basic npm publish', (t) => {
- setup()
- return withServer((server) => {
- server.filteringRequestBody(verify)
- .put('/publish-organized', true)
- .reply(201, {ok: true})
-
- return common.npm([
- 'publish',
- '--no-color',
- '--cache', common.cache,
- '--registry=' + common.registry.replace(common.port, server.port),
- `--//localhost:${server.port}/:username=username`,
- `--//localhost:${server.port}/:_password=` + Buffer.from('password').toString('base64'),
- `--//localhost:${server.port}/:email=` + 'ogd@aoaioxxysz.net'
- ], {
- 'cwd': testDir,
- nodeExecPath: process.execPath
- })
- .spread((code, stdout, stderr) => {
- t.comment(stdout)
- t.comment(stderr)
- t.is(code, 0, 'published without error')
- })
-
- function verify (body) {
- t.doesNotThrow(() => {
- const parsed = JSON.parse(body)
- const current = parsed.versions['1.2.5']
- t.equal(
- current._npmVersion,
- require(path.resolve(__dirname, '../../package.json')).version,
- 'npm version is correct'
- )
-
- t.equal(
- current._nodeVersion,
- process.versions.node,
- 'node version is correct'
- )
- }, 'converted body back into object')
-
- return true
- }
- })
-})
-
-test('npm publish --dry-run', (t) => {
- setup()
- return common.npm([
- 'publish',
- '--dry-run',
- '--registry=https://example.registry/fake',
- '--cache', common.cache,
- '--loglevel=notice',
- '--no-color'
- ], {'cwd': testDir})
- .spread((code, stdout, stderr) => {
- t.comment(stdout)
- t.comment(stderr)
- t.is(code, 0, 'published without error')
- t.match(stderr, /notice\s+\d+[a-z]+\s+package\.json/gi, 'mentions package.json')
- t.match(stderr, /notice\s+\d+[a-z]+\s+index\.js/gi, 'mentions index.js')
- })
-})
-
-test('npm publish --json', (t) => {
- setup()
- return withServer((server) => {
- server.filteringRequestBody(() => true)
- .put('/publish-organized', true)
- .reply(201, {ok: true})
- return common.npm([
- 'publish',
- '--json',
- '--registry', common.registry.replace(common.port, server.port),
- '--cache', common.cache
- ], {'cwd': testDir})
- .spread((code, stdout, stderr) => {
- t.comment(stdout)
- t.comment(stderr)
- t.is(code, 0, 'published without error')
- t.similar(JSON.parse(stdout), {
- name: 'publish-organized',
- version: '1.2.5',
- files: [
- {path: 'index.js'},
- {path: 'package.json'}
- ],
- entryCount: 2
- }, 'JSON output reflects package contents')
- t.equal(stderr.trim(), '', 'nothing on stderr')
- })
- })
-})
-
-test('npm publish --dry-run --json', (t) => {
- setup()
- return common.npm([
- 'publish',
- '--dry-run',
- '--json',
- '--registry=https://example.registry/fake',
- '--cache', common.cache,
- '--loglevel=notice',
- '--no-color'
- ], {'cwd': testDir})
- .spread((code, stdout, stderr) => {
- t.comment(stdout)
- t.comment(stderr)
- t.is(code, 0, 'published without error')
- t.similar(JSON.parse(stdout), {
- name: 'publish-organized',
- version: '1.2.5',
- files: [
- {path: 'index.js'},
- {path: 'package.json'}
- ],
- entryCount: 2
- }, 'JSON output reflects package contents')
- t.equal(stderr.trim(), '', 'nothing on stderr')
- })
-})
diff --git a/deps/npm/test/tap/pwd-prefix.js b/deps/npm/test/tap/pwd-prefix.js
deleted file mode 100644
index 1b59f5c838..0000000000
--- a/deps/npm/test/tap/pwd-prefix.js
+++ /dev/null
@@ -1,35 +0,0 @@
-// This test ensures that a few commands do the same
-// thing when the cwd is where package.json is, and when
-// the package.json is one level up.
-
-var test = require('tap').test
-var common = require('../common-tap.js')
-var path = require('path')
-var root = path.resolve(__dirname, '../..')
-var lib = path.resolve(root, 'lib')
-var commands = ['run', 'version']
-
-commands.forEach(function (cmd) {
- // Should get the same stdout and stderr each time
- var stdout, stderr
-
- test(cmd + ' in root', function (t) {
- common.npm([cmd], {cwd: root}, function (er, code, so, se) {
- if (er) throw er
- t.notOk(code, 'npm ' + cmd + ' exited with code 0')
- stdout = so
- stderr = se
- t.end()
- })
- })
-
- test(cmd + ' in lib', function (t) {
- common.npm([cmd], {cwd: lib}, function (er, code, so, se) {
- if (er) throw er
- t.notOk(code, 'npm ' + cmd + ' exited with code 0')
- t.equal(so, stdout)
- t.equal(se, stderr)
- t.end()
- })
- })
-})
diff --git a/deps/npm/test/tap/referer.js b/deps/npm/test/tap/referer.js
deleted file mode 100644
index 6df676db62..0000000000
--- a/deps/npm/test/tap/referer.js
+++ /dev/null
@@ -1,83 +0,0 @@
-var common = require('../common-tap.js')
-var test = require('tap').test
-var http = require('http')
-
-test('should send referer http header', function (t) {
- http.createServer(function (q, s) {
- t.equal(q.headers.referer, 'install foo')
- s.statusCode = 404
- s.end(JSON.stringify({error: 'whatever'}))
- this.close()
- }).listen(common.port, function () {
- var reg = 'http://localhost:' + common.port
- var args = [ 'install', 'foo', '--registry', reg ]
- common.npm(args, {}, function (er, code) {
- if (er) {
- throw er
- }
- // should not have ended nicely, since we returned an error
- t.ok(code)
- t.end()
- })
- })
-})
-
-test('should redact user secret from hook add command', function (t) {
- http.createServer(function (q, s) {
- t.equal(q.headers.referer, 'hook add ~zkat [REDACTED] [REDACTED]')
- s.statusCode = 204
- s.end()
- this.close()
- }).listen(common.port, function () {
- var reg = `http://localhost:${common.port}`
- var args = [ 'hook', 'add', '~zkat', 'https://example.com', 'sekrit', '--registry', reg ]
- common.npm(args, {}, function (er, code) {
- if (er) {
- throw er
- }
- // should not have ended nicely, since we returned an error
- t.ok(code)
- t.end()
- })
- })
-})
-
-test('should redact user secret from hook up command', function (t) {
- http.createServer(function (q, s) {
- t.equal(q.headers.referer, 'hook up ~zkat [REDACTED] [REDACTED]')
- s.statusCode = 204
- s.end()
- this.close()
- }).listen(common.port, function () {
- var reg = `http://localhost:${common.port}`
- var args = [ 'hook', 'up', '~zkat', 'https://example.com', 'sekrit', '--registry', reg ]
- common.npm(args, {}, function (er, code) {
- if (er) {
- throw er
- }
- // should not have ended nicely, since we returned an error
- t.ok(code)
- t.end()
- })
- })
-})
-
-test('should redact user secret from hook update command', function (t) {
- http.createServer(function (q, s) {
- t.equal(q.headers.referer, 'hook update ~zkat [REDACTED] [REDACTED]')
- s.statusCode = 204
- s.end()
- this.close()
- }).listen(common.port, function () {
- var reg = `http://localhost:${common.port}`
- var args = [ 'hook', 'update', '~zkat', 'https://example.com', 'sekrit', '--registry', reg ]
- common.npm(args, {}, function (er, code) {
- if (er) {
- throw er
- }
- // should not have ended nicely, since we returned an error
- t.ok(code)
- t.end()
- })
- })
-})
diff --git a/deps/npm/test/tap/repo.js b/deps/npm/test/tap/repo.js
deleted file mode 100644
index 3e97fdeaed..0000000000
--- a/deps/npm/test/tap/repo.js
+++ /dev/null
@@ -1,175 +0,0 @@
-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 fakeBrowser = path.join(common.pkg, '_script.sh')
-var outFile = path.join(common.pkg, '_output')
-var opts = { cwd: common.pkg }
-var mkdirp = require('mkdirp')
-
-common.pendIfWindows('This is trickier to convert without opening new shells')
-
-test('setup', function (t) {
- mkdirp.sync(common.pkg)
- var s = '#!/usr/bin/env bash\n' +
- 'echo "$@" > ' + JSON.stringify(common.pkg) + '/_output\n'
- fs.writeFileSync(fakeBrowser, s, 'ascii')
- fs.chmodSync(fakeBrowser, '0755')
- t.pass('made script')
- t.end()
-})
-
-test('npm repo underscore', function (t) {
- mr({ port: common.port }, function (er, s) {
- common.npm([
- 'repo', 'underscore',
- '--registry=' + common.registry,
- '--loglevel=silent',
- '--browser=' + fakeBrowser
- ], opts, function (err, code, stdout, stderr) {
- t.ifError(err, 'repo command ran without error')
- t.equal(code, 0, 'exit ok')
- var res = fs.readFileSync(outFile, 'ascii')
- s.close()
- t.equal(res, 'https://github.com/jashkenas/underscore\n')
- rimraf.sync(outFile)
- t.end()
- })
- })
-})
-
-test('npm repo underscore --json', function (t) {
- mr({ port: common.port }, function (er, s) {
- common.npm([
- 'repo', 'underscore',
- '--json',
- '--registry=' + common.registry,
- '--loglevel=silent',
- '--no-browser'
- ], opts, function (err, code, stdout, stderr) {
- t.ifError(err, 'repo command ran without error')
- t.equal(code, 0, 'exit ok')
- t.matchSnapshot(stdout, 'should print json result')
- s.close()
- t.end()
- })
- })
-})
-
-test('npm repo underscore --no-browser', function (t) {
- mr({ port: common.port }, function (er, s) {
- common.npm([
- 'repo', 'underscore',
- '--no-browser',
- '--registry=' + common.registry,
- '--loglevel=silent'
- ], opts, function (err, code, stdout, stderr) {
- t.ifError(err, 'repo command ran without error')
- t.equal(code, 0, 'exit ok')
- t.matchSnapshot(stdout, 'should print alternative msg')
- s.close()
- t.end()
- })
- })
-})
-
-test('npm repo optimist - github (https://)', function (t) {
- mr({ port: common.port }, function (er, s) {
- common.npm([
- 'repo', 'optimist',
- '--registry=' + common.registry,
- '--loglevel=silent',
- '--browser=' + fakeBrowser
- ], opts, function (err, code, stdout, stderr) {
- t.ifError(err, 'repo command ran without error')
- t.equal(code, 0, 'exit ok')
- var res = fs.readFileSync(outFile, 'ascii')
- s.close()
- t.equal(res, 'https://github.com/substack/node-optimist\n')
- rimraf.sync(outFile)
- t.end()
- })
- })
-})
-
-test('npm repo npm-test-peer-deps - no repo', function (t) {
- mr({ port: common.port }, function (er, s) {
- common.npm([
- 'repo', 'npm-test-peer-deps',
- '--registry=' + common.registry,
- '--loglevel=silent',
- '--browser=' + fakeBrowser
- ], opts, function (err, code, stdout, stderr) {
- t.ifError(err, 'repo command ran without error')
- t.equal(code, 1, 'exit not ok')
- s.close()
- t.end()
- })
- })
-})
-
-test('npm repo test-repo-url-http - non-github (http://)', function (t) {
- mr({ port: common.port }, function (er, s) {
- common.npm([
- 'repo', 'test-repo-url-http',
- '--registry=' + common.registry,
- '--loglevel=silent',
- '--browser=' + fakeBrowser
- ], opts, function (err, code, stdout, stderr) {
- t.ifError(err, 'repo command ran without error')
- t.equal(code, 0, 'exit ok')
- var res = fs.readFileSync(outFile, 'ascii')
- s.close()
- t.equal(res, 'http://gitlab.com/evanlucas/test-repo-url-http\n')
- rimraf.sync(outFile)
- t.end()
- })
- })
-})
-
-test('npm repo test-repo-url-https - non-github (https://)', function (t) {
- mr({ port: common.port }, function (er, s) {
- common.npm([
- 'repo', 'test-repo-url-https',
- '--registry=' + common.registry,
- '--loglevel=silent',
- '--browser=' + fakeBrowser
- ], opts, function (err, code, stdout, stderr) {
- t.ifError(err, 'repo command ran without error')
- t.equal(code, 0, 'exit ok')
- var res = fs.readFileSync(outFile, 'ascii')
- s.close()
- t.equal(res, 'https://gitlab.com/evanlucas/test-repo-url-https\n')
- rimraf.sync(outFile)
- t.end()
- })
- })
-})
-
-test('npm repo test-repo-url-ssh - non-github (ssh://)', function (t) {
- mr({ port: common.port }, function (er, s) {
- common.npm([
- 'repo', 'test-repo-url-ssh',
- '--registry=' + common.registry,
- '--loglevel=silent',
- '--browser=' + fakeBrowser
- ], opts, function (err, code, stdout, stderr) {
- t.ifError(err, 'repo command ran without error')
- t.equal(code, 0, 'exit ok')
- var res = fs.readFileSync(outFile, 'ascii')
- s.close()
- t.equal(res, 'https://gitlab.com/evanlucas/test-repo-url-ssh\n')
- rimraf.sync(outFile)
- t.end()
- })
- })
-})
-
-test('cleanup', function (t) {
- fs.unlinkSync(fakeBrowser)
- t.pass('cleaned up')
- t.end()
-})
diff --git a/deps/npm/test/tap/retry-on-stale-cache.js b/deps/npm/test/tap/retry-on-stale-cache.js
deleted file mode 100644
index 7e3d291a5b..0000000000
--- a/deps/npm/test/tap/retry-on-stale-cache.js
+++ /dev/null
@@ -1,195 +0,0 @@
-var path = require('path')
-
-var mr = require('npm-registry-mock')
-var test = require('tap').test
-var common = require('../common-tap')
-var Tacks = require('tacks')
-var Dir = Tacks.Dir
-var File = Tacks.File
-
-var workdir = common.pkg
-var cachedir = common.cache
-var modulesdir = path.join(workdir, 'modules')
-var oldModule = path.join(modulesdir, 'good-night-0.1.0.tgz')
-var newModule = path.join(modulesdir, 'good-night-1.0.0.tgz')
-
-var config = [
- '--cache', cachedir,
- '--prefix', workdir,
- '--registry', common.registry
-]
-
-var fixture = new Tacks(Dir({
- 'modules': Dir({
- 'good-night-0.1.0.tgz': File(Buffer.from(
- '1f8b0800000000000003ed934f4bc43010c57beea7187a59056dd36eff80' +
- 'de85050541c1f3d8c634da4e4a925a8af8dd6db7bb8ba0e0c15559e9eff2' +
- '206f929909bc06f327143c6826f51f8d2267cf30c6d2388641c32c61ef75' +
- '4d9426e084519a25491645cbcc61e192c5d1e0ef7b90cf688d453d8cf2dd' +
- '77a65d60a707c28b0b031e61cdbd33f08452c52949515aef64729eb93652' +
- 'd168323ff4d9f6bce026d7b2b11bafef11b1eb3a221a2aa6126c6da9f4e8' +
- '5e691f6e908a1a697b5ff346196995eec7023399c1c7fe95cc3999f57077' +
- 'b717d7979efbeafef5a7fd2336b90f6a943484ff477a7c917f96c5bbfc87' +
- '493ae63f627138e7ff37c815195571bf52e268b1820e0d0825498055d069' +
- '6939d8521ab86f2dace0815715a0a9386f16c7e7730c676666660e9837c0' +
- 'f6795d000c0000',
- 'hex'
- )),
- 'good-night-1.0.0.tgz': File(Buffer.from(
- '1f8b0800000000000003ed954d6bc24010863dfb2bb6b9a8503793b849a0' +
- 'eda5979efa052d484184252e495a331b76d78a94fef76e8cf683163cd42a' +
- '957d2e03796777268187543c7de299f0aba6d2472db1b5650020668cd81a' +
- '24117cae4bc23822ad208c93284a1208c216040318c436dff6223f31d386' +
- '2bbbca6fef69de85bcd77fc24b9b583ce4a5f04e88974939e96391e5c63b' +
- '6e9267a17421b10e030a14d6cf2742a7aaa8cc2a5b2c38e7f3f91c116d47' +
- 'd3c2672697aa4eaf1425771c2725c7f579252aa90b23d5a26ed04de87f9f' +
- '3f2d52817ab9dcf0fee2f6d26bbfb6f7fdd10e8895f77ec90bb4f2ffc98c' +
- '0dfe439c7cf81fc4b5ff213070feef8254a2965341a732eb76b4cef39c12' +
- 'e456eb52d82a29198dc637639f9c751fce8796eba35ea777ea0c3c14d6fe' +
- '532314f62ba9ccf6676cf21fbefcff59ed3f4b22e7ff2e60110bc37d2fe1' +
- '70381c8e9df306642df14500100000',
- 'hex'
- ))
- })
-}))
-
-var server
-
-// In this test we mock a situation where the user has a package in his cache,
-// a newer version of the package is published, and the user tried to install
-// said new version while requestion that the cache be used.
-// npm should see that it doesn't have the package in its cache and hit the
-// registry.
-var onlyOldMetadata = {
- 'name': 'good-night',
- 'dist-tags': {
- 'latest': '0.1.0'
- },
- 'versions': {
- '0.1.0': {
- 'name': 'good-night',
- 'version': '0.1.0',
- 'dist': {
- 'shasum': '2a746d49dd074ba0ec2d6ff13babd40c658d89eb',
- 'tarball': 'http://localhost:' + common.port + '/good-night/-/good-night-0.1.0.tgz'
- }
- }
- }
-}
-
-var oldAndNewMetadata = Object.assign({}, onlyOldMetadata)
-oldAndNewMetadata['dist-tags'] = { latest: '1.0.0' }
-oldAndNewMetadata.versions = Object.assign({
- '1.0.0': {
- 'name': 'good-night',
- 'version': '1.0.0',
- 'dist': {
- 'shasum': 'f377bf002a0a8fc4085d347a160a790b76896bc3',
- 'tarball': 'http://localhost:' + common.port + '/good-night/-/good-night-1.0.0.tgz'
- }
- }
-}, oldAndNewMetadata.versions)
-
-function setup () {
- cleanup()
- fixture.create(workdir)
-}
-
-function cleanup () {
- fixture.remove(workdir)
-}
-
-test('setup', function (t) {
- setup()
- t.end()
-})
-
-test('setup initial server', function (t) {
- mr({
- port: common.port,
- throwOnUnmatched: true
- }, function (err, s) {
- t.ifError(err, 'registry mocked successfully')
- server = s
-
- server.get('/good-night')
- .many({ min: 1, max: 1 })
- .reply(200, onlyOldMetadata)
- server.get('/good-night/-/good-night-0.1.0.tgz')
- .many({ min: 1, max: 1 })
- .replyWithFile(200, oldModule)
-
- t.end()
- })
-})
-
-test('install initial version', function (t) {
- common.npm(config.concat([
- 'install', 'good-night'
- ]), {stdio: 'inherit'}, function (err, code) {
- if (err) throw err
- t.is(code, 0, 'initial install succeeded')
- server.done()
- t.end()
- })
-})
-
-test('cleanup initial server', function (t) {
- server.close()
- t.end()
-})
-
-test('setup new server', function (t) {
- mr({
- port: common.port,
- throwOnUnmatched: true
- }, function (err, s) {
- t.ifError(err, 'registry mocked successfully')
- server = s
-
- server.get('/good-night')
- .many({ min: 1, max: 1 })
- .reply(200, oldAndNewMetadata)
-
- server.get('/good-night/-/good-night-1.0.0.tgz')
- .many({ min: 1, max: 1 })
- .replyWithFile(200, newModule)
-
- t.end()
- })
-})
-
-test('install new version', function (t) {
- common.npm(config.concat([
- '--prefer-offline',
- 'install', 'good-night@1.0.0'
- ]), {}, function (err, code, stdout, stderr) {
- if (err) throw err
- t.equal(stderr, '', 'no error output')
- t.is(code, 0, 'install succeeded')
-
- t.end()
- })
-})
-
-test('install does not hit server again', function (t) {
- // The mock server route definitions ensure we don't hit the server again
- common.npm(config.concat([
- '--prefer-offline',
- '--parseable',
- 'install', 'good-night'
- ]), {stdio: [0, 'pipe', 2]}, function (err, code, stdout) {
- if (err) throw err
- t.is(code, 0, 'install succeeded')
-
- t.match(stdout, /^update\tgood-night\t1.0.0\t/, 'installed latest version')
- server.done()
- t.end()
- })
-})
-
-test('cleanup', function (t) {
- server.close()
- cleanup()
- t.end()
-})
diff --git a/deps/npm/test/tap/run-script-filter-private.js b/deps/npm/test/tap/run-script-filter-private.js
deleted file mode 100644
index 31f1912fd1..0000000000
--- a/deps/npm/test/tap/run-script-filter-private.js
+++ /dev/null
@@ -1,52 +0,0 @@
-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')
-
-var pkg = common.pkg
-
-var opts = { cwd: pkg }
-
-var json = {
- name: 'run-script-filter-private',
- version: '1.2.3'
-}
-
-var npmrc = '//blah.com:_harsh=realms\n'
-
-test('setup', function (t) {
- cleanup()
- mkdirp.sync(pkg)
- fs.writeFileSync(
- path.resolve(pkg, 'package.json'),
- JSON.stringify(json, null, 2) + '\n'
- )
- fs.writeFileSync(
- path.resolve(pkg, '.npmrc'),
- npmrc
- )
- t.end()
-})
-
-test('npm run-script env', function (t) {
- common.npm(['run-script', 'env'], opts, function (er, code, stdout, stderr) {
- t.ifError(er, 'using default env script')
- t.notOk(stderr, 'should not generate errors')
- t.ok(stdout.indexOf('npm_config_init_version') > 0, 'expected values in var list')
- t.notMatch(stdout, /harsh/, 'unexpected config not there')
- t.end()
- })
-})
-
-test('cleanup', function (t) {
- cleanup()
- t.end()
-})
-
-function cleanup () {
- rimraf.sync(pkg)
-}
diff --git a/deps/npm/test/tap/run-script.js b/deps/npm/test/tap/run-script.js
deleted file mode 100644
index 75b714002e..0000000000
--- a/deps/npm/test/tap/run-script.js
+++ /dev/null
@@ -1,373 +0,0 @@
-var fs = require('graceful-fs')
-var path = require('path')
-
-var mkdirp = require('mkdirp')
-var test = require('tap').test
-var rimraf = require('rimraf')
-
-var common = require('../common-tap')
-
-var pkg = common.pkg
-var cache = common.cache
-var tmp = path.resolve(pkg, 'tmp')
-
-var opts = { cwd: pkg }
-
-var fullyPopulated = {
- 'name': 'runscript',
- 'version': '1.2.3',
- 'scripts': {
- 'start': 'node -e "console.log(process.argv[1] || \'start\')"',
- 'prewith-pre': 'node -e "console.log(process.argv[1] || \'pre\')"',
- 'with-pre': 'node -e "console.log(process.argv[1] || \'main\')"',
- 'with-post': 'node -e "console.log(process.argv[1] || \'main\')"',
- 'postwith-post': 'node -e "console.log(process.argv[1] || \'post\')"',
- 'prewith-both': 'node -e "console.log(process.argv[1] || \'pre\')"',
- 'with-both': 'node -e "console.log(process.argv[1] || \'main\')"',
- 'postwith-both': 'node -e "console.log(process.argv[1] || \'post\')"',
- 'stop': 'node -e "console.log(process.argv[1] || \'stop\')"',
- 'env-vars': 'node -e "console.log(process.env.run_script_foo_var)"',
- 'npm-env-vars': 'node -e "console.log(process.env.npm_run_script_foo_var)"',
- 'package-env-vars': 'node -e "console.log(process.env.run_script_foo_var)"',
- 'prefixed-package-env-vars': 'node -e "console.log(process.env.npm_package_run_script_foo_var)"'
- },
- 'run_script_foo_var': 'run_script_test_foo_val'
-}
-
-var lifecycleOnly = {
- name: 'scripted',
- version: '1.2.3',
- scripts: {
- 'prestart': 'echo prestart'
- }
-}
-
-var directOnly = {
- name: 'scripted',
- version: '1.2.3',
- scripts: {
- 'whoa': 'echo whoa'
- }
-}
-
-var both = {
- name: 'scripted',
- version: '1.2.3',
- scripts: {
- 'prestart': 'echo prestart',
- 'whoa': 'echo whoa'
- }
-}
-
-var preversionOnly = {
- name: 'scripted',
- version: '1.2.3',
- scripts: {
- 'preversion': 'echo preversion'
- }
-}
-
-var exitCode = {
- name: 'scripted',
- version: '1.2.3',
- scripts: {
- 'start': 'node -e "process.exit(7)"'
- }
-}
-
-var shell = {
- name: 'scripted',
- version: '1.2.3',
- scripts: {
- 'start': 'echo foo'
- }
-}
-
-function testOutput (t, command, er, code, stdout, stderr) {
- var lines
-
- if (er) throw er
-
- if (stderr) {
- throw new Error('npm ' + command + ' stderr: ' + stderr.toString())
- }
-
- lines = stdout.trim().split('\n')
- stdout = lines.filter(function (line) {
- return line.trim() !== '' && line[0] !== '>'
- }).join(';')
-
- t.equal(stdout, command)
- t.end()
-}
-
-function writeMetadata (object) {
- fs.writeFileSync(
- path.resolve(pkg, 'package.json'),
- JSON.stringify(object, null, 2) + '\n'
- )
-}
-
-function cleanup () {
- rimraf.sync(pkg)
-}
-
-test('setup', function (t) {
- cleanup()
- mkdirp.sync(cache)
- mkdirp.sync(tmp)
- writeMetadata(fullyPopulated)
- t.end()
-})
-
-test('npm run-script start', function (t) {
- common.npm(['run-script', 'start'], opts, testOutput.bind(null, t, 'start'))
-})
-
-test('npm run-script with args', function (t) {
- common.npm(['run-script', 'start', '--', 'stop'], opts, testOutput.bind(null, t, 'stop'))
-})
-
-test('npm run-script with args that contain spaces', function (t) {
- common.npm(['run-script', 'start', '--', 'hello world'], opts, testOutput.bind(null, t, 'hello world'))
-})
-
-test('npm run-script with args that contain single quotes', function (t) {
- common.npm(['run-script', 'start', '--', 'they"re awesome'], opts, testOutput.bind(null, t, 'they"re awesome'))
-})
-
-test('npm run-script with args that contain double quotes', function (t) {
- common.npm(['run-script', 'start', '--', 'what"s "up"?'], opts, testOutput.bind(null, t, 'what"s "up"?'))
-})
-
-test('npm run-script with args that contain ticks', function (t) {
- common.npm(['run-script', 'start', '--', 'what\'s \'up\'?'], opts, testOutput.bind(null, t, 'what\'s \'up\'?'))
-})
-
-test('npm run-script with pre script', function (t) {
- common.npm(['run-script', 'with-post'], opts, testOutput.bind(null, t, 'main;post'))
-})
-
-test('npm run-script with post script', function (t) {
- common.npm(['run-script', 'with-pre'], opts, testOutput.bind(null, t, 'pre;main'))
-})
-
-test('npm run-script with both pre and post script', function (t) {
- common.npm(['run-script', 'with-both'], opts, testOutput.bind(null, t, 'pre;main;post'))
-})
-
-test('npm run-script with both pre and post script and with args', function (t) {
- common.npm(['run-script', 'with-both', '--', 'an arg'], opts, testOutput.bind(null, t, 'pre;an arg;post'))
-})
-
-test('npm run-script explicitly call pre script with arg', function (t) {
- common.npm(['run-script', 'prewith-pre', '--', 'an arg'], opts, testOutput.bind(null, t, 'an arg'))
-})
-
-test('npm run-script test', function (t) {
- common.npm(['run-script', 'test'], opts, function (er, code, stdout, stderr) {
- t.ifError(er, 'npm run-script test ran without issue')
- t.notOk(stderr, 'should not generate errors')
- t.end()
- })
-})
-
-test('npm run-script env', function (t) {
- common.npm(['run-script', 'env'], opts, function (er, code, stdout, stderr) {
- t.ifError(er, 'using default env script')
- t.notOk(stderr, 'should not generate errors')
- t.ok(stdout.indexOf('npm_config_init_version') > 0, 'expected values in var list')
- t.end()
- })
-})
-
-test('npm run-script nonexistent-script', function (t) {
- common.npm(['run-script', 'nonexistent-script'], opts, function (er, code, stdout, stderr) {
- t.ifError(er, 'npm run-script nonexistent-script did not cause npm to explode')
- t.ok(stderr, 'should generate errors')
- t.end()
- })
-})
-
-test('npm run-script restart when there isn\'t restart', function (t) {
- common.npm(['run-script', 'restart'], opts, testOutput.bind(null, t, 'stop;start'))
-})
-
-test('npm run-script nonexistent-script with --if-present flag', function (t) {
- common.npm(['run-script', '--if-present', 'nonexistent-script'], opts, function (er, code, stdout, stderr) {
- t.ifError(er, 'npm run-script --if-present non-existent-script ran without issue')
- t.notOk(stderr, 'should not generate errors')
- t.end()
- })
-})
-
-test('npm run-script env vars accessible', function (t) {
- process.env.run_script_foo_var = 'run_script_test_foo_val'
- common.npm(['run-script', 'env-vars'], {
- cwd: pkg
- }, function (err, code, stdout, stderr) {
- t.ifError(err, 'ran run-script without crashing')
- t.equal(code, 0, 'exited normally')
- t.equal(stderr, '', 'no error output')
- t.match(stdout,
- new RegExp(process.env.run_script_foo_var),
- 'script had env access')
- t.end()
- })
-})
-
-test('npm run-script package.json vars injected', function (t) {
- common.npm(['run-script', 'package-env-vars'], {
- cwd: pkg
- }, function (err, code, stdout, stderr) {
- t.ifError(err, 'ran run-script without crashing')
- t.equal(code, 0, 'exited normally')
- t.equal(stderr, '', 'no error output')
- t.match(stdout,
- new RegExp(fullyPopulated.run_script_foo_var),
- 'script injected package.json value')
- t.end()
- })
-})
-
-test('npm run-script package.json vars injected with prefix', function (t) {
- common.npm(['run-script', 'prefixed-package-env-vars'], {
- cwd: pkg
- }, function (err, code, stdout, stderr) {
- t.ifError(err, 'ran run-script without crashing')
- t.equal(code, 0, 'exited normally')
- t.equal(stderr, '', 'no error output')
- t.match(stdout,
- new RegExp(fullyPopulated.run_script_foo_var),
- 'script injected npm_package-prefixed package.json value')
- t.end()
- })
-})
-
-test('npm run-script env vars stripped npm-prefixed', function (t) {
- process.env.npm_run_script_foo_var = 'run_script_test_foo_val'
- common.npm(['run-script', 'npm-env-vars'], {
- cwd: pkg
- }, function (err, code, stdout, stderr) {
- t.ifError(err, 'ran run-script without crashing')
- t.equal(code, 0, 'exited normally')
- t.equal(stderr, '', 'no error output')
- t.notMatch(stdout,
- new RegExp(process.env.npm_run_script_foo_var),
- 'script stripped npm-prefixed env var')
- t.end()
- })
-})
-
-test('npm run-script no-params (lifecycle only)', function (t) {
- var expected = [
- 'Lifecycle scripts included in scripted:',
- ' prestart',
- ' echo prestart',
- ''
- ].join('\n')
-
- writeMetadata(lifecycleOnly)
-
- common.npm(['run-script'], opts, function (err, code, stdout, stderr) {
- t.ifError(err, 'ran run-script without parameters without crashing')
- t.notOk(code, 'npm exited without error code')
- t.notOk(stderr, 'npm printed nothing to stderr')
- t.equal(stdout, expected, 'got expected output')
- t.end()
- })
-})
-
-test('npm run-script no-params (preversion only)', function (t) {
- var expected = [
- 'Lifecycle scripts included in scripted:',
- ' preversion',
- ' echo preversion',
- ''
- ].join('\n')
-
- writeMetadata(preversionOnly)
-
- common.npm(['run-script'], opts, function (err, code, stdout, stderr) {
- t.ifError(err, 'ran run-script without parameters without crashing')
- t.notOk(code, 'npm exited without error code')
- t.notOk(stderr, 'npm printed nothing to stderr')
- t.equal(stdout, expected, 'got expected output')
- t.end()
- })
-})
-
-test('npm run-script no-params (direct only)', function (t) {
- var expected = [
- 'Scripts available in scripted via `npm run-script`:',
- ' whoa',
- ' echo whoa',
- ''
- ].join('\n')
-
- writeMetadata(directOnly)
-
- common.npm(['run-script'], opts, function (err, code, stdout, stderr) {
- t.ifError(err, 'ran run-script without parameters without crashing')
- t.notOk(code, 'npm exited without error code')
- t.notOk(stderr, 'npm printed nothing to stderr')
- t.equal(stdout, expected, 'got expected output')
- t.end()
- })
-})
-
-test('npm run-script script-shell config', function (t) {
- writeMetadata(shell)
-
- common.npm(['run-script', 'start', '--script-shell', 'echo'], opts, testOutput.bind(null, t, '-c echo foo'))
-})
-
-test('npm run-script no-params (direct only)', function (t) {
- var expected = [
- 'Lifecycle scripts included in scripted:',
- ' prestart',
- ' echo prestart',
- '',
- 'available via `npm run-script`:',
- ' whoa',
- ' echo whoa',
- ''
- ].join('\n')
-
- writeMetadata(both)
-
- common.npm(['run-script'], opts, function (err, code, stdout, stderr) {
- t.ifError(err, 'ran run-script without parameters without crashing')
- t.notOk(code, 'npm exited without error code')
- t.notOk(stderr, 'npm printed nothing to stderr')
- t.equal(stdout, expected, 'got expected output')
- t.end()
- })
-})
-
-test('npm run-script keep non-zero exit code', function (t) {
- writeMetadata(exitCode)
-
- common.npm(['run-script', 'start'], opts, function (err, code, stdout, stderr) {
- t.ifError(err, 'ran run-script without parameters without crashing')
- t.equal(code, 7, 'got expected exit code')
- t.ok(stderr, 'should generate errors')
- t.end()
- })
-})
-
-test('npm run-script nonexistent script and display suggestions', function (t) {
- writeMetadata(directOnly)
-
- common.npm(['run-script', 'whoop'], opts, function (err, code, stdout, stderr) {
- t.ifError(err, 'ran run-script without crashing')
- t.equal(code, 1, 'got expected exit code')
- t.has(stderr, 'Did you mean this?')
- t.end()
- })
-})
-
-test('cleanup', function (t) {
- cleanup()
- t.end()
-})
diff --git a/deps/npm/test/tap/save-optional.js b/deps/npm/test/tap/save-optional.js
deleted file mode 100644
index 9985451684..0000000000
--- a/deps/npm/test/tap/save-optional.js
+++ /dev/null
@@ -1,81 +0,0 @@
-'use strict'
-const path = require('path')
-const test = require('tap').test
-const mr = require('npm-registry-mock')
-const Tacks = require('tacks')
-const fs = require('fs')
-const File = Tacks.File
-const Dir = Tacks.Dir
-const common = require('../common-tap.js')
-
-const basedir = common.pkg
-const testdir = path.join(basedir, 'testdir')
-const cachedir = common.cache
-const globaldir = path.join(basedir, 'global')
-const tmpdir = path.join(basedir, 'tmp')
-
-const conf = {
- cwd: testdir,
- stdio: [0, 1, 2],
- env: Object.assign({}, process.env, {
- npm_config_cache: cachedir,
- npm_config_tmp: tmpdir,
- npm_config_prefix: globaldir,
- npm_config_registry: common.registry,
- npm_config_loglevel: 'silly'
- })
-}
-
-let server
-const fixture = new Tacks(Dir({
- cache: Dir(),
- global: Dir(),
- tmp: Dir(),
- testdir: Dir({
- example: Dir({
- 'package.json': File({
- name: 'example',
- version: '1.0.0'
- })
- }),
- 'package.json': File({
- name: 'save-optional',
- version: '1.0.0'
- })
- })
-}))
-
-function setup () {
- cleanup()
- fixture.create(basedir)
-}
-
-function cleanup () {
- fixture.remove(basedir)
-}
-
-test('setup', function (t) {
- setup()
- mr({port: common.port, throwOnUnmatched: true}, function (err, s) {
- if (err) throw err
- server = s
- t.done()
- })
-})
-
-test('example', function (t) {
- common.npm(['install', '-O', '--package-lock-only', 'file:example'], conf, function (err, code) {
- if (err) throw err
- t.is(code, 0, 'command ran ok')
- const plock = JSON.parse(fs.readFileSync(`${testdir}/package-lock.json`))
- t.like(plock, { dependencies: { example: { optional: true } } }, 'optional status saved')
- // your assertions here
- t.done()
- })
-})
-
-test('cleanup', function (t) {
- server.close()
- cleanup()
- t.done()
-})
diff --git a/deps/npm/test/tap/scope-header.js b/deps/npm/test/tap/scope-header.js
deleted file mode 100644
index f4eb7ae12c..0000000000
--- a/deps/npm/test/tap/scope-header.js
+++ /dev/null
@@ -1,160 +0,0 @@
-'use strict'
-var path = require('path')
-var test = require('tap').test
-var mr = require('npm-registry-mock')
-var Tacks = require('tacks')
-var File = Tacks.File
-var Dir = Tacks.Dir
-var common = require('../common-tap.js')
-
-var basedir = common.pkg
-var testdir = path.join(basedir, 'testdir')
-var withScope = path.join(testdir, 'with-scope')
-var withoutScope = path.join(testdir, 'without-scope')
-var onlyProjectScope = path.join(testdir, 'only-project-scope')
-var cachedir = common.cache
-var globaldir = path.join(basedir, 'global')
-var tmpdir = path.join(basedir, 'tmp')
-
-var env = common.newEnv().extend({
- npm_config_cache: cachedir,
- npm_config_tmp: tmpdir,
- npm_config_prefix: globaldir,
- npm_config_registry: common.registry,
- npm_config_loglevel: 'warn'
-})
-
-var conf = function (cwd) {
- return {
- cwd: cwd || testdir,
- env: env
- }
-}
-var server
-var fixture = new Tacks(Dir({
- cache: Dir(),
- global: Dir(),
- tmp: Dir(),
- testdir: Dir({
- 'with-scope': Dir({
- 'package.json': File({
- name: '@example/with-scope',
- version: '1.0.0'
- })
- }),
- 'without-scope': Dir({
- 'package.json': File({
- name: 'without-scope',
- version: '1.0.0'
- })
- }),
- 'only-project-scope': Dir({
- '.npmrc': File('@example:registry=thisisinvalid\n'),
- 'package.json': File({
- name: '@example/only-project-scope',
- version: '1.0.0'
- })
- })
- })
-}))
-
-function setup () {
- cleanup()
- fixture.create(basedir)
-}
-
-function cleanup () {
- fixture.remove(basedir)
-}
-
-var scopeHeaderTestGotScope = {
- 'time': {'1.0.0': ''},
- 'dist-tags': {'latest': '1.0.0'},
- 'versions': {
- '1.0.0': {
- name: 'scope-header-test',
- version: '1.0.0',
- gotScope: true
- }
- }
-}
-var scopeHeaderTestNoScope = {
- 'time': {'1.0.0': ''},
- 'dist-tags': {'latest': '1.0.0'},
- 'versions': {
- '1.0.0': {
- name: 'scope-header-test',
- version: '1.0.0',
- gotScope: false
- }
- }
-}
-
-test('setup', function (t) {
- setup()
- mr({port: common.port, throwOnUnmatched: true}, function (err, s) {
- if (err) throw err
- server = s
- server.get('/scope-header-test', {
- 'NPM-Scope': '@example'
- }).many().reply('200', scopeHeaderTestGotScope)
- server.get('/scope-header-test', {}).many().reply('200', scopeHeaderTestNoScope)
- t.done()
- })
-})
-
-test('with-scope', function (t) {
- common.npm(['view', '--cache-min=0', 'scope-header-test', 'gotScope'], conf(withScope), function (err, code, stdout, stderr) {
- if (err) throw err
- t.is(code, 0, 'command ran ok')
- t.comment(stderr.trim())
- t.is(stdout.trim(), 'true', 'got version matched to scope header')
- t.done()
- })
-})
-
-test('without-scope', function (t) {
- common.npm(['view', '--cache-min=0', 'scope-header-test', 'gotScope'], conf(withoutScope), function (err, code, stdout, stderr) {
- if (err) throw err
- t.is(code, 0, 'command ran ok')
- t.comment(stderr.trim())
- t.is(stdout.trim(), 'false', 'got version matched to NO scope header')
- t.done()
- })
-})
-
-test('scope can be forced by having an explicit one', function (t) {
- common.npm([
- 'view',
- '--cache-min=0',
- '--scope=example',
- 'scope-header-test',
- 'gotScope'
- ], conf(withoutScope), function (err, code, stdout, stderr) {
- if (err) throw err
- t.is(code, 0, 'command ran ok')
- t.comment(stderr.trim())
- t.is(stdout.trim(), 'true', 'got version matched to scope header')
- t.done()
- })
-})
-
-test('only the project scope is used', function (t) {
- common.npm([
- 'view',
- '--cache-min=0',
- 'scope-header-test', 'gotScope'
- ], conf(onlyProjectScope), function (err, code, stdout, stderr) {
- if (err) throw err
- t.is(code, 0, 'command ran ok')
- t.comment(stderr.trim())
- t.is(stdout.trim(), 'true', 'got version scope')
- t.done()
- })
-})
-
-test('cleanup', function (t) {
- server.close()
- cleanup()
- t.done()
-})
diff --git a/deps/npm/test/tap/scripts-whitespace-windows.js b/deps/npm/test/tap/scripts-whitespace-windows.js
deleted file mode 100644
index 9a301dca52..0000000000
--- a/deps/npm/test/tap/scripts-whitespace-windows.js
+++ /dev/null
@@ -1,88 +0,0 @@
-var fs = require('graceful-fs')
-var path = require('path')
-
-var mkdirp = require('mkdirp')
-var test = require('tap').test
-
-var common = require('../common-tap')
-
-var pkg = common.pkg
-var tmp = path.resolve(pkg, 'tmp')
-var cache = common.cache
-var dep = path.resolve(pkg, 'dep')
-
-var EXEC_OPTS = { cwd: pkg }
-
-var json = {
- name: 'scripts-whitespace-windows',
- version: '1.0.0',
- description: 'a test',
- repository: 'git://github.com/robertkowalski/bogus',
- scripts: {
- foo: 'foo --title "Analysis of" --recurse -d report src'
- },
- dependencies: {
- 'scripts-whitespace-windows-dep': '0.0.1'
- },
- license: 'WTFPL'
-}
-
-var dependency = {
- name: 'scripts-whitespace-windows-dep',
- version: '0.0.1',
- bin: [ 'bin/foo' ]
-}
-
-var foo = function () { /*
-#!/usr/bin/env node
-
-if (process.argv.length === 8)
- console.log('npm-test-fine')
-*/ }.toString().split('\n').slice(1, -1).join('\n')
-
-test('setup', function (t) {
- mkdirp.sync(tmp)
- fs.writeFileSync(
- path.join(pkg, 'package.json'),
- JSON.stringify(json, null, 2)
- )
- fs.writeFileSync(
- path.join(pkg, 'README.md'),
- "### THAT'S RIGHT\n"
- )
-
- 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)
-
- common.npm(['i', dep], {
- cwd: pkg,
- env: Object.assign({
- npm_config_cache: cache,
- npm_config_tmp: tmp,
- npm_config_prefix: pkg,
- npm_config_global: 'false'
- }, process.env)
- }, function (err, code, stdout, stderr) {
- t.ifErr(err, 'npm i ' + dep + ' finished without error')
- t.equal(code, 0, 'npm i ' + dep + ' exited ok')
- t.notOk(stderr, 'no output stderr')
- t.end()
- })
-})
-
-test('test', function (t) {
- common.npm(['run', 'foo'], EXEC_OPTS, function (err, code, stdout, stderr) {
- stderr = stderr.trim()
- if (stderr) console.error(stderr)
- t.ifErr(err, 'npm run finished without error')
- t.equal(code, 0, 'npm run exited ok')
- t.notOk(stderr, 'no output stderr: ' + stderr)
- stdout = stdout.trim()
- t.ok(/npm-test-fine/.test(stdout))
- t.end()
- })
-})
diff --git a/deps/npm/test/tap/search.all-package-search.js b/deps/npm/test/tap/search.all-package-search.js
deleted file mode 100644
index 9b3b989f9c..0000000000
--- a/deps/npm/test/tap/search.all-package-search.js
+++ /dev/null
@@ -1,207 +0,0 @@
-'use strict'
-
-const cacheFile = require('npm-cache-filename')
-const mkdirp = require('mkdirp')
-const mr = require('npm-registry-mock')
-const path = require('path')
-const qs = require('querystring')
-const Tacks = require('tacks')
-const test = require('tap').test
-
-const {File} = Tacks
-
-const common = require('../common-tap.js')
-
-const CACHE_DIR = common.cache
-const cacheBase = cacheFile(CACHE_DIR)(common.registry + '/-/all')
-const cachePath = path.join(cacheBase, '.cache.json')
-const chownr = require('chownr')
-const fixOwner = (
- process.getuid && process.getuid() === 0 &&
- process.env.SUDO_UID && process.env.SUDO_GID
-) ? (path) => chownr.sync(path, +process.env.SUDO_UID, +process.env.SUDO_GID)
- : () => {}
-
-let server
-
-test('setup', function (t) {
- mkdirp.sync(cacheBase)
- fixOwner(CACHE_DIR)
- mr({port: common.port, throwOnUnmatched: true}, function (err, s) {
- t.ifError(err, 'registry mocked successfully')
- server = s
- t.pass('all set up')
- t.done()
- })
-})
-
-const searches = [
- {
- term: 'cool',
- description: 'non-regex search',
- location: 103
- },
- {
- term: '/cool/',
- description: 'regex search',
- location: 103
- },
- {
- term: 'cool',
- description: 'searches name field',
- location: 103
- },
- {
- term: 'ool',
- description: 'excludes matches for --searchexclude',
- location: 205,
- inject: {
- other: { name: 'other', description: 'this is a simple tool' }
- },
- extraOpts: ['--searchexclude', 'cool']
- },
- {
- term: 'neat lib',
- description: 'searches description field',
- location: 141,
- inject: {
- cool: {
- name: 'cool', version: '5.0.0', description: 'this is a neat lib'
- }
- }
- },
- {
- term: 'foo',
- description: 'skips description field with --no-description',
- location: 80,
- inject: {
- cool: {
- name: 'cool', version: '5.0.0', description: 'foo bar!'
- }
- },
- extraOpts: ['--no-description']
- },
- {
- term: 'zkat',
- description: 'searches maintainers by name',
- location: 155,
- inject: {
- cool: {
- name: 'cool',
- version: '5.0.0',
- maintainers: [{
- name: 'zkat'
- }]
- }
- }
- },
- {
- term: '=zkat',
- description: 'searches maintainers unambiguously by =name',
- location: 154,
- inject: {
- bar: { name: 'bar', description: 'zkat thing', version: '1.0.0' },
- cool: {
- name: 'cool',
- version: '5.0.0',
- maintainers: [{
- name: 'zkat'
- }]
- }
- }
- },
- {
- term: 'github.com',
- description: 'searches projects by url',
- location: 205,
- inject: {
- bar: {
- name: 'bar',
- url: 'gitlab.com/bar',
- // For historical reasons, `url` is only present if `versions` is there
- versions: ['1.0.0'],
- version: '1.0.0'
- },
- cool: {
- name: 'cool',
- version: '5.0.0',
- versions: ['1.0.0'],
- url: 'github.com/cool/cool'
- }
- }
- },
- {
- term: 'monad',
- description: 'searches projects by keywords',
- location: 197,
- inject: {
- cool: {
- name: 'cool',
- version: '5.0.0',
- keywords: ['monads']
- }
- }
- }
-]
-
-// These test classic hand-matched searches
-searches.forEach(function (search) {
- test(search.description, function (t) {
- const query = qs.stringify({
- text: search.term,
- size: 20,
- from: 0,
- quality: 0.65,
- popularity: 0.98,
- maintenance: 0.5
- })
- server.get(`/-/v1/search?${query}`).once().reply(404, {})
- const now = Date.now()
- const cacheContents = {
- '_updated': now,
- bar: { name: 'bar', version: '1.0.0' },
- cool: { name: 'cool', version: '5.0.0' },
- foo: { name: 'foo', version: '2.0.0' },
- other: { name: 'other', version: '1.0.0' }
- }
- for (let k in search.inject) {
- cacheContents[k] = search.inject[k]
- }
- const fixture = new Tacks(File(cacheContents))
- fixture.create(cachePath)
- fixOwner(cachePath)
- common.npm([
- 'search', search.term,
- '--registry', common.registry,
- '--cache', CACHE_DIR,
- '--loglevel', 'error',
- '--color', 'always'
- ].concat(search.extraOpts || []),
- {},
- function (err, code, stdout, stderr) {
- t.equal(stderr, '', 'no error output')
- t.notEqual(stdout, '', 'got output')
- t.equal(code, 0, 'search finished successfully')
- t.ifErr(err, 'search finished successfully')
- // \033 == \u001B
- const markStart = '\u001B\\[[0-9][0-9]m'
- const markEnd = '\u001B\\[0m'
-
- const re = new RegExp(markStart + '.*?' + markEnd)
-
- const cnt = stdout.search(re)
- t.equal(
- cnt,
- search.location,
- search.description + ' search for ' + search.term
- )
- t.end()
- })
- })
-})
-
-test('cleanup', function (t) {
- server.done()
- server.close()
- t.end()
-})
diff --git a/deps/npm/test/tap/search.js b/deps/npm/test/tap/search.js
deleted file mode 100644
index 049706cc08..0000000000
--- a/deps/npm/test/tap/search.js
+++ /dev/null
@@ -1,254 +0,0 @@
-'use strict'
-
-const cacheFile = require('npm-cache-filename')
-const mkdirp = require('mkdirp')
-const mr = require('npm-registry-mock')
-const path = require('path')
-const qs = require('querystring')
-const test = require('tap').test
-
-const Tacks = require('tacks')
-const File = Tacks.File
-
-const common = require('../common-tap.js')
-
-// this test uses a fresh cache for each test block
-// create them all in common.cache so that we can verify
-// them for root-owned files in sudotest
-let CACHE_DIR
-let cacheBase
-let cachePath
-let cacheCounter = 1
-function setup () {
- CACHE_DIR = common.cache + '/' + cacheCounter++
- cacheBase = cacheFile(CACHE_DIR)(common.registry + '/-/all')
- cachePath = path.join(cacheBase, '.cache.json')
- mkdirp.sync(cacheBase)
- fixOwner(CACHE_DIR)
-}
-
-const chownr = require('chownr')
-const fixOwner = (
- process.getuid && process.getuid() === 0 &&
- process.env.SUDO_UID && process.env.SUDO_GID
-) ? (path) => chownr.sync(path, +process.env.SUDO_UID, +process.env.SUDO_GID)
- : () => {}
-
-let server
-
-test('setup', function (t) {
- mr({port: common.port, throwOnUnmatched: true}, function (err, s) {
- t.ifError(err, 'registry mocked successfully')
- server = s
- t.pass('all set up')
- t.done()
- })
-})
-
-test('notifies when there are no results', function (t) {
- setup()
- const query = qs.stringify({
- text: 'none',
- size: 20,
- from: 0,
- quality: 0.65,
- popularity: 0.98,
- maintenance: 0.5
- })
- server.get(`/-/v1/search?${query}`).once().reply(200, {
- objects: []
- })
- common.npm([
- 'search', 'none',
- '--registry', common.registry,
- '--loglevel', 'error',
- '--cache', CACHE_DIR
- ], {}, function (err, code, stdout, stderr) {
- if (err) throw err
- t.equal(stderr, '', 'no error output')
- t.equal(code, 0, 'search gives 0 error code even if no matches')
- t.match(stdout, /No matches found/, 'Useful message on search failure')
- t.done()
- })
-})
-
-test('spits out a useful error when no cache nor network', function (t) {
- setup()
- const query = qs.stringify({
- text: 'foo',
- size: 20,
- from: 0,
- quality: 0.65,
- popularity: 0.98,
- maintenance: 0.5
- })
- server.get(`/-/v1/search?${query}`).once().reply(404, {})
- server.get('/-/all').many().reply(404, {})
- const cacheContents = {}
- const fixture = new Tacks(File(cacheContents))
- fixture.create(cachePath)
- fixOwner(cachePath)
- common.npm([
- 'search', 'foo',
- '--registry', common.registry,
- '--loglevel', 'silly',
- '--json',
- '--fetch-retry-mintimeout', 0,
- '--fetch-retry-maxtimeout', 0,
- '--cache', CACHE_DIR
- ], {}, function (err, code, stdout, stderr) {
- if (err) throw err
- t.equal(code, 1, 'non-zero exit code')
- t.match(JSON.parse(stdout).error.summary, /No search sources available/)
- t.match(stderr, /No search sources available/, 'useful error')
- t.done()
- })
-})
-
-test('can switch to JSON mode', function (t) {
- setup()
- const query = qs.stringify({
- text: 'oo',
- size: 20,
- from: 0,
- quality: 0.65,
- popularity: 0.98,
- maintenance: 0.5
- })
- server.get(`/-/v1/search?${query}`).once().reply(200, {
- objects: [
- { package: { name: 'cool', version: '1.0.0' } },
- { package: { name: 'foo', version: '2.0.0' } }
- ]
- })
- common.npm([
- 'search', 'oo',
- '--json',
- '--registry', common.registry,
- '--loglevel', 'error',
- '--cache', CACHE_DIR
- ], {}, function (err, code, stdout, stderr) {
- if (err) throw err
- t.equal(stderr, '', 'no error output')
- t.equal(code, 0, 'search gives 0 error code even if no matches')
- t.similar(JSON.parse(stdout), [
- {
- name: 'cool',
- version: '1.0.0'
- },
- {
- name: 'foo',
- version: '2.0.0'
- }
- ], 'results returned as valid json')
- t.done()
- })
-})
-
-test('JSON mode does not notify on empty', function (t) {
- setup()
- const query = qs.stringify({
- text: 'oo',
- size: 20,
- from: 0,
- quality: 0.65,
- popularity: 0.98,
- maintenance: 0.5
- })
- server.get(`/-/v1/search?${query}`).once().reply(200, {
- objects: []
- })
- common.npm([
- 'search', 'oo',
- '--json',
- '--registry', common.registry,
- '--loglevel', 'error',
- '--cache', CACHE_DIR
- ], {}, function (err, code, stdout, stderr) {
- if (err) throw err
- t.deepEquals(JSON.parse(stdout), [], 'no notification about no results')
- t.equal(stderr, '', 'no error output')
- t.equal(code, 0, 'search gives 0 error code even if no matches')
- t.done()
- })
-})
-
-test('can switch to tab separated mode', function (t) {
- setup()
- const query = qs.stringify({
- text: 'oo',
- size: 20,
- from: 0,
- quality: 0.65,
- popularity: 0.98,
- maintenance: 0.5
- })
- server.get(`/-/v1/search?${query}`).once().reply(200, {
- objects: [
- { package: { name: 'cool', version: '1.0.0' } },
- { package: { name: 'foo', description: 'this\thas\ttabs', version: '2.0.0' } }
- ]
- })
- common.npm([
- 'search', 'oo',
- '--parseable',
- '--registry', common.registry,
- '--loglevel', 'error',
- '--cache', CACHE_DIR
- ], {}, function (err, code, stdout, stderr) {
- if (err) throw err
- t.equal(stdout, 'cool\t\t\tprehistoric\t1.0.0\t\nfoo\tthis has tabs\t\tprehistoric\t2.0.0\t\n', 'correct output, including replacing tabs in descriptions')
- t.equal(stderr, '', 'no error output')
- t.equal(code, 0, 'search gives 0 error code even if no matches')
- t.done()
- })
-})
-
-test('tab mode does not notify on empty', function (t) {
- setup()
- const query = qs.stringify({
- text: 'oo',
- size: 20,
- from: 0,
- quality: 0.65,
- popularity: 0.98,
- maintenance: 0.5
- })
- server.get(`/-/v1/search?${query}`).once().reply(200, {
- objects: []
- })
- common.npm([
- 'search', 'oo',
- '--parseable',
- '--registry', common.registry,
- '--loglevel', 'error',
- '--cache', CACHE_DIR
- ], {}, function (err, code, stdout, stderr) {
- if (err) throw err
- t.equal(stdout, '', 'no notification about no results')
- t.equal(stderr, '', 'no error output')
- t.equal(code, 0, 'search gives 0 error code even if no matches')
- t.done()
- })
-})
-
-test('no arguments provided should error', function (t) {
- setup()
- common.npm(['search', '--cache', CACHE_DIR], {}, function (err, code, stdout, stderr) {
- if (err) throw err
- t.equal(code, 1, 'search finished unsuccessfully')
-
- t.match(
- stderr,
- /search must be called with arguments/,
- 'should have correct error message'
- )
- t.end()
- })
-})
-
-test('cleanup', function (t) {
- server.done()
- server.close()
- t.end()
-})
diff --git a/deps/npm/test/tap/semver-doc.js b/deps/npm/test/tap/semver-doc.js
deleted file mode 100644
index fe2077660c..0000000000
--- a/deps/npm/test/tap/semver-doc.js
+++ /dev/null
@@ -1,14 +0,0 @@
-var test = require('tap').test
-
-test('semver doc is up to date', function (t) {
- var path = require('path')
- var moddoc = path.join(__dirname, '../../node_modules/semver/README.md')
- var mydoc = path.join(__dirname, '../../docs/content/using-npm/semver.md')
- var fs = require('fs')
- var mod = fs.readFileSync(moddoc, 'utf8')
- mod = mod.substr(mod.match(/^## Install$/m).index)
- var my = fs.readFileSync(mydoc, 'utf8')
- my = my.substr(my.match(/^## Install$/m).index)
- t.equal(my, mod)
- t.end()
-})
diff --git a/deps/npm/test/tap/shared-linked.js b/deps/npm/test/tap/shared-linked.js
deleted file mode 100644
index 517be4699d..0000000000
--- a/deps/npm/test/tap/shared-linked.js
+++ /dev/null
@@ -1,151 +0,0 @@
-'use strict'
-var path = require('path')
-var test = require('tap').test
-var Tacks = require('tacks')
-var File = Tacks.File
-var Symlink = Tacks.Symlink
-var Dir = Tacks.Dir
-var common = require('../common-tap.js')
-var mr = require('npm-registry-mock')
-
-var testdir = common.pkg
-var bugdir = path.join(testdir, 'modules', 'bug')
-
-// This is an absolutely minimal version of the optimist included with
-// npm-registry-mock.
-var optimist = Dir({
- 'package.json': File({
- dependencies: {
- minimist: '~0.0.1',
- wordwrap: '~0.0.2'
- },
- name: 'optimist',
- version: '0.6.0'
- }),
- node_modules: Dir({
- minimist: Dir({
- 'package.json': File({
- _shasum: 'd7aa327bcecf518f9106ac6b8f003fa3bcea8566',
- _resolve: 'foo',
- name: 'minimist',
- version: '0.0.5'
- })
- }),
- wordwrap: Dir({
- 'package.json': File({
- _shasum: 'b79669bb42ecb409f83d583cad52ca17eaa1643f',
- _resolve: 'foo',
- name: 'wordwrap',
- version: '0.0.2'
- })
- })
- })
-})
-
-var fixture = new Tacks(
- Dir({
- global: Dir({
- lib: Dir({
- node_modules: Dir({
- linked1: Symlink('../../../modules/linked1/'),
- linked2: Symlink('../../../modules/linked2/')
- })
- })
- }),
- modules: Dir({
- bug: Dir({
- node_modules: Dir({
- linked1: Symlink('../../../global/lib/node_modules/linked1'),
- linked2: Symlink('../../../global/lib/node_modules/linked2')
- }),
- 'package.json': File({
- name: 'bug',
- version: '10800.0.0',
- devDependencies: {
- optimist: '0.6.0',
- linked1: '^1.0.0',
- linked2: '^1.0.0'
- }
- })
- }),
- linked1: Dir({
- 'package.json': File({
- name: 'linked1',
- version: '1.0.0',
- devDependencies: {
- optimist: '0.6.0'
- }
- }),
- node_modules: Dir({
- optimist: optimist
- })
- }),
- linked2: Dir({
- 'package.json': File({
- name: 'linked2',
- version: '1.0.0',
- devDependencies: {
- optimist: '0.6.0',
- linked1: '^1.0.0'
- }
- }),
- node_modules: Dir({
- linked1: Symlink('../../../global/lib/node_modules/linked1'),
- optimist: optimist
- })
- })
- })
- })
-)
-
-function setup () {
- cleanup()
- fixture.create(testdir)
-}
-
-function cleanup () {
- fixture.remove(testdir)
-}
-
-var server
-test('setup', function (t) {
- setup()
- mr({port: common.port}, function (er, s) {
- t.ifError(er)
- server = s
- t.end()
- })
-})
-
-test('shared-linked', function (t) {
- var options = {
- cwd: bugdir,
- env: Object.assign({}, process.env, {
- npm_config_prefix: path.join(testdir, 'global')
- })
- }
- var config = [
- '--cache', common.cache,
- '--registry', common.registry,
- '--unicode', 'false'
- ]
-
- common.npm(config.concat(['install', '--dry-run', '--parseable']), options, function (err, code, stdout, stderr) {
- if (err) throw err
- t.is(code, 0)
- var got = stdout.trim().replace(/\s+\n/g, '\n').replace(/\\/g, '/')
- var expected =
- 'add\tminimist\t0.0.5\tnode_modules/minimist\n' +
- 'add\twordwrap\t0.0.2\tnode_modules/wordwrap\n' +
- 'add\toptimist\t0.6.0\tnode_modules/optimist'
- t.is(got, expected, 'just an optimist install please')
- server.done()
- t.end()
- })
-})
-
-test('cleanup', function (t) {
- if (server) server.close()
- cleanup()
- t.end()
-})
diff --git a/deps/npm/test/tap/shrinkwrap-_auth.js b/deps/npm/test/tap/shrinkwrap-_auth.js
deleted file mode 100644
index 2987e3eec0..0000000000
--- a/deps/npm/test/tap/shrinkwrap-_auth.js
+++ /dev/null
@@ -1,109 +0,0 @@
-'use strict'
-
-var fs = require('fs')
-var path = require('path')
-var writeFileSync = require('graceful-fs').writeFileSync
-
-var mkdirp = require('mkdirp')
-var http = require('http')
-var ssri = require('ssri')
-var t = require('tap')
-var test = t.test
-
-var common = require('../common-tap.js')
-
-var pkg = common.pkg
-var outfile = path.resolve(pkg, '_npmrc')
-
-var modules = path.resolve(pkg, 'node_modules')
-var tarballPath = '/scoped-underscore/-/scoped-underscore-1.3.1.tgz'
-var tarballURL = common.registry + tarballPath
-var tarball = path.resolve(__dirname, '../fixtures/scoped-underscore-1.3.1.tgz')
-var tarballIntegrity = ssri.fromData(fs.readFileSync(tarball)).toString()
-
-var _auth = '0xabad1dea'
-
-var contents = '_auth=' + _auth + '\n' +
- '\'always-auth\'=true\n'
-
-var json = {
- name: 'test-package-install',
- version: '1.0.0',
- dependencies: {
- '@scoped/underscore': '1.0.0'
- }
-}
-
-var shrinkwrap = {
- name: 'test-package-install',
- version: '1.0.0',
- lockfileVersion: 1,
- dependencies: {
- '@scoped/underscore': {
- resolved: tarballURL,
- integrity: tarballIntegrity,
- version: '1.3.1'
- }
- }
-}
-
-var server = http.createServer()
-t.teardown(() => server.close())
-
-const errors = []
-server.on('request', (req, res) => {
- const auth = 'Basic ' + _auth
- if (req.method === 'GET' && req.url === tarballPath) {
- if (req.headers.authorization === auth) {
- res.writeHead(200, 'ok')
- res.end(fs.readFileSync(tarball))
- } else {
- res.writeHead(403, 'unauthorized')
- errors.push("Got authorization of '" + req.headers.authorization + "' expected '" + auth + "'")
- res.end()
- }
- } else {
- res.writeHead(500)
- errors.push('Unknown request: ' + req.method + ' ' + req.url)
- res.end()
- }
-})
-
-test('setup', function (t) {
- mkdirp.sync(modules)
- writeFileSync(path.resolve(pkg, 'package.json'), JSON.stringify(json, null, 2) + '\n')
- writeFileSync(outfile, contents)
- writeFileSync(
- path.resolve(pkg, 'npm-shrinkwrap.json'),
- JSON.stringify(shrinkwrap, null, 2) + '\n'
- )
- server.listen(common.port, t.end)
-})
-
-test('authed npm install with shrinkwrapped global package using _auth', function (t) {
- common.npm(
- [
- 'install',
- '--loglevel', 'error',
- '--json',
- '--fetch-retries', 0,
- '--registry', common.registry,
- '--userconfig', outfile
- ],
- {cwd: pkg, stdio: [0, 'pipe', 2]},
- function (err, code, stdout) {
- if (err) throw err
- t.equal(code, 0, 'npm install exited OK')
- errors.forEach((err) => t.comment('Error: ' + err))
- try {
- var results = JSON.parse(stdout)
- t.match(results, {added: [{name: '@scoped/underscore', version: '1.3.1'}]}, '@scoped/underscore installed')
- } catch (ex) {
- console.error('#', ex)
- t.ifError(ex, 'stdout was valid JSON')
- }
-
- t.end()
- }
- )
-})
diff --git a/deps/npm/test/tap/shrinkwrap-default-dev.js b/deps/npm/test/tap/shrinkwrap-default-dev.js
deleted file mode 100644
index cd101092d4..0000000000
--- a/deps/npm/test/tap/shrinkwrap-default-dev.js
+++ /dev/null
@@ -1,93 +0,0 @@
-'use strict'
-var path = require('path')
-var test = require('tap').test
-var fs = require('fs')
-var Tacks = require('tacks')
-var File = Tacks.File
-var Dir = Tacks.Dir
-var common = require('../common-tap.js')
-
-var basedir = common.pkg
-var testdir = path.join(basedir, 'testdir')
-var cachedir = common.cache
-var globaldir = path.join(basedir, 'global')
-var tmpdir = path.join(basedir, 'tmp')
-
-var conf = {
- cwd: testdir,
- env: Object.assign({}, process.env, {
- npm_config_cache: cachedir,
- npm_config_tmp: tmpdir,
- npm_config_prefix: globaldir,
- npm_config_registry: common.registry,
- npm_config_loglevel: 'error'
- })
-}
-
-var fixture = new Tacks(Dir({
- cache: Dir(),
- global: Dir(),
- tmp: Dir(),
- testdir: Dir({
- node_modules: Dir({
- '@npmtest': Dir({
- example: Dir({
- 'package.json': File({
- name: '@npmtest/example',
- version: '1.0.0'
- })
- })
- })
- }),
- 'package.json': File({
- name: 'shrinkwrap-default-dev',
- version: '1.0.0',
- devDependencies: {
- '@npmtest/example': '1.0.0'
- }
- })
- })
-}))
-
-var shrinkwrapPath = path.join(testdir, 'npm-shrinkwrap.json')
-var shrinkwrapWithDev = {
- name: 'shrinkwrap-default-dev',
- version: '1.0.0',
- dependencies: {
- '@npmtest/example': {
- 'version': '1.0.0',
- 'dev': true
- }
- }
-}
-
-function setup () {
- cleanup()
- fixture.create(basedir)
-}
-
-function cleanup () {
- fixture.remove(basedir)
-}
-
-test('setup', function (t) {
- setup()
- t.done()
-})
-
-test('shrinkwrap-default-dev', function (t) {
- common.npm(['shrinkwrap'], conf, function (err, code, stdout, stderr) {
- if (err) throw err
- t.is(code, 0, 'command ran ok')
- t.comment(stdout.trim())
- t.comment(stderr.trim())
- var swrap = JSON.parse(fs.readFileSync(shrinkwrapPath))
- t.isDeeply(swrap.dependencies, shrinkwrapWithDev.dependencies, 'Shrinkwrap included dev deps by default')
- t.done()
- })
-})
-
-test('cleanup', function (t) {
- cleanup()
- t.done()
-})
diff --git a/deps/npm/test/tap/shrinkwrap-dev-dependency.js b/deps/npm/test/tap/shrinkwrap-dev-dependency.js
deleted file mode 100644
index 973cb5435b..0000000000
--- a/deps/npm/test/tap/shrinkwrap-dev-dependency.js
+++ /dev/null
@@ -1,70 +0,0 @@
-var fs = require('fs')
-var path = require('path')
-
-var mr = require('npm-registry-mock')
-var test = require('tap').test
-
-var common = require('../common-tap.js')
-
-var pkg = common.pkg
-
-var opts = [
- '--cache', common.cache,
- '--registry', common.registry
-]
-
-var desired = {
- name: 'npm-test-shrinkwrap-dev-dependency',
- version: '0.0.0',
- dependencies: {
- request: {
- version: '0.9.0',
- resolved: common.registry + '/request/-/request-0.9.0.tgz',
- integrity: 'sha1-EEn1mm9GWI5tAwkh+7hMovDCcU4='
- },
- underscore: {
- version: '1.3.1',
- resolved: common.registry + '/underscore/-/underscore-1.3.1.tgz',
- integrity: 'sha1-bLiq0Od+tdu/tUsivNhpcwnPlkE='
- }
- }
-}
-
-var json = {
- author: 'Domenic Denicola',
- name: 'npm-test-shrinkwrap-dev-dependency',
- version: '0.0.0',
- dependencies: {
- request: '0.9.0',
- underscore: '1.3.1'
- },
- devDependencies: {
- underscore: '1.5.1'
- }
-}
-
-test("shrinkwrap doesn't strip out the dependency", function (t) {
- t.plan(3)
-
- fs.writeFileSync(path.join(pkg, 'package.json'), JSON.stringify(json, null, 2))
- process.chdir(pkg)
-
- mr({port: common.port}, function (er, s) {
- common.npm(opts.concat(['install', '.']), {stdio: [0, 'pipe', 2]}, function (err, code) {
- if (err) throw err
- if (!t.is(code, 0)) return (s.close(), t.end())
- common.npm(opts.concat(['shrinkwrap']), {stdio: [0, 2, 2]}, function (err, code) {
- if (err) throw err
- t.is(code, 0)
- try {
- var results = JSON.parse(fs.readFileSync(path.join(pkg, 'npm-shrinkwrap.json')))
- } catch (ex) {
- t.comment(ex)
- }
- t.deepEqual(results.dependencies, desired.dependencies)
- s.close()
- t.end()
- })
- })
- })
-})
diff --git a/deps/npm/test/tap/shrinkwrap-empty-dep-value.js b/deps/npm/test/tap/shrinkwrap-empty-dep-value.js
deleted file mode 100644
index 3a264f5a10..0000000000
--- a/deps/npm/test/tap/shrinkwrap-empty-dep-value.js
+++ /dev/null
@@ -1,66 +0,0 @@
-'use strict'
-
-const common = require('../common-tap.js')
-const path = require('path')
-const test = require('tap').test
-
-const Tacks = require('tacks')
-const File = Tacks.File
-const Dir = Tacks.Dir
-
-const basedir = common.pkg
-const testdir = path.join(basedir, 'testdir')
-
-const fixture = new Tacks(Dir({
- cache: Dir(),
- global: Dir(),
- tmp: Dir(),
- testdir: Dir({
- 'npm-shrinkwrap.json': File({
- name: 'http-locks',
- version: '0.0.0',
- dependencies: {
- minimist: {}
- }
- }),
- 'package.json': File({
- name: 'http-locks',
- version: '1.0.0',
- dependencies: {
- minimist: common.registry + '/minimist/-/minimist-0.0.5.tgz'
- }
- })
- })
-}))
-
-function setup () {
- cleanup()
- fixture.create(basedir)
-}
-
-function cleanup () {
- fixture.remove(basedir)
-}
-
-test('setup', function (t) {
- setup()
- t.done()
-})
-
-test('raises error to regenerate the shrinkwrap', function (t) {
- common.npm(['install'], {cwd: testdir}, function (err, code, stdout, stderr) {
- if (err) throw err
- t.match(
- stderr,
- 'npm ERR! If using a shrinkwrap, regenerate with "npm shrinkwrap".',
- 'returns message to regenerate shrinkwrap'
- )
-
- t.done()
- })
-})
-
-test('cleanup', function (t) {
- cleanup()
- t.done()
-})
diff --git a/deps/npm/test/tap/shrinkwrap-empty-deps.js b/deps/npm/test/tap/shrinkwrap-empty-deps.js
deleted file mode 100644
index 3c68845745..0000000000
--- a/deps/npm/test/tap/shrinkwrap-empty-deps.js
+++ /dev/null
@@ -1,58 +0,0 @@
-'use strict'
-
-const common = require('../common-tap.js')
-const fs = require('fs')
-const mr = require('npm-registry-mock')
-const path = require('path')
-const test = require('tap').test
-
-const pkg = common.pkg
-
-const EXEC_OPTS = { cwd: pkg }
-
-const json = {
- author: 'Rockbert',
- name: 'shrinkwrap-empty-deps',
- version: '0.0.0',
- dependencies: {},
- devDependencies: {}
-}
-
-test('setup', function (t) {
- fs.writeFileSync(
- path.join(pkg, 'package.json'),
- JSON.stringify(json, null, 2)
- )
-
- process.chdir(pkg)
- t.end()
-})
-
-test('returns a list of removed items', function (t) {
- mr({ port: common.port }, function (er, s) {
- common.npm(
- [
- '--registry', common.registry,
- '--loglevel', 'silent',
- 'shrinkwrap'
- ],
- EXEC_OPTS,
- function (err, code, stdout, stderr) {
- t.ifError(err, 'shrinkwrap ran without issue')
- t.notOk(code, 'shrinkwrap ran without raising error code')
-
- fs.readFile(path.resolve(pkg, 'npm-shrinkwrap.json'), function (err, found) {
- t.ifError(err, 'read npm-shrinkwrap.json without issue')
- t.same(
- JSON.parse(found).dependencies,
- undefined,
- 'shrinkwrap handled empty deps without exploding'
- )
-
- s.close()
- t.end()
- })
- }
- )
- })
-})
diff --git a/deps/npm/test/tap/shrinkwrap-extra-metadata.js b/deps/npm/test/tap/shrinkwrap-extra-metadata.js
deleted file mode 100644
index 6e652e2db0..0000000000
--- a/deps/npm/test/tap/shrinkwrap-extra-metadata.js
+++ /dev/null
@@ -1,60 +0,0 @@
-'use strict'
-
-const common = require('../common-tap.js')
-const fs = require('fs')
-const mr = require('npm-registry-mock')
-const npm = require('../../lib/npm.js')
-const path = require('path')
-const test = require('tap').test
-
-const pkg = common.pkg
-
-const json = {
- author: 'Rockbert',
- name: 'shrinkwrap-extra-metadata',
- version: '0.0.0'
-}
-
-test('setup', function (t) {
- fs.writeFileSync(
- path.join(pkg, 'package.json'),
- JSON.stringify(json, null, 2)
- )
-
- process.chdir(pkg)
- t.end()
-})
-
-test('adds additional metadata fields from the pkglock spec', function (t) {
- mr({ port: common.port }, function (er, s) {
- t.teardown(() => s.close())
- common.npm(
- [
- '--registry', common.registry,
- '--loglevel', 'silent',
- 'shrinkwrap'
- ],
- { cwd: pkg, env: { NODE_PRESERVE_SYMLINKS: 'foo' } },
- function (err, code, stdout, stderr) {
- t.ifError(err, 'shrinkwrap ran without issue')
- t.notOk(code, 'shrinkwrap ran without raising error code')
-
- fs.readFile(path.resolve(pkg, 'npm-shrinkwrap.json'), function (err, desired) {
- t.ifError(err, 'read npm-shrinkwrap.json without issue')
- t.same(
- {
- 'name': 'shrinkwrap-extra-metadata',
- 'version': '0.0.0',
- 'lockfileVersion': npm.lockfileVersion,
- 'preserveSymlinks': 'foo'
- },
- JSON.parse(desired),
- 'shrinkwrap wrote the expected metadata fields'
- )
-
- t.end()
- })
- }
- )
- })
-})
diff --git a/deps/npm/test/tap/shrinkwrap-global-auth.js b/deps/npm/test/tap/shrinkwrap-global-auth.js
deleted file mode 100644
index e14a328a43..0000000000
--- a/deps/npm/test/tap/shrinkwrap-global-auth.js
+++ /dev/null
@@ -1,97 +0,0 @@
-'use strict'
-
-var fs = require('fs')
-var path = require('path')
-var writeFileSync = require('graceful-fs').writeFileSync
-
-var mkdirp = require('mkdirp')
-var mr = require('npm-registry-mock')
-var ssri = require('ssri')
-var test = require('tap').test
-
-var common = require('../common-tap.js')
-
-var pkg = common.pkg
-var outfile = path.resolve(pkg, '_npmrc')
-
-var modules = path.resolve(pkg, 'node_modules')
-var tarballPath = '/scoped-underscore/-/scoped-underscore-1.3.1.tgz'
-var tarballURL = common.registry + tarballPath
-var tarball = path.resolve(__dirname, '../fixtures/scoped-underscore-1.3.1.tgz')
-var tarballIntegrity = ssri.fromData(fs.readFileSync(tarball)).toString()
-
-var contents = 'registry=' + common.registry + '\n' +
- '_authToken=0xabad1dea\n' +
- '\'always-auth\'=true\n'
-
-var json = {
- name: 'test-package-install',
- version: '1.0.0',
- dependencies: {
- '@scoped/underscore': '1.0.0'
- }
-}
-
-var shrinkwrap = {
- name: 'test-package-install',
- version: '1.0.0',
- lockfileVersion: 1,
- dependencies: {
- '@scoped/underscore': {
- resolved: tarballURL,
- integrity: tarballIntegrity,
- version: '1.3.1'
- }
- }
-}
-
-function mocks (server) {
- var auth = 'Bearer 0xabad1dea'
- server.get(tarballPath, { authorization: auth }).replyWithFile(200, tarball)
- server.get(tarballPath).reply(401, {
- error: 'unauthorized',
- reason: 'You are not authorized to access this db.'
- })
-}
-
-test('setup', function (t) {
- mkdirp.sync(modules)
- writeFileSync(path.resolve(pkg, 'package.json'), JSON.stringify(json, null, 2) + '\n')
- writeFileSync(outfile, contents)
- writeFileSync(
- path.resolve(pkg, 'npm-shrinkwrap.json'),
- JSON.stringify(shrinkwrap, null, 2) + '\n'
- )
- mr({ port: common.port, plugin: mocks }, function (er, s) {
- t.parent.teardown(() => s.close())
- t.ok(s, 'set up mock registry')
- t.end()
- })
-})
-
-test('authed npm install with shrinkwrapped global package', function (t) {
- common.npm(
- [
- 'install',
- '--loglevel', 'error',
- '--json',
- '--fetch-retries', 0,
- '--userconfig', outfile,
- '--registry', common.registry
- ],
- {cwd: pkg, stdio: [0, 'pipe', 2]},
- function (err, code, stdout) {
- if (err) throw err
- t.equal(code, 0, 'npm install exited OK')
- try {
- var results = JSON.parse(stdout)
- t.match(results, {added: [{name: '@scoped/underscore', version: '1.3.1'}]}, '@scoped/underscore installed')
- } catch (ex) {
- console.error('#', ex)
- t.ifError(ex, 'stdout was valid JSON')
- }
-
- t.end()
- }
- )
-})
diff --git a/deps/npm/test/tap/shrinkwrap-lifecycle-cwd.js b/deps/npm/test/tap/shrinkwrap-lifecycle-cwd.js
deleted file mode 100644
index 78f40f5297..0000000000
--- a/deps/npm/test/tap/shrinkwrap-lifecycle-cwd.js
+++ /dev/null
@@ -1,87 +0,0 @@
-'use strict'
-var path = require('path')
-var test = require('tap').test
-var mr = require('npm-registry-mock')
-var Tacks = require('tacks')
-var File = Tacks.File
-var Dir = Tacks.Dir
-var common = require('../common-tap.js')
-
-var basedir = common.pkg
-var testdir = path.join(basedir, 'testdir')
-var cachedir = common.cache
-var globaldir = path.join(basedir, 'global')
-var tmpdir = path.join(basedir, 'tmp')
-
-var conf = {
- cwd: testdir,
- env: Object.assign({
- npm_config_cache: cachedir,
- npm_config_tmp: tmpdir,
- npm_config_prefix: globaldir,
- npm_config_registry: common.registry,
- npm_config_loglevel: 'warn'
- }, process.env)
-}
-
-var server
-var fixture = new Tacks(Dir({
- cache: Dir(),
- global: Dir(),
- tmp: Dir(),
- testdir: Dir({
- node_modules: Dir({}),
- 'package.json': File({
- name: '13252',
- version: '1.0.0',
- scripts: {
- // add this to the end of the command to preserve the debug log:
- // || mv npm-debug.log real-debug.log
- // removed for windows compat reasons
- abc: 'node ' + JSON.stringify(common.bin) + ' shrinkwrap',
- shrinkwrap: 'node scripts/shrinkwrap.js'
- }
- }),
- scripts: Dir({
- 'shrinkwrap.js': File(
- 'console.log("OK " + process.cwd())'
- )
- })
- })
-}))
-
-function setup () {
- cleanup()
- fixture.create(basedir)
-}
-
-function cleanup () {
- fixture.remove(basedir)
-}
-
-test('setup', function (t) {
- setup()
- mr({port: common.port, throwOnUnmatched: true}, function (err, s) {
- if (err) throw err
- server = s
- t.done()
- })
-})
-
-test('shrinkwrap-lifecycle-cwd', function (t) {
- common.npm(['run', 'abc'], conf, function (err, code, stdout, stderr) {
- if (err) throw err
- t.is(code, 0, 'command ran ok')
- t.comment(stdout.trim())
- t.comment(stderr.trim())
- t.match(stdout.trim(), 'OK ' + testdir, 'got output from lifecycle script')
- t.is(stderr.trim().length, 0, 'no errors')
- t.done()
- })
-})
-
-test('cleanup', function (t) {
- server.close()
- cleanup()
- t.done()
-})
diff --git a/deps/npm/test/tap/shrinkwrap-lifecycle.js b/deps/npm/test/tap/shrinkwrap-lifecycle.js
deleted file mode 100644
index 6e6bc4c287..0000000000
--- a/deps/npm/test/tap/shrinkwrap-lifecycle.js
+++ /dev/null
@@ -1,37 +0,0 @@
-var fs = require('graceful-fs')
-var path = require('path')
-var test = require('tap').test
-var common = require('../common-tap.js')
-var pkg = common.pkg
-
-test('npm shrinkwrap execution order', function (t) {
- fs.writeFileSync(path.resolve(pkg, 'package.json'), JSON.stringify({
- author: 'Simen Bekkhus',
- name: 'shrinkwrap-lifecycle',
- shrinkwrap: '0.0.0',
- description: 'Test for npm shrinkwrap execution order',
- scripts: {
- preshrinkwrap: 'echo this happens first',
- shrinkwrap: 'echo this happens second',
- postshrinkwrap: 'echo this happens third'
- }
- }), 'utf8')
- common.npm(['shrinkwrap', '--loglevel=error'], { cwd: pkg }, function (err, code, stdout, stderr) {
- if (err) throw err
-
- t.comment(stdout)
- t.comment(stderr)
- var indexOfFirst = stdout.indexOf('echo this happens first')
- var indexOfSecond = stdout.indexOf('echo this happens second')
- var indexOfThird = stdout.indexOf('echo this happens third')
-
- t.ok(indexOfFirst >= 0)
- t.ok(indexOfSecond >= 0)
- t.ok(indexOfThird >= 0)
-
- t.ok(indexOfFirst < indexOfSecond)
- t.ok(indexOfSecond < indexOfThird)
-
- t.end()
- })
-})
diff --git a/deps/npm/test/tap/shrinkwrap-local-dependency.js b/deps/npm/test/tap/shrinkwrap-local-dependency.js
deleted file mode 100644
index 5e6d278d30..0000000000
--- a/deps/npm/test/tap/shrinkwrap-local-dependency.js
+++ /dev/null
@@ -1,124 +0,0 @@
-var test = require('tap').test
-var path = require('path')
-var fs = require('fs')
-var rimraf = require('rimraf')
-var common = require('../common-tap.js')
-var Tacks = require('tacks')
-var unixFormatPath = require('../../lib/utils/unix-format-path.js')
-var File = Tacks.File
-var Dir = Tacks.Dir
-
-var testdir = common.pkg
-var cachedir = common.cache
-var config = ['--cache=' + cachedir, '--loglevel=error']
-
-var shrinkwrap = {
- name: 'shrinkwrap-local-dependency',
- version: '1.0.0',
- dependencies: {
- mod2: {
- version: 'file:' + unixFormatPath(path.join('mods', 'mod2')),
- dependencies: {
- mod1: {
- version: 'file:' + unixFormatPath(path.join('mods', 'mod1'))
- }
- }
- }
- }
-}
-
-var fixture = new Tacks(
- Dir({
- cache: Dir(),
- mods: Dir({
- mod1: Dir({
- 'package.json': File({
- name: 'mod1',
- version: '1.0.0'
- })
- }),
- mod2: Dir({
- 'package.json': File({
- name: 'mod2',
- version: '1.0.0',
- dependencies: {
- mod1: 'file:' + path.join('..', 'mod1')
- }
- })
- })
- }),
- 'package.json': File({
- name: 'shrinkwrap-local-dependency',
- version: '1.0.0',
- dependencies: {
- mod2: 'file:' + path.join('mods', 'mod2')
- }
- })
- })
-)
-
-function setup () {
- cleanup()
- fixture.create(testdir)
-}
-
-function cleanNodeModules () {
- rimraf.sync(path.resolve(testdir, 'node_modules'))
-}
-
-function cleanup () {
- fixture.remove(testdir)
-}
-
-test('shrinkwrap uses resolved with file: on local deps', function (t) {
- setup()
-
- common.npm(config.concat(['install', '--legacy']), {cwd: testdir}, function (err, code, stdout, stderr) {
- if (err) throw err
- t.comment(stdout.trim())
- t.comment(stderr.trim())
- t.equal(code, 0, 'npm exited normally')
-
- common.npm(config.concat('shrinkwrap'), {cwd: testdir}, function (err, code, stdout, stderr) {
- if (err) throw err
- t.comment(stdout.trim())
- t.comment(stderr.trim())
- t.equal(code, 0, 'npm exited normally')
- var data = fs.readFileSync(path.join(testdir, 'npm-shrinkwrap.json'), { encoding: 'utf8' })
- t.like(
- JSON.parse(data).dependencies,
- shrinkwrap.dependencies,
- 'shrinkwrap looks correct'
- )
- t.end()
- })
- })
-})
-
-function exists (file) {
- try {
- fs.statSync(file)
- return true
- } catch (ex) {
- return false
- }
-}
-
-test("'npm install' should install local packages from shrinkwrap", function (t) {
- cleanNodeModules()
-
- common.npm(config.concat(['install']), {cwd: testdir}, function (err, code, stdout, stderr) {
- if (err) throw err
- t.comment(stdout.trim())
- t.comment(stderr.trim())
- t.equal(code, 0, 'npm exited normally')
- t.ok(exists(path.join(testdir, 'node_modules', 'mod2')), 'mod2 exists')
- t.ok(exists(path.join(testdir, 'node_modules', 'mod2', 'node_modules', 'mod1')), 'mod1 exists')
- t.end()
- })
-})
-
-test('cleanup', function (t) {
- cleanup()
- t.end()
-})
diff --git a/deps/npm/test/tap/shrinkwrap-nested.js b/deps/npm/test/tap/shrinkwrap-nested.js
deleted file mode 100644
index bace44d01a..0000000000
--- a/deps/npm/test/tap/shrinkwrap-nested.js
+++ /dev/null
@@ -1,165 +0,0 @@
-'use strict'
-var test = require('tap').test
-var Bluebird = require('bluebird')
-var Tacks = require('tacks')
-var File = Tacks.File
-var Dir = Tacks.Dir
-var fs = require('fs')
-var path = require('path')
-var common = require('../common-tap.js')
-
-var testdir = common.pkg
-var modAtgz = path.resolve(testdir, 'modA') + '-1.0.0.tgz'
-var modB1tgz = path.resolve(testdir, 'modB') + '-1.0.0.tgz'
-var modB2tgz = path.resolve(testdir, 'modB') + '-2.0.0.tgz'
-var modCtgz = path.resolve(testdir, 'modC') + '-1.0.0.tgz'
-
-var fixture = new Tacks(Dir({
- 'package.json': File({
- dependencies: {
- modA: 'file://' + modAtgz,
- modC: 'file://' + modCtgz
- }
- }),
- 'npm-shrinkwrap.json': File({
- dependencies: {
- modA: {
- version: '1.0.0',
- resolved: 'file://' + modAtgz
- },
- modB: {
- version: '1.0.0',
- resolved: 'file://' + modB1tgz
- }
- }
- }),
- 'modA': Dir({
- 'package.json': File({
- name: 'modA',
- version: '1.0.0',
- dependencies: {
- 'modB': 'file://' + modB1tgz
- }
- })
- }),
- 'modB@1': Dir({
- 'package.json': File({
- name: 'modB',
- version: '1.0.0'
- }),
- 'B1': File('')
- }),
- 'modB@2': Dir({
- 'package.json': File({
- name: 'modB',
- version: '2.0.0'
- }),
- 'B2': File('')
- }),
- 'modC': Dir({
- 'package.json': File({
- name: 'modC',
- version: '1.0.0',
- dependencies: {
- 'modB': 'file://' + modB2tgz
- }
- })
- })
-}))
-
-var newShrinkwrap = new Tacks(Dir({
- 'npm-shrinkwrap.json': File({
- dependencies: {
- modA: {
- version: '1.0.0',
- resolved: 'file://' + modAtgz
- },
- modB: {
- version: '1.0.0',
- resolved: 'file://' + modB1tgz
- },
- modC: {
- version: '1.0.0',
- resolved: 'file://' + modCtgz,
- dependencies: {
- modB: {
- version: '1.0.0',
- resolved: 'file://' + modB1tgz
- }
- }
- }
- }
- }),
- 'node_modules': Dir({
- 'modB@1': Dir({
- 'package.json': File({
- _requested: {
- name: 'modB',
- raw: 'modB@file:' + modB1tgz,
- rawSpec: 'file:' + modB1tgz,
- scope: null,
- spec: modB1tgz,
- type: 'directory'
- },
- dependencies: { },
- devDependencies: { },
- name: 'modB',
- optionalDependencies: { },
- readme: 'ERROR: No README data found!',
- version: '1.0.0'
- })
- })
- })
-}))
-
-function setup () {
- fixture.create(testdir)
-}
-
-function cleanup () {
- fixture.remove(testdir)
-}
-
-test('setup', function (t) {
- cleanup()
- setup()
- return Bluebird.try(() => {
- return Bluebird.join(
- common.npm(['pack', 'file:modB@1'], {cwd: testdir, stdio: [0, 2, 2]}),
- common.npm(['pack', 'file:modB@2'], {cwd: testdir, stdio: [0, 2, 2]}),
- function (b1, b2) {
- t.is(b1[0], 0, 'pack modB@1')
- t.is(b2[0], 0, 'pack modB@2')
- })
- }).then(() => {
- return Bluebird.join(
- common.npm(['pack', 'file:modA'], {cwd: testdir, stdio: [0, 2, 2]}),
- common.npm(['pack', 'file:modC'], {cwd: testdir, stdio: [0, 2, 2]}),
- function (a, c) {
- t.is(a[0], 0, 'pack modA')
- t.is(c[0], 0, 'pack modC')
- })
- }).then(() => {
- return common.npm(['install'], {cwd: testdir, stdio: [0, 2, 2]})
- }).spread((code) => {
- t.is(code, 0, 'top level install')
- t.end()
- })
-})
-
-test('incremental install', function (t) {
- newShrinkwrap.create(testdir)
- common.npm(['install'], {cwd: testdir, stdio: [0, 2, 2]}, function (err, code) {
- if (err) throw err
- t.is(code, 0, 'npm itself completed ok')
- fs.stat(path.join(testdir, 'node_modules', 'modC', 'node_modules', 'modB', 'B1'), function (missing) {
- t.ok(!missing, 'modC got the updated version of modB')
- t.end()
- })
- })
-})
-
-test('cleanup', function (t) {
- cleanup()
- t.end()
-})
diff --git a/deps/npm/test/tap/shrinkwrap-optional-dependency.js b/deps/npm/test/tap/shrinkwrap-optional-dependency.js
deleted file mode 100644
index a08d153849..0000000000
--- a/deps/npm/test/tap/shrinkwrap-optional-dependency.js
+++ /dev/null
@@ -1,91 +0,0 @@
-var fs = require('fs')
-var path = require('path')
-
-var mkdirp = require('mkdirp')
-var mr = require('npm-registry-mock')
-var test = require('tap').test
-
-var common = require('../common-tap.js')
-var npm = require('../../')
-
-var pkg = common.pkg
-
-test('shrinkwrap does not fail on missing optional dependency', function (t) {
- t.plan(1)
-
- var mocks = {
- get: {
- '/random-package': [404, {}]
- }
- }
-
- mr({port: common.port, mocks: mocks}, function (er, s) {
- t.parent.teardown(() => s.close())
- setup(function (err) {
- if (err) {
- throw err
- }
-
- // Install without the optional dependency
- npm.install('.', function (err) {
- if (err) {
- throw err
- }
-
- // Pretend the optional dependency was specified, but somehow failed to load:
- json.optionalDependencies = {
- 'random-package': '0.0.0'
- }
- writePackage()
-
- npm.commands.shrinkwrap([], true, function (err, results) {
- if (err) {
- throw err
- }
-
- t.deepEqual(results.dependencies, desired.dependencies)
- s.close()
- t.end()
- })
- })
- })
- })
-})
-
-var desired = {
- name: 'npm-test-shrinkwrap-optional-dependency',
- version: '0.0.0',
- dependencies: {
- 'test-package': {
- version: '0.0.0',
- resolved: common.registry + '/test-package/-/test-package-0.0.0.tgz',
- integrity: 'sha1-sNMrbEXCWcV4uiADdisgUTG9+9E='
- }
- }
-}
-
-var json = {
- author: 'Maximilian Antoni',
- name: 'npm-test-shrinkwrap-optional-dependency',
- version: '0.0.0',
- dependencies: {
- 'test-package': '0.0.0'
- }
-}
-
-function writePackage () {
- fs.writeFileSync(path.join(pkg, 'package.json'), JSON.stringify(json, null, 2))
-}
-
-function setup (cb) {
- mkdirp.sync(pkg)
- writePackage()
- process.chdir(pkg)
-
- var opts = {
- cache: common.cache,
- registry: common.registry,
- cwd: pkg
- }
- npm.load(opts, cb)
-}
diff --git a/deps/npm/test/tap/shrinkwrap-optional-platform.js b/deps/npm/test/tap/shrinkwrap-optional-platform.js
deleted file mode 100644
index f5b87d2f8d..0000000000
--- a/deps/npm/test/tap/shrinkwrap-optional-platform.js
+++ /dev/null
@@ -1,107 +0,0 @@
-'use strict'
-var path = require('path')
-var test = require('tap').test
-var Tacks = require('tacks')
-var File = Tacks.File
-var Dir = Tacks.Dir
-var common = require('../common-tap.js')
-
-var basedir = common.pkg
-var testdir = path.join(basedir, 'testdir')
-var cachedir = common.cache
-var globaldir = path.join(basedir, 'global')
-var tmpdir = path.join(basedir, 'tmp')
-
-var conf = {
- cwd: testdir,
- env: Object.assign({}, process.env, {
- npm_config_cache: cachedir,
- npm_config_tmp: tmpdir,
- npm_config_prefix: globaldir,
- npm_config_registry: common.registry,
- npm_config_loglevel: 'warn'
- })
-}
-
-var fixture = new Tacks(Dir({
- cache: Dir(),
- global: Dir(),
- tmp: Dir(),
- testdir: Dir({
- mod1: Dir({
- 'package.json': File({
- name: 'mod1',
- version: '1.0.0',
- scripts: {},
- 'optionalDependencies': {
- 'mod2': 'file:../mod2'
- },
- os: ['nosuchos']
- })
- }),
- mod2: Dir({
- 'package.json': File({
- name: 'mod2',
- version: '1.0.0',
- scripts: {},
- os: ['nosuchos']
- })
- }),
- 'npm-shrinkwrap.json': File({
- name: 'shrinkwrap-optional-platform',
- version: '1.0.0',
- dependencies: {
- mod1: {
- version: '1.0.0',
- resolved: 'file:mod1',
- optional: true
- },
- mod2: {
- version: '1.0.0',
- resolved: 'file:mod2',
- optional: true
- }
- }
- }),
- 'package.json': File({
- name: 'shrinkwrap-optional-platform',
- version: '1.0.0',
- optionalDependencies: {
- mod1: 'file:mod1'
- },
- description: 'x',
- repository: 'x',
- license: 'Artistic-2.0'
- })
- })
-}))
-
-function setup () {
- cleanup()
- fixture.create(basedir)
-}
-
-function cleanup () {
- fixture.remove(basedir)
-}
-
-test('setup', function (t) {
- setup()
- t.done()
-})
-
-test('example', function (t) {
- common.npm(['install'], conf, function (err, code, stdout, stderr) {
- if (err) throw err
- t.is(code, 0, 'install ran ok')
- t.comment(stdout.trim())
- t.comment(stderr.trim())
- t.notMatch(stderr, /Exit status 1/, 'did not try to install opt dep')
- t.done()
- })
-})
-
-test('cleanup', function (t) {
- cleanup()
- t.done()
-})
diff --git a/deps/npm/test/tap/shrinkwrap-optional-property.js b/deps/npm/test/tap/shrinkwrap-optional-property.js
deleted file mode 100644
index c2dc8585ae..0000000000
--- a/deps/npm/test/tap/shrinkwrap-optional-property.js
+++ /dev/null
@@ -1,87 +0,0 @@
-var fs = require('fs')
-var path = require('path')
-
-var mr = require('npm-registry-mock')
-var test = require('tap').test
-
-var common = require('../common-tap.js')
-var npm = require('../../')
-
-var pkg = common.pkg
-
-test('shrinkwrap adds optional property when optional dependency', function (t) {
- t.plan(1)
-
- mr({port: common.port}, function (er, s) {
- t.parent.teardown(() => s.close())
- setup(function (err) {
- if (err) {
- throw err
- }
-
- // Install with the optional dependency
- npm.install('.', function (err) {
- if (err) {
- throw err
- }
-
- writePackage()
-
- npm.commands.shrinkwrap([], true, function (err, results) {
- if (err) {
- throw err
- }
-
- t.deepEqual(results.dependencies, desired.dependencies)
- s.close()
- t.end()
- })
- })
- })
- })
-})
-
-var desired = {
- name: 'npm-test-shrinkwrap-optional-dependency',
- version: '0.0.0',
- dependencies: {
- 'test-package': {
- version: '0.0.0',
- resolved: common.registry + '/test-package/-/test-package-0.0.0.tgz',
- integrity: 'sha1-sNMrbEXCWcV4uiADdisgUTG9+9E='
- },
- 'underscore': {
- version: '1.3.3',
- resolved: 'http://localhost:' + common.port + '/underscore/-/underscore-1.3.3.tgz',
- optional: true,
- integrity: 'sha1-R6xTaD2vgyv6lS4XdEF9pHgXrkI='
- }
- }
-}
-
-var json = {
- author: 'Maximilian Antoni',
- name: 'npm-test-shrinkwrap-optional-dependency',
- version: '0.0.0',
- dependencies: {
- 'test-package': '0.0.0'
- },
- optionalDependencies: {
- 'underscore': '1.3.3'
- }
-}
-
-function writePackage () {
- fs.writeFileSync(path.join(pkg, 'package.json'), JSON.stringify(json, null, 2))
-}
-
-function setup (cb) {
- writePackage()
- process.chdir(pkg)
-
- var opts = {
- cache: common.cache,
- registry: common.registry
- }
- npm.load(opts, cb)
-}
diff --git a/deps/npm/test/tap/shrinkwrap-prod-dependency-also.js b/deps/npm/test/tap/shrinkwrap-prod-dependency-also.js
deleted file mode 100644
index 1e4e9d7438..0000000000
--- a/deps/npm/test/tap/shrinkwrap-prod-dependency-also.js
+++ /dev/null
@@ -1,85 +0,0 @@
-var fs = require('fs')
-var path = require('path')
-
-var mr = require('npm-registry-mock')
-var test = require('tap').test
-
-var common = require('../common-tap.js')
-var pkg = common.pkg
-var opts = [
- '--cache=' + common.cache,
- '--registry=' + common.registry
-]
-
-function reportOutput (t, fh, out) {
- var trimmed = out.trim()
- if (!trimmed.length) return
- var prefix = fh + '> '
- t.comment(prefix + trimmed.split(/\n/).join('\n' + prefix))
-}
-
-var desired = {
- name: 'npm-test-shrinkwrap-prod-dependency',
- version: '0.0.0',
- dependencies: {
- request: {
- version: '0.9.0',
- resolved: common.registry + '/request/-/request-0.9.0.tgz',
- integrity: 'sha1-EEn1mm9GWI5tAwkh+7hMovDCcU4='
- },
- underscore: {
- dev: true,
- version: '1.5.1',
- resolved: common.registry + '/underscore/-/underscore-1.5.1.tgz',
- integrity: 'sha1-0r3oF9F2/63olKtxRY5oKhS4bck='
- }
- }
-}
-
-var json = {
- author: 'Domenic Denicola',
- name: 'npm-test-shrinkwrap-prod-dependency',
- version: '0.0.0',
- dependencies: {
- request: '0.9.0'
- },
- devDependencies: {
- underscore: '1.5.1'
- }
-}
-
-test("shrinkwrap --also=development doesn't strip out prod dependencies", function (t) {
- t.plan(4)
-
- mr({port: common.port}, function (er, s) {
- t.parent.teardown(() => s.close())
- fs.writeFileSync(path.join(pkg, 'package.json'), JSON.stringify(json, null, 2))
- common.npm(['install', '.'].concat(opts), {cwd: pkg}, function (err, code, stdout, stderr) {
- if (err) return t.fail(err)
- t.is(code, 0, 'install')
- reportOutput(t, 'out', stdout)
- reportOutput(t, 'err', stderr)
- common.npm(['shrinkwrap', '--also=development'].concat(opts), {cwd: pkg}, function (err, code, stdout, stderr) {
- if (err) return t.fail(err)
- var ok = t.is(code, 0, 'shrinkwrap')
- reportOutput(t, 'out', stdout)
- reportOutput(t, 'err', stderr)
- if (ok) {
- try {
- var results = JSON.parse(fs.readFileSync(path.join(pkg, 'npm-shrinkwrap.json')))
- t.pass('read shrinkwrap')
- } catch (ex) {
- t.ifError(ex, 'read shrinkwrap')
- }
- }
- t.deepEqual(
- results.dependencies,
- desired.dependencies,
- 'results have dev dep'
- )
- s.done()
- t.end()
- })
- })
- })
-})
diff --git a/deps/npm/test/tap/shrinkwrap-prod-dependency.js b/deps/npm/test/tap/shrinkwrap-prod-dependency.js
deleted file mode 100644
index bf6d98bf80..0000000000
--- a/deps/npm/test/tap/shrinkwrap-prod-dependency.js
+++ /dev/null
@@ -1,76 +0,0 @@
-var fs = require('fs')
-var path = require('path')
-
-var mkdirp = require('mkdirp')
-var mr = require('npm-registry-mock')
-var test = require('tap').test
-
-var npm = require('../../')
-
-var common = require('../common-tap.js')
-var pkg = common.pkg
-
-var desired = {
- name: 'npm-test-shrinkwrap-prod-dependency',
- version: '0.0.0',
- dependencies: {
- request: {
- version: '0.9.0',
- resolved: common.registry + '/request/-/request-0.9.0.tgz',
- integrity: 'sha1-EEn1mm9GWI5tAwkh+7hMovDCcU4='
- },
- underscore: {
- dev: true,
- version: '1.5.1',
- resolved: common.registry + '/underscore/-/underscore-1.5.1.tgz',
- integrity: 'sha1-0r3oF9F2/63olKtxRY5oKhS4bck='
- }
- }
-}
-
-var json = {
- author: 'Domenic Denicola',
- name: 'npm-test-shrinkwrap-prod-dependency',
- version: '0.0.0',
- dependencies: {
- request: '0.9.0'
- },
- devDependencies: {
- underscore: '1.5.1'
- }
-}
-
-test('setup', function (t) {
- mkdirp.sync(pkg)
- fs.writeFileSync(path.join(pkg, 'package.json'), JSON.stringify(json, null, 2))
- process.chdir(pkg)
-
- var allOpts = {
- cache: common.cache,
- registry: common.registry
- }
-
- npm.load(allOpts, t.end)
-})
-
-test('mock registry', t => {
- mr({port: common.port}, function (er, s) {
- t.parent.teardown(() => s.close())
- t.end()
- })
-})
-
-test("shrinkwrap --dev doesn't strip out prod dependencies", t => {
- t.plan(1)
- npm.install('.', function (err) {
- if (err) return t.fail(err)
-
- npm.config.set('dev', true)
- npm.commands.shrinkwrap([], true, function (err, results) {
- if (err) return t.fail(err)
-
- t.deepEqual(results.dependencies, desired.dependencies)
- t.end()
- })
- })
-})
diff --git a/deps/npm/test/tap/shrinkwrap-resolve-conflict.js b/deps/npm/test/tap/shrinkwrap-resolve-conflict.js
deleted file mode 100644
index d1f63f7e62..0000000000
--- a/deps/npm/test/tap/shrinkwrap-resolve-conflict.js
+++ /dev/null
@@ -1,117 +0,0 @@
-'use strict'
-
-const BB = require('bluebird')
-
-const common = require('../common-tap.js')
-const fs = BB.promisifyAll(require('fs'))
-const path = require('path')
-const rimraf = BB.promisify(require('rimraf'))
-const test = require('tap').test
-const Tacks = require('tacks')
-
-const File = Tacks.File
-const Dir = Tacks.Dir
-
-const testDir = common.pkg
-const modAdir = path.resolve(testDir, 'modA')
-const modBdir = path.resolve(testDir, 'modB')
-const modCdir = path.resolve(testDir, 'modC')
-
-test('conflicts in shrinkwrap are auto-resolved on install', (t) => {
- const fixture = new Tacks(Dir({
- 'package.json': File({
- name: 'foo',
- dependencies: {
- modA: 'file://' + modAdir,
- modB: 'file://' + modBdir
- },
- devDependencies: {
- modC: 'file://' + modCdir
- }
- }),
- 'npm-shrinkwrap.json': File(
- `
-{
- "name": "foo",
- "requires": true,
- "lockfileVersion": 1,
- "dependencies": {
-<<` + `<<` + `<<` + `< HEAD
- "modA": {
- "version": "file:modA"
-||` + `||` + `||` + `| merged common ancestors
- "modB": {
- "version": "file:modB"
-==` + `==` + `==` + `=
- "modC": {
- "version": "file:modC",
- "dev": true
->>` + `>>` + `>>` + `> branch
- }
- }
-}
-`),
- 'modA': Dir({
- 'package.json': File({
- name: 'modA',
- version: '1.0.0'
- })
- }),
- 'modB': Dir({
- 'package.json': File({
- name: 'modB',
- version: '1.0.0'
- })
- }),
- 'modC': Dir({
- 'package.json': File({
- name: 'modC',
- version: '1.0.0'
- })
- })
- }))
- fixture.create(testDir)
- function readJson (file) {
- return fs.readFileAsync(path.join(testDir, file)).then(JSON.parse)
- }
- return BB.fromNode((cb) => {
- common.npm([
- 'install',
- '--loglevel', 'warn'
- ], {cwd: testDir}, (err, code, out, stderr) => {
- t.comment(stderr)
- t.match(stderr, /warn.*conflict/gi, 'warns about a conflict')
- cb(err || (code && new Error('non-zero exit code')) || null, out)
- })
- })
- .then(() => BB.join(
- readJson('npm-shrinkwrap.json'),
- readJson('node_modules/modA/package.json'),
- readJson('node_modules/modB/package.json'),
- readJson('node_modules/modC/package.json'),
- (lockfile, A, B, C) => {
- t.deepEqual(lockfile, {
- name: 'foo',
- requires: true,
- lockfileVersion: 1,
- dependencies: {
- modA: {
- version: 'file:modA'
- },
- modB: {
- version: 'file:modB'
- },
- modC: {
- version: 'file:modC',
- dev: true
- }
- }
- }, 'resolved lockfile matches expectations')
- t.equal(A.name, 'modA', 'installed modA')
- t.equal(B.name, 'modB', 'installed modB')
- t.equal(C.name, 'modC', 'installed modC')
- }
- ))
-})
-
-test('cleanup', () => rimraf(testDir))
diff --git a/deps/npm/test/tap/shrinkwrap-save-dev-with-existing-deps.js b/deps/npm/test/tap/shrinkwrap-save-dev-with-existing-deps.js
deleted file mode 100644
index 1c35bf226b..0000000000
--- a/deps/npm/test/tap/shrinkwrap-save-dev-with-existing-deps.js
+++ /dev/null
@@ -1,92 +0,0 @@
-/* eslint-disable camelcase */
-var fs = require('fs')
-var path = require('path')
-var mkdirp = require('mkdirp')
-var test = require('tap').test
-var common = require('../common-tap.js')
-
-var base = common.pkg
-var installme = path.join(base, 'installme')
-var installme_pkg = path.join(installme, 'package.json')
-var example = path.join(base, 'example')
-var example_shrinkwrap = path.join(example, 'npm-shrinkwrap.json')
-var example_pkg = path.join(example, 'package.json')
-var installed_prod = path.join(example, 'node_modules', 'installed-prod')
-var installed_prod_pkg = path.join(installed_prod, 'package.json')
-var installed_dev = path.join(example, 'node_modules', 'installed-dev')
-var installed_dev_pkg = path.join(installed_dev, 'package.json')
-
-var EXEC_OPTS = { cwd: example }
-
-var installme_pkg_json = {
- name: 'installme',
- version: '1.0.0',
- dependencies: {}
-}
-
-var example_pkg_json = {
- name: 'example',
- version: '1.0.0',
- dependencies: {
- 'installed-prod': '1.0'
- },
- devDependencies: {
- 'installed-dev': '1.0'
- }
-}
-
-var example_shrinkwrap_json = {
- name: 'example',
- version: '1.0.0',
- dependencies: {
- 'installed-prod': {
- version: '1.0.0'
- },
- 'installed-dev': {
- version: '1.0.0'
- }
- }
-}
-
-var installed_prod_pkg_json = {
- _id: 'installed-prod@1.0.0',
- _integrity: 'sha1-deadbeef',
- _resolved: 'foo',
- name: 'installed-prod',
- version: '1.0.0'
-}
-
-var installed_dev_pkg_json = {
- _id: 'installed-dev@1.0.0',
- _integrity: 'sha1-deadbeef',
- _resolved: 'foo',
- name: 'installed-dev',
- version: '1.0.0'
-}
-
-function writeJson (filename, obj) {
- mkdirp.sync(path.dirname(filename))
- fs.writeFileSync(filename, JSON.stringify(obj, null, 2))
-}
-
-test('setup', function (t) {
- writeJson(installme_pkg, installme_pkg_json)
- writeJson(example_pkg, example_pkg_json)
- writeJson(example_shrinkwrap, example_shrinkwrap_json)
- writeJson(installed_prod_pkg, installed_prod_pkg_json)
- writeJson(installed_dev_pkg, installed_dev_pkg_json)
- t.end()
-})
-
-test('install --save-dev leaves prod deps alone', function (t) {
- common.npm(['install', '--save-dev', 'file://' + installme], EXEC_OPTS, function (er, code, stdout, stderr) {
- t.ifError(er, "spawn didn't catch fire")
- t.is(code, 0, 'install completed ok')
- t.is(stderr, '', 'install completed without error output')
- var shrinkwrap = JSON.parse(fs.readFileSync(example_shrinkwrap))
- t.ok(shrinkwrap.dependencies['installed-prod'], "save-dev new install didn't remove prod dep")
- t.ok(shrinkwrap.dependencies['installed-dev'], "save-dev new install didn't remove dev dep")
- t.ok(shrinkwrap.dependencies.installme, 'save-dev new install DID add new dev dep')
- t.end()
- })
-})
diff --git a/deps/npm/test/tap/shrinkwrap-save-with-existing-dev-deps.js b/deps/npm/test/tap/shrinkwrap-save-with-existing-dev-deps.js
deleted file mode 100644
index acf6ac2101..0000000000
--- a/deps/npm/test/tap/shrinkwrap-save-with-existing-dev-deps.js
+++ /dev/null
@@ -1,79 +0,0 @@
-/* eslint-disable camelcase */
-var fs = require('fs')
-var path = require('path')
-
-var mkdirp = require('mkdirp')
-var test = require('tap').test
-
-var common = require('../common-tap.js')
-
-var base = common.pkg
-var installme = path.join(base, 'installme')
-var installme_pkg = path.join(installme, 'package.json')
-var example = path.join(base, 'example')
-var example_shrinkwrap = path.join(example, 'npm-shrinkwrap.json')
-var example_pkg = path.join(example, 'package.json')
-var installed = path.join(example, 'node_modules', 'installed')
-var installed_pkg = path.join(installed, 'package.json')
-
-// Ignore max listeners warnings until that gets fixed
-var env = Object.keys(process.env).reduce((set, key) => {
- if (!set[key]) set[key] = process.env[key]
- return set
-}, { NODE_NO_WARNINGS: '1' })
-
-var EXEC_OPTS = { cwd: example, env: env }
-
-var installme_pkg_json = {
- name: 'installme',
- version: '1.0.0',
- dependencies: {}
-}
-
-var example_pkg_json = {
- name: 'example',
- version: '1.0.0',
- dependencies: {},
- devDependencies: {
- 'installed': '1.0'
- }
-}
-
-var example_shrinkwrap_json = {
- name: 'example',
- version: '1.0.0',
- dependencies: {
- installed: {
- version: '1.0.0'
- }
- }
-}
-
-var installed_pkg_json = {
- _id: 'installed@1.0.0',
- name: 'installed',
- version: '1.0.0'
-}
-
-function writeJson (filename, obj) {
- mkdirp.sync(path.dirname(filename))
- fs.writeFileSync(filename, JSON.stringify(obj, null, 2))
-}
-
-test('setup', function (t) {
- writeJson(installme_pkg, installme_pkg_json)
- writeJson(example_pkg, example_pkg_json)
- writeJson(example_shrinkwrap, example_shrinkwrap_json)
- writeJson(installed_pkg, installed_pkg_json)
- t.end()
-})
-
-test('install --save leaves dev deps alone', t =>
- common.npm(['install', '--save', 'file://' + installme], EXEC_OPTS)
- .then(([code, stdout, stderr]) => {
- t.is(code, 0, 'install completed ok')
- t.is(stderr, '', 'install completed without error output')
- var shrinkwrap = JSON.parse(fs.readFileSync(example_shrinkwrap))
- t.ok(shrinkwrap.dependencies.installed, "save new install didn't remove dev dep")
- t.ok(shrinkwrap.dependencies.installme, 'save new install DID add new dep')
- }))
diff --git a/deps/npm/test/tap/shrinkwrap-scoped-auth.js b/deps/npm/test/tap/shrinkwrap-scoped-auth.js
deleted file mode 100644
index cc1b227001..0000000000
--- a/deps/npm/test/tap/shrinkwrap-scoped-auth.js
+++ /dev/null
@@ -1,96 +0,0 @@
-'use strict'
-
-var fs = require('fs')
-var path = require('path')
-var writeFileSync = require('graceful-fs').writeFileSync
-
-var mkdirp = require('mkdirp')
-var mr = require('npm-registry-mock')
-var ssri = require('ssri')
-var test = require('tap').test
-
-var common = require('../common-tap.js')
-var toNerfDart = require('../../lib/config/nerf-dart.js')
-
-var pkg = common.pkg
-var outfile = path.resolve(pkg, '_npmrc')
-var modules = path.resolve(pkg, 'node_modules')
-var tarballPath = '/scoped-underscore/-/scoped-underscore-1.3.1.tgz'
-var tarballURL = common.registry + tarballPath
-var tarball = path.resolve(__dirname, '../fixtures/scoped-underscore-1.3.1.tgz')
-var tarballIntegrity = ssri.fromData(fs.readFileSync(tarball)).toString()
-
-function mocks (server) {
- var auth = 'Bearer 0xabad1dea'
- server.get(tarballPath, { authorization: auth }).replyWithFile(200, tarball)
- server.get(tarballPath).reply(401, {
- error: 'unauthorized',
- reason: 'You are not authorized to access this db.'
- })
-}
-
-var contents = '@scoped:registry=' + common.registry + '\n' +
- toNerfDart(common.registry) + ':_authToken=0xabad1dea\n'
-
-var json = {
- name: 'test-package-install',
- version: '1.0.0',
- dependencies: {
- '@scoped/underscore': '1.0.0'
- }
-}
-
-var shrinkwrap = {
- name: 'test-package-install',
- version: '1.0.0',
- lockfileVersion: 1,
- dependencies: {
- '@scoped/underscore': {
- resolved: tarballURL,
- integrity: tarballIntegrity,
- version: '1.3.1'
- }
- }
-}
-
-test('setup', function (t) {
- mkdirp.sync(modules)
- writeFileSync(path.resolve(pkg, 'package.json'), JSON.stringify(json, null, 2) + '\n')
- writeFileSync(outfile, contents)
- writeFileSync(
- path.resolve(pkg, 'npm-shrinkwrap.json'),
- JSON.stringify(shrinkwrap, null, 2) + '\n'
- )
- mr({ port: common.port, plugin: mocks }, function (er, s) {
- t.parent.teardown(() => s.close())
- t.ok(s, 'set up mock registry')
- t.end()
- })
-})
-
-test('authed npm install with shrinkwrapped scoped package', function (t) {
- common.npm(
- [
- 'install',
- '--loglevel', 'error',
- '--json',
- '--fetch-retries', 0,
- '--userconfig', outfile,
- '--registry', common.registry
- ],
- {cwd: pkg, stdio: [0, 'pipe', 2]},
- function (err, code, stdout) {
- if (err) throw err
- t.equal(code, 0, 'npm install exited OK')
- try {
- var results = JSON.parse(stdout)
- t.match(results, {added: [{name: '@scoped/underscore', version: '1.3.1'}]}, '@scoped/underscore installed')
- } catch (ex) {
- console.error('#', ex)
- t.ifError(ex, 'stdout was valid JSON')
- }
-
- t.end()
- }
- )
-})
diff --git a/deps/npm/test/tap/shrinkwrap-shared-dev-dependency.js b/deps/npm/test/tap/shrinkwrap-shared-dev-dependency.js
deleted file mode 100644
index 5aa331f34c..0000000000
--- a/deps/npm/test/tap/shrinkwrap-shared-dev-dependency.js
+++ /dev/null
@@ -1,89 +0,0 @@
-var fs = require('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 = common.pkg
-
-var opts = {
- env: common.newEnv().extend({
- npm_config_cache: common.cache,
- npm_config_registry: common.registry
- }),
- stdio: [0, 1, 2],
- cwd: pkg
-}
-
-var json = {
- author: 'Domenic Denicola',
- name: 'npm-test-shrinkwrap-shared-dev-dependency',
- version: '0.0.0',
- dependencies: {
- 'test-package-with-one-dep': '0.0.0'
- },
- devDependencies: {
- 'test-package': '0.0.0'
- }
-}
-
-var server
-test('setup', function (t) {
- setup()
- mr({ port: common.port }, function (er, s) {
- if (er) throw er
- server = s
- t.done()
- })
-})
-
-var desired = {
- name: 'npm-test-shrinkwrap-shared-dev-dependency',
- version: '0.0.0',
- dependencies: {
- 'test-package-with-one-dep': {
- version: '0.0.0',
- resolved: common.registry + '/test-package-with-one-dep/-/test-package-with-one-dep-0.0.0.tgz',
- integrity: 'sha1-JWwVltusKyPRImjatagCuy42Wsg='
- },
- 'test-package': {
- version: '0.0.0',
- resolved: common.registry + '/test-package/-/test-package-0.0.0.tgz',
- integrity: 'sha1-sNMrbEXCWcV4uiADdisgUTG9+9E='
- }
- }
-}
-
-test("shrinkwrap doesn't strip out the shared dependency", function (t) {
- t.plan(3)
-
- return common.npm(['install'], opts).spread((code) => {
- t.is(code, 0, 'install')
- return common.npm(['shrinkwrap'], opts)
- }).spread((code) => {
- t.is(code, 0, 'shrinkwrap')
- var results = JSON.parse(fs.readFileSync(`${pkg}/npm-shrinkwrap.json`))
- t.like(results.dependencies, desired.dependencies)
- t.end()
- })
-})
-
-test('cleanup', function (t) {
- server.close()
- cleanup()
- t.end()
-})
-
-function setup () {
- cleanup()
- mkdirp.sync(pkg)
- fs.writeFileSync(path.join(pkg, 'package.json'), JSON.stringify(json, null, 2))
-}
-
-function cleanup () {
- rimraf.sync(pkg)
-}
diff --git a/deps/npm/test/tap/shrinkwrap-version-match.js b/deps/npm/test/tap/shrinkwrap-version-match.js
deleted file mode 100644
index e579f84d4b..0000000000
--- a/deps/npm/test/tap/shrinkwrap-version-match.js
+++ /dev/null
@@ -1,115 +0,0 @@
-'use strict'
-var test = require('tap').test
-var Tacks = require('tacks')
-var File = Tacks.File
-var Dir = Tacks.Dir
-var fs = require('fs')
-var path = require('path')
-var common = require('../common-tap.js')
-
-var testdir = common.pkg
-var modAdir = path.resolve(testdir, 'modA')
-var modB1dir = path.resolve(testdir, 'modB@1')
-var modB2dir = path.resolve(testdir, 'modB@2')
-var modCdir = path.resolve(testdir, 'modC')
-
-var fixture = new Tacks(Dir({
- 'package.json': File({
- dependencies: {
- modA: 'file://' + modAdir
- },
- devDependencies: {
- modC: 'file://' + modCdir
- }
- }),
- 'npm-shrinkwrap.json': File({
- requires: true,
- lockfileVersion: 1,
- dependencies: {
- modA: {
- version: 'file://' + modAdir,
- requires: {
- modB: 'file://' + modB1dir
- }
- },
- modB: {
- version: 'file://' + modB1dir
- }
- }
- }),
- 'modA': Dir({
- 'package.json': File({
- name: 'modA',
- version: '1.0.0',
- dependencies: {
- 'modB': 'file://' + modB1dir
- }
- })
- }),
- 'modB@1': Dir({
- 'package.json': File({
- name: 'modB',
- version: '1.0.0'
- }),
- 'B1': File('')
- }),
- 'modB@2': Dir({
- 'package.json': File({
- name: 'modB',
- version: '2.0.0'
- }),
- 'B2': File('')
- }),
- 'modC': Dir({
- 'package.json': File({
- name: 'modC',
- version: '1.0.0',
- dependencies: {
- 'modB': 'file://' + modB2dir
- }
- })
- })
-}))
-
-function setup () {
- fixture.create(testdir)
-}
-
-function cleanup () {
- fixture.remove(testdir)
-}
-
-test('setup', function (t) {
- cleanup()
- setup()
- t.end()
-})
-
-// Shrinkwraps need to let you override dependency versions specified in
-// package.json files. Indeed, this was already supported, but it was a bit
-// to keen on this. Previously, if you had a dep in your shrinkwrap then
-// anything that required that dependency would count as a match, regardless
-// of version.
-
-// This test ensures that the broad matching is not done when the matched
-// module is not a direct child of the module doing the requiring.
-
-test('bundled', function (t) {
- common.npm(['install'], {cwd: testdir}, function (err, code, out, stderr) {
- t.is(err, null, 'No fatal errors running npm')
- t.is(code, 0, 'npm itself completed ok')
- // Specifically, if B2 exists (or the modB directory under modC at all)
- // that means modC was given its own copy of modB. Without the patch
- // that went with this test, it wouldn't have been installed because npm
- // would have consider modB@1 to have fulfilled modC's requirement.
- fs.stat(path.join(testdir, 'node_modules', 'modC', 'node_modules', 'modB', 'B2'), function (missing) {
- t.ok(!missing, 'modC got the right version of modB')
- t.end()
- })
- })
-})
-
-test('cleanup', function (t) {
- cleanup()
- t.end()
-})
diff --git a/deps/npm/test/tap/sorted-package-json.js b/deps/npm/test/tap/sorted-package-json.js
deleted file mode 100644
index f802bfd9e5..0000000000
--- a/deps/npm/test/tap/sorted-package-json.js
+++ /dev/null
@@ -1,61 +0,0 @@
-var test = require('tap').test
-var path = require('path')
-var common = require('../common-tap.js')
-var pkg = common.pkg
-var tmp = path.join(pkg, 'tmp')
-var cache = common.cache
-var fs = require('fs')
-var mr = require('npm-registry-mock')
-var packageJson = path.resolve(pkg, 'package.json')
-
-fs.writeFileSync(packageJson, JSON.stringify({
- 'name': 'sorted-package-json',
- 'version': '0.0.0',
- 'description': '',
- 'main': 'index.js',
- 'scripts': {
- 'test': 'echo \'Error: no test specified\' && exit 1'
- },
- 'author': 'Rocko Artischocko',
- 'license': 'ISC',
- 'dependencies': {
- 'underscore': '^1.3.3',
- 'request': '^0.9.0'
- }
-}, null, 2), 'utf8')
-
-test('sorting dependencies', function (t) {
- var before = JSON.parse(fs.readFileSync(packageJson).toString())
-
- mr({ port: common.port }, function (er, s) {
- // underscore is already in the package.json,
- // but --save will trigger a rewrite with sort
- common.npm([
- 'install',
- '--save', 'underscore@1.3.3',
- '--no-progress',
- '--cache', cache,
- '--tmp', tmp,
- '--registry', common.registry
- ], {
- cwd: pkg
- }, function (err, code, stdout, stderr) {
- t.ifError(err, 'no error')
- t.equal(code, 0, 'npm install exited with code')
- var result = fs.readFileSync(packageJson).toString()
- var resultAsJson = JSON.parse(result)
-
- s.close()
-
- t.same(Object.keys(resultAsJson.dependencies),
- Object.keys(before.dependencies).sort())
-
- t.notSame(Object.keys(resultAsJson.dependencies),
- Object.keys(before.dependencies))
-
- t.ok(resultAsJson.dependencies.underscore)
- t.ok(resultAsJson.dependencies.request)
- t.end()
- })
- })
-})
diff --git a/deps/npm/test/tap/spawn-enoent-help.js b/deps/npm/test/tap/spawn-enoent-help.js
deleted file mode 100644
index cb7c942be8..0000000000
--- a/deps/npm/test/tap/spawn-enoent-help.js
+++ /dev/null
@@ -1,35 +0,0 @@
-var test = require('tap').test
-var rimraf = require('rimraf')
-var mkdirp = require('mkdirp')
-var common = require('../common-tap.js')
-
-var pkg = common.pkg
-
-common.pendIfWindows('man pages are not built on Windows')
-
-test('setup', function (t) {
- rimraf.sync(pkg)
- mkdirp.sync(pkg)
- t.end()
-})
-
-test('enoent help', function (t) {
- common.npm(['help', 'config'], {
- cwd: pkg,
- env: {
- PATH: '',
- Path: '',
- 'npm_config_loglevel': 'warn',
- 'npm_config_viewer': 'woman'
- }
- }, function (er, code, sout, serr) {
- t.similar(serr, /Check if the file 'emacsclient' is present./)
- t.equal(global.cooked, undefined, "Don't leak into global scope")
- t.end()
- })
-})
-
-test('clean', function (t) {
- rimraf.sync(pkg)
- t.end()
-})
diff --git a/deps/npm/test/tap/spawn-enoent.js b/deps/npm/test/tap/spawn-enoent.js
deleted file mode 100644
index 78153572ee..0000000000
--- a/deps/npm/test/tap/spawn-enoent.js
+++ /dev/null
@@ -1,38 +0,0 @@
-var test = require('tap').test
-var fs = require('fs')
-var rimraf = require('rimraf')
-var mkdirp = require('mkdirp')
-var common = require('../common-tap.js')
-
-var pkg = common.pkg
-var pj = JSON.stringify({
- name: 'x',
- version: '1.2.3',
- scripts: { start: 'wharble-garble-blorst' }
-}, null, 2) + '\n'
-
-test('setup', function (t) {
- rimraf.sync(pkg)
- mkdirp.sync(pkg)
- fs.writeFileSync(pkg + '/package.json', pj)
- t.end()
-})
-
-test('enoent script', function (t) {
- common.npm(['start'], {
- cwd: pkg,
- env: {
- PATH: process.env.PATH,
- Path: process.env.Path,
- 'npm_config_loglevel': 'warn'
- }
- }, function (er, code, sout, serr) {
- t.similar(serr, /npm ERR! Failed at the x@1\.2\.3 start script\./)
- t.end()
- })
-})
-
-test('clean', function (t) {
- rimraf.sync(pkg)
- t.end()
-})
diff --git a/deps/npm/test/tap/spec-local-specifiers.js b/deps/npm/test/tap/spec-local-specifiers.js
deleted file mode 100644
index 6ea65278cd..0000000000
--- a/deps/npm/test/tap/spec-local-specifiers.js
+++ /dev/null
@@ -1,752 +0,0 @@
-'use strict'
-var path = require('path')
-var test = require('tap').test
-var fs = require('fs')
-var rimraf = require('rimraf')
-var mr = require('npm-registry-mock')
-var Tacks = require('tacks')
-var File = Tacks.File
-var Symlink = Tacks.Symlink
-var Dir = Tacks.Dir
-var common = require('../common-tap.js')
-var isWindows = require('../../lib/utils/is-windows.js')
-
-var basedir = common.pkg
-var testdir = path.join(basedir, 'testdir')
-var cachedir = common.cache
-var globaldir = path.join(basedir, 'global')
-var tmpdir = path.join(basedir, 'tmp')
-
-var conf = {
- cwd: testdir,
- env: common.emptyEnv().extend({
- npm_config_cache: cachedir,
- npm_config_tmp: tmpdir,
- npm_config_prefix: globaldir,
- npm_config_registry: common.registry,
- npm_config_loglevel: 'error'
- }),
- stdio: [0, 'pipe', 2]
-}
-var confE = {
- cwd: testdir,
- env: conf.env,
- stdio: [0, 'pipe', 'pipe']
-}
-
-function readJson (file) {
- return JSON.parse(fs.readFileSync(file))
-}
-
-function isSymlink (t, file, message) {
- try {
- var info = fs.lstatSync(file)
- t.is(info.isSymbolicLink(), true, message)
- } catch (ex) {
- if (ex.code === 'ENOENT') {
- t.fail(message, {found: null, wanted: 'symlink', compare: 'fs.lstat(' + file + ')'})
- } else {
- t.fail(message, {found: ex, wanted: 'symlink', compare: 'fs.lstat(' + file + ')'})
- }
- }
-}
-
-function fileExists (t, file, message) {
- try {
- fs.statSync(file)
- t.pass(message)
- } catch (ex) {
- if (ex.code === 'ENOENT') {
- t.fail(message, {found: null, wanted: 'exists', compare: 'fs.stat(' + file + ')'})
- } else {
- t.fail(message, {found: ex, wanted: 'exists', compare: 'fs.stat(' + file + ')'})
- }
- }
-}
-
-function noFileExists (t, file, message) {
- try {
- fs.statSync(file)
- t.fail(message, {found: 'exists', wanted: 'not exists', compare: 'fs.stat(' + file + ')'})
- } catch (ex) {
- if (ex.code === 'ENOENT') {
- t.pass(message)
- } else {
- t.fail(message, {found: ex, wanted: 'not exists', compare: 'fs.stat(' + file + ')'})
- }
- }
-}
-
-var server
-var testdirContent = {
- node_modules: Dir({}),
- pkga: Dir({
- 'package.json': File({
- name: 'pkga',
- version: '1.0.0'
- })
- }),
- pkgb: Dir({
- 'package.json': File({
- name: 'pkgb',
- version: '1.0.0'
- })
- }),
- pkgc: Dir({
- 'package.json': File({
- name: 'pkgc',
- version: '1.0.0'
- })
- }),
- pkgd: Dir({
- 'package.json': File({
- name: 'pkgd',
- version: '1.0.0'
- })
- })
-}
-
-var fixture
-function setup () {
- fixture = new Tacks(Dir({
- cache: Dir(),
- global: Dir(),
- tmp: Dir(),
- testdir: Dir(testdirContent)
- }))
- cleanup()
- fixture.create(basedir)
-}
-
-function cleanup () {
- fixture.remove(basedir)
-}
-
-test('setup', function (t) {
- process.nextTick(function () {
- setup()
- mr({port: common.port, throwOnUnmatched: true}, function (err, s) {
- if (err) throw err
- server = s
- t.done()
- })
- })
-})
-
-var installOk = []
-var slashes = [ 'unix', 'win' ]
-slashes.forEach(function (os) {
- var slash = os === 'unix'
- ? function (ss) { return ss.replace(/\\/g, '/') }
- : function (ss) { return ss.replace(/\//g, '\\') }
- installOk.push(os + '-file-abs-f')
- testdirContent[os + '-file-abs-f'] = Dir({
- 'package.json': File({
- name: os + '-file-abs-f',
- version: '1.0.0',
- dependencies: {
- pkga: 'file:' + slash(testdir + '/pkga')
- }
- })
- })
- installOk.push(os + '-file-abs-fff')
- testdirContent[os + '-file-abs-fff'] = Dir({
- 'package.json': File({
- name: os + '-file-abs-fff',
- version: '1.0.0',
- dependencies: {
- pkga: 'file://' + slash(testdir + '/pkga')
- }
- })
- })
- installOk.push(os + '-file-rel')
- testdirContent[os + '-file-rel'] = Dir({
- 'package.json': File({
- name: os + '-file-rel',
- version: '1.0.0',
- dependencies: {
- pkga: 'file:' + slash('../pkga')
- }
- })
- })
- installOk.push(os + '-file-rel-fffff')
- testdirContent[os + '-file-rel-fffff'] = Dir({
- 'package.json': File({
- name: os + '-file-rel-fffff',
- version: '1.0.0',
- dependencies: {
- pkga: 'file:' + slash('/////../pkga')
- }
- })
- })
-})
-
-testdirContent['win-abs-drive-win'] = Dir({
- 'package.json': File({
- name: 'win-abs-drive-win',
- version: '1.0.0',
- dependencies: {
- pkga: 'file:D:\\thing\\pkga'
- }
- })
-})
-
-testdirContent['win-abs-drive-unix'] = Dir({
- 'package.json': File({
- name: 'win-abs-drive-unix',
- version: '1.0.0',
- dependencies: {
- pkga: 'file://D:/thing/pkga'
- }
- })
-})
-
-test('specifiers', function (t) {
- t.plan(installOk.length + 2)
- installOk.forEach(function (mod) {
- t.test(mod, function (t) {
- common.npm(['install', '--dry-run', '--json', 'file:' + mod], conf, function (err, code, stdout) {
- if (err) throw err
- t.is(code, 0, 'command ran ok')
- t.comment(stdout.trim())
- t.done()
- })
- })
- })
- slashes.forEach(function (os) {
- t.test('win-abs-drive-' + os, function (t) {
- common.npm(['install', '--dry-run', '--json', 'file:win-abs-drive-' + os], confE, function (err, code, stdout, stderr) {
- if (err) throw err
- t.not(code, 0, 'command errored ok')
- t.comment(stderr.trim())
- if (isWindows) {
- t.test('verify failure of file-not-found or wrong drive letter on windows')
- } else {
- var result = JSON.parse(stdout)
- t.is(result.error && result.error.code, 'EWINDOWSPATH', 'verify failure due to windows paths not supported on non-Windows')
- }
-
- t.done()
- })
- })
- })
-})
-testdirContent['mkdirp'] = Dir({
- 'package.json': File({
- name: 'mkdirp',
- version: '9.9.9'
- })
-})
-testdirContent['example'] = Dir({
- 'minimist': Dir({
- 'package.json': File({
- name: 'minimist',
- version: '9.9.9'
- })
- })
-})
-testdirContent['wordwrap'] = Dir({
-})
-testdirContent['prefer-pkg'] = Dir({
- 'package.json': File({
- name: 'perfer-pkg',
- version: '1.0.0',
- dependencies: {
- 'mkdirp': 'latest'
- }
- }),
- 'latest': Dir({
- 'package.json': File({
- name: 'mkdirp',
- version: '9.9.9'
- })
- })
-})
-
-test('ambiguity', function (t) {
- t.plan(5)
- t.test('arg: looks like package name, is dir', function (t) {
- common.npm(['install', 'mkdirp', '--dry-run', '--json'], conf, function (err, code, stdout) {
- if (err) throw err
- t.is(code, 0, 'command ran ok')
- const result = JSON.parse(stdout.trim())
- t.like(result, {added: [{name: 'mkdirp', version: '9.9.9'}]}, 'got local dir')
- t.done()
- })
- })
- t.test('arg: looks like package name, is package', function (t) {
- common.npm(['install', 'wordwrap', '--dry-run', '--json'], conf, function (err, code, stdout) {
- if (err) throw err
- t.is(code, 0, 'command ran ok')
- const result = JSON.parse(stdout.trim())
- t.like(result, {added: [{name: 'wordwrap', version: '0.0.2'}]}, 'even with local dir w/o package.json, got global')
- t.done()
- })
- })
- t.test('arg: looks like github repo, is dir', function (t) {
- common.npm(['install', 'example/minimist', '--dry-run', '--json'], conf, function (err, code, stdout) {
- if (err) throw err
- t.is(code, 0, 'command ran ok')
- const result = JSON.parse(stdout.trim())
- t.like(result, {added: [{name: 'minimist', version: '9.9.9'}]}, 'got local dir')
- t.done()
- })
- })
- t.test('package: looks like tag, has dir, use tag', function (t) {
- common.npm(['install', '--dry-run', '--json'], {cwd: path.join(testdir, 'prefer-pkg'), env: conf.env}, function (err, code, stdout) {
- if (err) throw err
- t.is(code, 0, 'command ran ok')
- const result = JSON.parse(stdout.trim())
- t.like(result, {added: [{name: 'mkdirp', version: '0.3.5'}]}, 'got local dir')
- t.done()
- })
- })
-
- t.test('test ambiguity for github repos')
-})
-testdirContent['existing-matches'] = Dir({
- 'package.json': File({
- name: 'existing-matches',
- version: '1.0.0',
- dependencies: {
- 'pkga': 'file:../pkga',
- 'pkgb': 'file:' + testdir + '/pkgb',
- 'pkgc': 'file:../pkgc',
- 'pkgd': 'file:' + testdir + '/pkgd'
- }
- }),
- 'node_modules': Dir({
- 'pkga': Symlink('../../pkga'),
- 'pkgd': Symlink('../../pkgd')
- })
-})
-
-test('existing install matches', function (t) {
- t.plan(1)
- // have to make these by hand because tacks doesn't support absolute paths in symlinks
- fs.symlinkSync(testdir + '/pkgb', testdir + '/existing-matches/node_modules/pkgb', 'junction')
- fs.symlinkSync(testdir + '/pkgc', testdir + '/existing-matches/node_modules/pkgc', 'junction')
- t.test('relative symlink counts as match of relative symlink in package.json', function (t) {
- common.npm(['ls', '--json'], {cwd: path.join(testdir, 'existing-matches'), env: conf.env}, function (err, code, stdout) {
- if (err) throw err
- t.is(code, 0, 'command ran ok')
- if (stdout) t.comment(stdout.trim())
- t.test('specifically test that output is valid')
- // relative symlink counts as match of relative symlink in package.json (pkga)
- // relative symlink counts as match of abs symlink in package.json (pkgc)
- // abs symlink counts as match of relative symlink in package.json (pkgb)
- // abs symlink counts as match of abs symlink in package.json (pkgd)
- t.done()
- })
- })
-})
-var ibdir = testdir + '/install-behavior'
-testdirContent['ib-out'] = Dir({
- 'package.json': File({
- name: 'ib-out',
- version: '1.0.0',
- dependencies: {
- 'minimist': '*'
- }
- })
-})
-
-testdirContent['install-behavior'] = Dir({
- 'package.json': File({
- name: 'install-behavior',
- version: '1.0.0'
- }),
- 'ib-in': Dir({
- 'package.json': File({
- name: 'ib-in',
- version: '1.0.0',
- dependencies: {
- 'mkdirp': '*'
- }
- })
- }),
- 'noext': File(Buffer.from(
- '1f8b08000000000000032b484cce4e4c4fd52f80d07a59c5f9790c540606' +
- '06066626260a20dadccc144c1b1841f86000923334363037343536343732' +
- '633000728c0c80f2d4760836505a5c925804740aa5e640bca200a78708a8' +
- '56ca4bcc4d55b252cacb4fad2851d251502a4b2d2acecccf030a19ea19e8' +
- '1928d5720db41b47c1281805a36014501f00005012007200080000',
- 'hex'
- )),
- 'tarball-1.0.0.tgz': File(Buffer.from(
- '1f8b08000000000000032b484cce4e4c4fd52f80d07a59c5f9790c540606' +
- '06066626260a20dadccc144c1b1841f8606062a6c060686c606e686a6c68' +
- '666ec26000e480e5a9ed106ca0b4b824b108e8144acd817845014e0f1150' +
- 'ad9497989baa64a5040c85a4c49c1c251d05a5b2d4a2e2ccfc3ca0a0a19e' +
- '819e81522dd740bb72148c8251300a4601b50100473dd15800080000',
- 'hex'
- )),
- 'not-module': Dir({}),
- 'test-preinstall': Dir({
- 'preinstall.js': File('console.log("CWD:" + process.cwd())'),
- 'package.json': File({
- name: 'test-preinstall',
- version: '1.0.0',
- scripts: {
- 'preinstall': 'node ' + ibdir + '/test-preinstall/preinstall.js'
- }
- })
- })
-})
-
-test('install behavior', function (t) {
- var ibconf = {cwd: ibdir, env: conf.env.extend({npm_config_loglevel: 'silent'}), stdio: conf.stdio}
- t.plan(7)
- t.test('transitive deps for in-larger-module cases', function (t) {
- common.npm(['install', 'file:ib-in'], ibconf, function (err, code, stdout) {
- if (err) throw err
- t.is(code, 0, 'command ran ok')
- if (stdout) t.comment(stdout.trim())
- fileExists(t, ibdir + '/node_modules/mkdirp', 'transitive dep flattened')
- isSymlink(t, ibdir + '/node_modules/ib-in', 'dep is symlink')
- noFileExists(t, ibdir + '/ib-in/node_modules/mkdirp', 'transitive dep not nested')
- t.done()
- })
- })
- t.test('transitive deps for out-of-larger module cases', function (t) {
- common.npm(['install', 'file:../ib-out'], ibconf, function (err, code, stdout) {
- if (err) throw err
- t.is(code, 0, 'command ran ok')
- if (stdout) t.comment(stdout.trim())
- noFileExists(t, ibdir + '/node_modules/minimist', 'transitive dep not flattened')
- fileExists(t, testdir + '/ib-out/node_modules/minimist', 'transitive dep nested')
- t.done()
- })
- })
- t.test('transitive deps for out-of-larger module cases w/ --preserve-symlinks', function (t) {
- rimraf.sync(ibdir + '/node_modules')
- rimraf.sync(testdir + '/ib-out/node_modules')
- var env = conf.env.extend({NODE_PRESERVE_SYMLINKS: '1'})
- common.npm(['install', 'file:../ib-out'], {cwd: ibdir, env: env}, function (err, code, stdout) {
- if (err) throw err
- t.is(code, 0, 'command ran ok')
- if (stdout) t.comment(stdout.trim())
- fileExists(t, ibdir + '/node_modules/minimist', 'transitive dep flattened')
- noFileExists(t, testdir + '/ib-out/node_modules/minimist', 'transitive dep not nested')
- t.done()
- })
- })
- t.test('tar/tgz/tar.gz should install a tarball', function (t) {
- common.npm(['install', 'file:tarball-1.0.0.tgz'], ibconf, function (err, code, stdout) {
- if (err) throw err
- t.is(code, 0, 'command ran ok')
- if (stdout) t.comment(stdout.trim())
- fileExists(t, ibdir + '/node_modules/tarball')
- t.done()
- })
- })
- t.test('non tar/tgz/tar.gz files should give good error message', function (t) {
- common.npm(['install', 'file:noext', '--json'], ibconf, function (err, code, stdout) {
- if (err) throw err
- t.not(code, 0, 'do not install files w/o extensions')
- noFileExists(t, ibdir + '/node_modules/noext')
- var result = JSON.parse(stdout)
- t.like(result, {error: {code: 'ENOLOCAL'}}, 'new type of error')
- t.done()
- })
- })
- t.test('directories without package.json should give good error message', function (t) {
- common.npm(['install', 'file:not-module', '--json'], ibconf, function (err, code, stdout) {
- if (err) throw err
- t.not(code, 0, 'error on dir w/o module')
- var result = JSON.parse(stdout)
- t.like(result, {error: {code: 'ENOLOCAL'}}, 'new type of error')
- t.done()
- })
- })
- t.test('verify preinstall step runs after finalize, such that cwd is as expected', function (t) {
- common.npm(['install', 'file:test-preinstall'], ibconf, function (err, code, stdout) {
- if (err) throw err
- t.is(code, 0, 'command ran ok')
- isSymlink(t, `${ibdir}/node_modules/test-preinstall`, 'installed as symlink')
- t.notLike(stdout, /CWD:.*[.]staging/, 'cwd should not be in staging')
-
- t.test('verify that env is as expected')
- t.done()
- })
- })
-})
-var sbdir = testdir + '/save-behavior'
-testdirContent['save-behavior'] = Dir({
- 'package.json': File({
- name: 'save-behavior',
- version: '1.0.0'
- }),
- 'npm-shrinkwrap.json': File({
- name: 'save-behavior',
- version: '1.0.0',
- dependencies: {}
- }),
- 'transitive': Dir({
- 'package.json': File({
- name: 'transitive',
- version: '1.0.0',
- dependencies: {
- 'pkgc': 'file:../../pkgc'
- }
- })
- })
-})
-testdirContent['sb-transitive'] = Dir({
- 'package.json': File({
- name: 'sb-transitive',
- version: '1.0.0',
- dependencies: {
- 'sbta': 'file:sbta'
- }
- }),
- 'sbta': Dir({
- 'package.json': File({
- name: 'sbta',
- version: '1.0.0'
- })
- })
-})
-var sbdirp = testdir + '/save-behavior-pre'
-testdirContent['save-behavior-pre'] = Dir({
- 'package.json': File({
- name: 'save-behavior',
- version: '1.0.0'
- }),
- 'npm-shrinkwrap.json': File({
- name: 'save-behavior',
- version: '1.0.0',
- dependencies: {}
- })
-})
-testdirContent['sb-transitive-preserve'] = Dir({
- 'package.json': File({
- name: 'sb-transitive-preserve',
- version: '1.0.0',
- dependencies: {
- 'sbtb': 'file:sbtb'
- }
- }),
- 'sbtb': Dir({
- 'package.json': File({
- name: 'sbtb',
- version: '1.0.0'
- })
- })
-})
-test('save behavior', function (t) {
- t.plan(6)
- var sbconf = {cwd: sbdir, env: conf.env, stdio: conf.stdio}
- t.test('to package.json and npm-shrinkwrap.json w/ abs', function (t) {
- common.npm(['install', '--save', 'file:' + testdir + '/pkga'], sbconf, function (err, code, stdout) {
- if (err) throw err
- t.is(code, 0, 'command ran ok')
- var pjson = readJson(sbdir + '/package.json')
- var shrinkwrap = readJson(sbdir + '/npm-shrinkwrap.json')
- t.is(pjson.dependencies.pkga, 'file:../pkga', 'package.json')
- var sdep = shrinkwrap.dependencies
- t.like(sdep, {pkga: {version: 'file:../pkga', resolved: null}}, 'npm-shrinkwrap.json')
- t.done()
- })
- })
- t.test('to package.json and npm-shrinkwrap.json w/ drive abs')
- t.test('to package.json and npm-shrinkwrap.json w/ rel', function (t) {
- common.npm(['install', '--save', 'file:../pkgb'], sbconf, function (err, code, stdout) {
- if (err) throw err
- t.is(code, 0, 'command ran ok')
- var pjson = readJson(sbdir + '/package.json')
- var shrinkwrap = readJson(sbdir + '/npm-shrinkwrap.json')
- t.is(pjson.dependencies.pkgb, 'file:../pkgb', 'package.json')
- var sdep = shrinkwrap.dependencies
- t.like(sdep, {pkgb: {version: 'file:../pkgb', resolved: null}}, 'npm-shrinkwrap.json')
- t.done()
- })
- })
- t.test('internal transitive dependencies of shrinkwraps', function (t) {
- common.npm(['install', '--save', 'file:transitive'], sbconf, function (err, code, stdout) {
- if (err) throw err
- t.is(code, 0, 'command ran ok')
- var pjson = readJson(sbdir + '/package.json')
- var shrinkwrap = readJson(sbdir + '/npm-shrinkwrap.json')
- t.is(pjson.dependencies.transitive, 'file:transitive', 'package.json')
- var sdep = shrinkwrap.dependencies.transitive || {}
- var tdep = shrinkwrap.dependencies.pkgc
- t.is(sdep.version, 'file:transitive', 'npm-shrinkwrap.json direct dep')
- t.is(tdep.version, 'file:../pkgc', 'npm-shrinkwrap.json transitive dep')
- t.done()
- })
- })
- t.test('external transitive dependencies of shrinkwraps', function (t) {
- common.npm(['install', '--save', 'file:../sb-transitive'], sbconf, function (err, code, stdout) {
- if (err) throw err
- t.is(code, 0, 'command ran ok')
- var pjson = readJson(sbdir + '/package.json')
- var shrinkwrap = readJson(sbdir + '/npm-shrinkwrap.json')
- var deps = pjson.dependencies || {}
- t.is(deps['sb-transitive'], 'file:../sb-transitive', 'package.json')
- var sdep = shrinkwrap.dependencies['sb-transitive'] || {}
- var tdep = sdep.dependencies.sbta
- t.like(tdep, {bundled: null, version: 'file:../sb-transitive/sbta'}, 'npm-shrinkwrap.json transitive dep')
- t.like(sdep, {bundled: null, version: 'file:../sb-transitive'}, 'npm-shrinkwrap.json direct dep')
- t.done()
- })
- })
- t.test('external transitive dependencies of shrinkwraps > preserve symlinks', function (t) {
- var preserveEnv = conf.env.extend({NODE_PRESERVE_SYMLINKS: '1'})
- var preserveConf = {cwd: sbdirp, env: preserveEnv, stdio: conf.stdio}
- common.npm(['install', '--save', 'file:../sb-transitive-preserve'], preserveConf, function (err, code, stdout) {
- if (err) throw err
- t.is(code, 0, 'command ran ok')
- var pjson = readJson(sbdirp + '/package.json')
- var shrinkwrap = readJson(sbdirp + '/npm-shrinkwrap.json')
- t.is(pjson.dependencies['sb-transitive-preserve'], 'file:../sb-transitive-preserve', 'package.json')
- var sdep = shrinkwrap.dependencies['sb-transitive-preserve'] || {}
- var tdep = shrinkwrap.dependencies.sbtb
- t.like(sdep, {bundled: null, version: 'file:../sb-transitive-preserve'}, 'npm-shrinkwrap.json direct dep')
- t.like(tdep, {bundled: null, version: 'file:../sb-transitive-preserve/sbtb'}, 'npm-shrinkwrap.json transitive dep')
- t.done()
- })
- })
-})
-
-var rmdir = testdir + '/remove-behavior'
-testdirContent['remove-behavior'] = Dir({
- 'rmsymlink': Dir({
- 'package.json': File({
- name: 'remove-behavior',
- version: '1.0.0',
- dependencies: {
- dep1: 'file:dep1'
- }
- }),
- 'package-lock.json': File({
- name: 'remove-behavior',
- version: '1.0.0',
- lockfileVersion: 1,
- requires: true,
- dependencies: {
- dep1: {
- version: 'file:dep1',
- requires: {
- dep2: 'file:dep2'
- },
- dependencies: {
- dep2: {
- version: 'file:dep2',
- bundled: true
- }
- }
- }
- }
- }),
- dep1: Dir({
- 'package.json': File({
- name: 'dep1',
- version: '1.0.0',
- dependencies: {
- dep2: 'file:../dep2'
- }
- }),
- 'node_modules': Dir({
- dep2: Symlink('../../dep2')
- })
- }),
- dep2: Dir({
- 'package.json': File({
- name: 'dep2',
- version: '1.0.0'
- })
- }),
- 'node_modules': Dir({
- dep1: Symlink('../dep1')
- })
- }),
- 'rmesymlink': Dir({
- 'package.json': File({
- name: 'remove-behavior',
- version: '1.0.0',
- dependencies: {
- edep1: 'file:../edep1'
- }
- }),
- 'package-lock.json': File({
- name: 'remove-behavior',
- version: '1.0.0',
- lockfileVersion: 1,
- requires: true,
- dependencies: {
- edep1: {
- version: 'file:../edep1',
- requires: {
- edep2: 'file:../edep2'
- },
- dependencies: {
- edep2: {
- version: 'file:../edep2',
- bundled: true
- }
- }
- }
- }
- }),
- 'node_modules': Dir({
- edep1: Symlink('../../edep1')
- })
- }),
- edep1: Dir({
- 'package.json': File({
- name: 'edep1',
- version: '1.0.0',
- dependencies: {
- edep2: 'file:../edep2'
- }
- }),
- 'node_modules': Dir({
- edep2: Symlink('../../edep2')
- })
- }),
- edep2: Dir({
- 'package.json': File({
- name: 'edep2',
- version: '1.0.0'
- })
- })
-})
-
-test('removal', function (t) {
- t.plan(2)
-
- t.test('should remove the symlink', (t) => {
- const rmconf = {cwd: `${rmdir}/rmsymlink`, env: conf.env, stdio: conf.stdio}
- return common.npm(['uninstall', 'dep1'], rmconf).spread((code, stdout) => {
- t.is(code, 0, 'uninstall ran ok')
- t.comment(stdout)
- noFileExists(t, `${rmdir}/rmsymlink/node_modules/dep1`, 'removed symlink')
- noFileExists(t, `${rmdir}/rmsymlink/dep1/node_modules/dep2`, 'removed transitive dep')
- fileExists(t, `${rmdir}/rmsymlink/dep2`, 'original transitive dep still exists')
- })
- })
- t.test("should not remove transitive deps if it's outside the package and --preserver-symlinks isn't set", (t) => {
- const rmconf = {cwd: `${rmdir}/rmesymlink`, env: conf.env, stdio: conf.stdio}
- return common.npm(['uninstall', 'edep1'], rmconf).spread((code, stdout) => {
- t.is(code, 0, 'uninstall ran ok')
- t.comment(stdout)
- noFileExists(t, `${rmdir}/rmsymlink/node_modules/edep1`, 'removed symlink')
- fileExists(t, `${rmdir}/edep1/node_modules/edep2`, 'did NOT remove transitive dep')
- fileExists(t, `${rmdir}/edep2`, 'original transitive dep still exists')
- })
- })
-})
-
-test('misc', function (t) {
- t.plan(3)
- t.test('listing: should look right, not include version')
- t.test('outdated: show LOCAL for wanted / latest')
- t.test('update: if specifier exists, do nothing. otherwise as if `npm install`.')
-})
-
-test('cleanup', function (t) {
- server.close()
- cleanup()
- t.done()
-})
diff --git a/deps/npm/test/tap/splat-with-only-prerelease-to-latest.js b/deps/npm/test/tap/splat-with-only-prerelease-to-latest.js
deleted file mode 100644
index ac2c58b5b9..0000000000
--- a/deps/npm/test/tap/splat-with-only-prerelease-to-latest.js
+++ /dev/null
@@ -1,95 +0,0 @@
-'use strict'
-
-const common = require('../common-tap.js')
-const mr = require('npm-registry-mock')
-const npm = require('../../lib/npm')
-const test = require('tap').test
-
-const testdir = common.pkg
-
-const moduleName = 'xyzzy-wibble'
-const testModule = {
- name: moduleName,
- 'dist-tags': {
- latest: '1.3.0-a',
- other: '1.2.0-a'
- },
- versions: {
- '1.0.0-a': {
- name: moduleName,
- version: '1.0.0-a',
- dist: {
- shasum: 'da39a3ee5e6b4b0d3255bfef95601890afd80709',
- tarball: 'http://registry.npmjs.org/aproba/-/xyzzy-wibble-1.0.0-a.tgz'
- }
- },
- '1.1.0-a': {
- name: moduleName,
- version: '1.1.0-a',
- dist: {
- shasum: 'da39a3ee5e6b4b0d3255bfef95601890afd80709',
- tarball: 'http://registry.npmjs.org/aproba/-/xyzzy-wibble-1.1.0-a.tgz'
- }
- },
- '1.2.0-a': {
- name: moduleName,
- version: '1.2.0-a',
- dist: {
- shasum: 'da39a3ee5e6b4b0d3255bfef95601890afd80709',
- tarball: 'http://registry.npmjs.org/aproba/-/xyzzy-wibble-1.2.0-a.tgz'
- }
- },
- '1.3.0-a': {
- name: moduleName,
- version: '1.3.0-a',
- dist: {
- shasum: 'da39a3ee5e6b4b0d3255bfef95601890afd80709',
- tarball: 'http://registry.npmjs.org/aproba/-/xyzzy-wibble-1.3.0-a.tgz'
- }
- }
- }
-}
-
-let server
-test('setup', (t) => {
- mr({port: common.port}, (er, s) => {
- if (er) throw er
- t.ok(true, 'mock registry loaded')
- server = s
- npm.load({
- loglevel: 'silent',
- registry: common.registry,
- cache: common.cache
- }, (err) => {
- if (err) { throw err }
- t.ok(true, 'npm loaded')
- t.end()
- })
- })
-})
-
-test('splat', (t) => {
- server.get('/xyzzy-wibble').reply(200, testModule)
- return npm.commands.cache.add('xyzzy-wibble', '*', testdir).then((pkg) => {
- throw new Error(`Was not supposed to succeed on ${pkg}`)
- }).catch((err) => {
- t.equal(err.code, 'E404', 'got a 404 on the tarball fetch')
- t.equal(
- err.uri,
- testModule.versions['1.3.0-a'].dist.tarball,
- 'tried to get tarball for `latest` tag'
- )
- npm.config.set('tag', 'other')
- return npm.commands.cache.add('xyzzy-wibble', '*', testdir)
- }).then((pkg) => {
- throw new Error(`Was not supposed to succeed on ${pkg}`)
- }).catch((err) => {
- t.equal(err.code, 'E404', 'got a 404 on the tarball fetch')
- t.equal(
- err.uri,
- testModule.versions['1.2.0-a'].dist.tarball,
- 'tried to get tarball for `other` tag'
- )
- server.close()
- })
-})
diff --git a/deps/npm/test/tap/startstop.js b/deps/npm/test/tap/startstop.js
deleted file mode 100644
index dd07352e0d..0000000000
--- a/deps/npm/test/tap/startstop.js
+++ /dev/null
@@ -1,61 +0,0 @@
-var fs = require('graceful-fs')
-var path = require('path')
-
-var mkdirp = require('mkdirp')
-var test = require('tap').test
-
-var common = require('../common-tap')
-
-var pkg = common.pkg
-
-var EXEC_OPTS = { cwd: pkg }
-
-var json = {
- name: 'startstop',
- version: '1.2.3',
- scripts: {
- start: 'node -e "console.log(\'start\')"',
- stop: 'node -e "console.log(\'stop\')"'
- }
-}
-
-function testOutput (t, command, er, code, stdout, stderr) {
- t.notOk(code, 'npm ' + command + ' exited with code 0')
-
- if (stderr) throw new Error('npm ' + command + ' stderr: ' + stderr.toString())
-
- stdout = stdout.trim().split(/\n|\r/)
- stdout = stdout[stdout.length - 1]
- t.equal(stdout, command)
- t.end()
-}
-
-test('setup', function (t) {
- mkdirp.sync(pkg)
- fs.writeFileSync(
- path.join(pkg, 'package.json'),
- JSON.stringify(json, null, 2)
- )
- t.end()
-})
-
-test('npm start', function (t) {
- common.npm(['start'], EXEC_OPTS, testOutput.bind(null, t, 'start'))
-})
-
-test('npm stop', function (t) {
- common.npm(['stop'], EXEC_OPTS, testOutput.bind(null, t, 'stop'))
-})
-
-test('npm restart', function (t) {
- common.npm(['restart'], EXEC_OPTS, function (er, c, stdout) {
- if (er) throw er
-
- var output = stdout.split('\n').filter(function (val) {
- return val.match(/^s/)
- })
-
- t.same(output.sort(), ['start', 'stop'].sort())
- t.end()
- })
-})
diff --git a/deps/npm/test/tap/symlink-cycle.js b/deps/npm/test/tap/symlink-cycle.js
deleted file mode 100644
index ea0c0f5359..0000000000
--- a/deps/npm/test/tap/symlink-cycle.js
+++ /dev/null
@@ -1,44 +0,0 @@
-'use strict'
-var fs = require('fs')
-var path = require('path')
-var test = require('tap').test
-var mkdirp = require('mkdirp')
-var writeFileSync = require('fs').writeFileSync
-var common = require('../common-tap.js')
-
-var base = common.pkg
-var cycle = path.join(base, 'cycle')
-
-var cycleJSON = {
- name: 'cycle',
- version: '1.0.0',
- description: '',
- main: 'index.js',
- scripts: {
- test: 'echo "Error: no test specified" && exit 1'
- },
- dependencies: {
- 'cycle': '*'
- },
- author: '',
- license: 'ISC'
-}
-
-test('setup', function (t) {
- mkdirp.sync(path.join(cycle, 'node_modules'))
- writeFileSync(
- path.join(cycle, 'package.json'),
- JSON.stringify(cycleJSON, null, 2)
- )
- fs.symlinkSync(cycle, path.join(cycle, 'node_modules', 'cycle'), 'junction')
- t.end()
-})
-
-test('ls', function (t) {
- process.chdir(cycle)
- common.npm(['ls'], {}, function (err, code, stdout, stderr) {
- t.ifError(err, 'installed w/o error')
- t.is(stderr, '', 'no warnings printed to stderr')
- t.end()
- })
-})
diff --git a/deps/npm/test/tap/tag-version-prefix.js b/deps/npm/test/tap/tag-version-prefix.js
deleted file mode 100644
index 70c968705a..0000000000
--- a/deps/npm/test/tap/tag-version-prefix.js
+++ /dev/null
@@ -1,73 +0,0 @@
-var common = require('../common-tap.js')
-var fs = require('fs')
-var path = require('path')
-
-var test = require('tap').test
-
-var npm = require('../../lib/npm.js')
-
-var pkg = common.pkg
-var npmrc = path.resolve(pkg, '.npmrc')
-var packagePath = path.resolve(pkg, 'package.json')
-
-var json = { name: 'blah', version: '0.1.2' }
-
-var configContents = 'sign-git-commit=false\nsign-git-tag=false\nmessage=":bookmark: %s"\n'
-
-test('npm version <semver> with message config', function (t) {
- setup()
-
- npm.load({ prefix: pkg, userconfig: npmrc }, function () {
- var git = require('../../lib/utils/git.js')
-
- common.makeGitRepo({ path: pkg }, function (er) {
- t.ifErr(er, 'git bootstrap ran without error')
-
- common.npm(
- [
- '--userconfig', npmrc,
- 'config',
- 'set',
- 'tag-version-prefix',
- 'q'
- ],
- { cwd: pkg, env: { PATH: process.env.PATH } },
- function (err, code, stdout, stderr) {
- t.ifError(err, 'npm config ran without issue')
- t.notOk(code, 'exited with a non-error code')
- t.notOk(stderr, 'no error output')
-
- common.npm(
- [
- 'version',
- 'patch',
- '--loglevel', 'silent'
- // package config is picked up from env
- ],
- { cwd: pkg, env: { PATH: process.env.PATH } },
- function (err, code, stdout, stderr) {
- t.ifError(err, 'npm version ran without issue')
- t.notOk(code, 'exited with a non-error code')
- t.notOk(stderr, 'no error output')
-
- git.whichAndExec(
- ['tag'],
- { cwd: pkg, env: process.env },
- function (er, tags, stderr) {
- t.ok(tags.match(/q0\.1\.3/g), 'tag was created by version' + tags)
- t.end()
- }
- )
- }
- )
- }
- )
- })
- })
-})
-
-function setup () {
- process.chdir(pkg)
- fs.writeFileSync(packagePath, JSON.stringify(json), 'utf8')
- fs.writeFileSync(npmrc, configContents, 'ascii')
-}
diff --git a/deps/npm/test/tap/tagged-version-matching.js b/deps/npm/test/tap/tagged-version-matching.js
deleted file mode 100644
index a939c21c0d..0000000000
--- a/deps/npm/test/tap/tagged-version-matching.js
+++ /dev/null
@@ -1,151 +0,0 @@
-'use strict'
-var path = require('path')
-var test = require('tap').test
-var Tacks = require('tacks')
-var File = Tacks.File
-var Dir = Tacks.Dir
-var Symlink = Tacks.Symlink
-var common = require('../common-tap.js')
-
-var basedir = common.pkg
-var testdir = path.join(basedir, 'testdir')
-var cachedir = common.cache
-var globaldir = path.join(basedir, 'global')
-var tmpdir = path.join(basedir, 'tmp')
-
-var conf = {
- cwd: testdir,
- env: Object.assign({
- npm_config_cache: cachedir,
- npm_config_tmp: tmpdir,
- npm_config_prefix: globaldir,
- npm_config_registry: common.registry,
- npm_config_loglevel: 'warn'
- }, process.env)
-}
-
-var fixture = new Tacks(Dir({
- cache: Dir(),
- global: Dir(),
- tmp: Dir(),
- testdir: Dir({
- example: Dir({
- 'package.json': File({
- dependencies: {
- tagdep: 'latest',
- gitdep: 'npm/example-gitdep'
- },
- name: 'example',
- version: '1.0.0'
- })
- }),
- node_modules: Dir({
- example: Symlink('../example'),
- gitdep: Dir({
- 'package.json': File({
- _from: 'npm/example-gitdep',
- _id: 'gitdep@1.0.0',
- _resolved: 'github:npm/example-gitdep#da39a3ee5e6b4b0d3255bfef95601890afd80709',
- name: 'gitdep',
- version: '1.0.0'
- })
- }),
- tagdep: Dir({
- 'package.json': File({
- _from: 'tagdep@latest',
- _id: 'tagdep@1.0.0',
- _integrity: 'sha1-0EJSKmsdk39848LlrRg/hZQo2B8=',
- _resolved: 'https://registry.example.com/tagdep/-/tagdep-1.0.0.tgz',
- name: 'tagdep',
- version: '1.0.0'
- })
- })
- }),
- 'npm-shrinkwrap.json': File({
- name: 'tagged-version-matching',
- version: '1.0.0',
- lockfileVersion: 1,
- requires: true,
- dependencies: {
- tagdep: {
- version: '1.0.0',
- resolved: 'https://registry.example.com/tagdep/-/tagdep-1.0.0.tgz',
- integrity: 'sha1-0EJSKmsdk39848LlrRg/hZQo2B8='
- },
- example: {
- version: 'file:example',
- requires: {
- tagdep: '^1.0.0',
- gitdep: 'github:npm/example-gitdep#da39a3ee5e6b4b0d3255bfef95601890afd80709'
- }
- },
- gitdep: {
- version: 'github:npm/example-gitdep#da39a3ee5e6b4b0d3255bfef95601890afd80709'
- }
- }
- }),
- 'package.json': File({
- name: 'tagged-version-matching',
- version: '1.0.0',
- dependencies: {
- example: 'file:example',
- gitdep: 'npm/example-gitdep'
- }
- })
- })
-}))
-
-function setup () {
- cleanup()
- fixture.create(basedir)
-}
-
-function cleanup () {
- fixture.remove(basedir)
-}
-
-test('setup', function (t) {
- setup()
- t.done()
-})
-
-test('tagged-version-matching', function (t) {
- common.npm(['ls', '--json'], conf, function (err, code, stdout, stderr) {
- if (err) throw err
- t.is(code, 0, 'command ran ok')
- if (stderr.trim()) t.comment(stderr.trim())
- var result = JSON.parse(stdout.trim())
- var expected = {
- name: 'tagged-version-matching',
- version: '1.0.0',
- dependencies: {
- example: {
- version: '1.0.0',
- dependencies: {
- gitdep: {
- version: '1.0.0',
- from: 'npm/example-gitdep'
- },
- tagdep: {
- version: '1.0.0',
- from: 'tagdep@latest'
- }
- }
- },
- gitdep: {
- version: '1.0.0',
- from: 'npm/example-gitdep'
- }
- }
- }
-
- t.like(result, expected, 'ls looks ok')
- t.is((result.problems || []).length, 0, 'no problems')
- t.done()
- })
-})
-
-test('cleanup', function (t) {
- cleanup()
- t.done()
-})
diff --git a/deps/npm/test/tap/team.js b/deps/npm/test/tap/team.js
deleted file mode 100644
index 17acf82f4b..0000000000
--- a/deps/npm/test/tap/team.js
+++ /dev/null
@@ -1,189 +0,0 @@
-var mr = require('npm-registry-mock')
-
-var test = require('tap').test
-var common = require('../common-tap.js')
-
-var server
-
-test('setup', function (t) {
- mr({port: common.port}, function (err, s) {
- t.ifError(err, 'registry mocked successfully')
- server = s
- t.end()
- })
-})
-
-test('team create basic', function (t) {
- var teamData = {
- name: 'test',
- scope_id: 1234,
- created: '2015-07-23T18:07:49.959Z',
- updated: '2015-07-23T18:07:49.959Z',
- deleted: null
- }
- server.put('/-/org/myorg/team', JSON.stringify({
- name: teamData.name,
- description: null
- })).reply(200, teamData)
- common.npm([
- 'team', 'create', 'myorg:' + teamData.name,
- '--registry', common.registry,
- '--loglevel', 'error',
- '--json'
- ], {}, function (err, code, stdout, stderr) {
- t.ifError(err, 'npm team')
- t.equal(code, 0, 'exited OK')
- t.equal(stderr, '', 'no error output')
- t.same(JSON.parse(stdout), {created: true, team: `myorg:${teamData.name}`})
- t.end()
- })
-})
-
-test('team create (allow optional @ prefix on scope)', function (t) {
- var teamData = {
- name: 'test',
- scope_id: 1234,
- created: '2015-07-23T18:07:49.959Z',
- updated: '2015-07-23T18:07:49.959Z',
- deleted: null
- }
- server.put('/-/org/myorg/team', JSON.stringify({
- name: teamData.name,
- description: null
- })).reply(200, teamData)
- common.npm([
- 'team', 'create', '@myorg:' + teamData.name,
- '--registry', common.registry,
- '--loglevel', 'silent',
- '--json'
- ], {}, function (err, code, stdout, stderr) {
- t.ifError(err, 'npm team')
- t.equal(code, 0, 'exited OK')
- t.equal(stderr, '', 'no error output')
- t.same(JSON.parse(stdout), {created: true, team: `myorg:${teamData.name}`})
- t.end()
- })
-})
-
-test('team destroy', function (t) {
- var teamData = {
- name: 'myteam',
- scope_id: 1234,
- created: '2015-07-23T18:07:49.959Z',
- updated: '2015-07-23T18:07:49.959Z',
- deleted: '2015-07-23T18:27:27.178Z'
- }
- server.delete('/-/team/myorg/' + teamData.name).reply(200, teamData)
- common.npm([
- 'team', 'destroy', 'myorg:' + teamData.name,
- '--registry', common.registry,
- '--loglevel', 'silent',
- '--json'
- ], {}, function (err, code, stdout, stderr) {
- t.ifError(err, 'npm team')
- t.equal(code, 0, 'exited OK')
- t.equal(stderr, '', 'no error output')
- t.same(JSON.parse(stdout), {deleted: true, team: `myorg:${teamData.name}`})
- t.end()
- })
-})
-
-test('team destroy is not allowed for the default developers team', (t) => {
- const teamData = {
- name: 'developers',
- scope_id: 1234,
- created: '2015-07-23T18:07:49.959Z',
- updated: '2015-07-23T18:07:49.959Z',
- deleted: '2015-07-23T18:27:27.178Z'
- }
- server.delete('/-/team/myorg/' + teamData.name).reply(405, teamData)
- common.npm([
- 'team', 'destroy', 'myorg:' + teamData.name,
- '--registry', common.registry,
- '--loglevel', 'silent',
- '--json'
- ], {}, function (err, code, stdout, stderr) {
- t.ifError(err, 'npm team')
- t.equal(code, 1, 'exited with code 1')
- t.equal(stderr, '', 'no error output')
- t.match(JSON.parse(stdout), {error: {code: 'E405'}})
- t.end()
- })
-})
-
-test('team add', function (t) {
- var user = 'zkat'
- server.put('/-/team/myorg/myteam/user', JSON.stringify({
- user: user
- })).reply(200, {})
- common.npm([
- 'team', 'add', 'myorg:myteam', user,
- '--registry', common.registry,
- '--loglevel', 'error',
- '--json'
- ], {}, function (err, code, stdout, stderr) {
- t.ifError(err, 'npm team')
- t.equal(code, 0, 'exited OK')
- t.equal(stderr, '', 'no error output')
- t.end()
- })
-})
-
-test('team rm', function (t) {
- var user = 'zkat'
- server.delete('/-/team/myorg/myteam/user', JSON.stringify({
- user: user
- })).reply(200, {})
- common.npm([
- 'team', 'rm', 'myorg:myteam', user,
- '--registry', common.registry,
- '--loglevel', 'silent',
- '--json'
- ], {}, function (err, code, stdout, stderr) {
- t.ifError(err, 'npm team')
- t.equal(code, 0, 'exited OK')
- t.equal(stderr, '', 'no error output')
- t.end()
- })
-})
-
-test('team ls (on org)', function (t) {
- var teams = ['myorg:team1', 'myorg:team2', 'myorg:team3']
- server.get('/-/org/myorg/team?format=cli').reply(200, teams)
- common.npm([
- 'team', 'ls', 'myorg',
- '--registry', common.registry,
- '--loglevel', 'silent',
- '--json'
- ], {}, function (err, code, stdout, stderr) {
- t.ifError(err, 'npm team')
- t.equal(code, 0, 'exited OK')
- t.equal(stderr, '', 'no error output')
- t.same(JSON.parse(stdout), teams)
- t.end()
- })
-})
-
-test('team ls (on team)', function (t) {
- var users = ['zkat', 'bcoe']
- server.get('/-/team/myorg/myteam/user?format=cli').reply(200, users)
- common.npm([
- 'team', 'ls', 'myorg:myteam',
- '--registry', common.registry,
- '--loglevel', 'silent',
- '--json'
- ], {}, function (err, code, stdout, stderr) {
- t.ifError(err, 'npm team')
- t.equal(code, 0, 'exited OK')
- t.equal(stderr, '', 'no error output')
- t.same(JSON.parse(stdout).sort(), users.sort())
- t.end()
- })
-})
-
-test('cleanup', function (t) {
- t.pass('cleaned up')
- server.done()
- server.close()
- t.end()
-})
diff --git a/deps/npm/test/tap/test-run-ls.js b/deps/npm/test/tap/test-run-ls.js
deleted file mode 100644
index 9475695cb6..0000000000
--- a/deps/npm/test/tap/test-run-ls.js
+++ /dev/null
@@ -1,33 +0,0 @@
-var common = require('../common-tap.js')
-var test = require('tap').test
-var path = require('path')
-var cwd = path.resolve(__dirname, '..', '..')
-var testscript = require('../../package.json').scripts.test
-var tsregexp = testscript.replace(/([[.*\]])/g, '\\$1')
-
-test('default', function (t) {
- common.npm(['run'], { cwd: cwd }, function (er, code, so) {
- if (er) throw er
- t.notOk(code)
- t.similar(so, new RegExp('\\n test\\n ' + tsregexp + '\\n'))
- t.end()
- })
-})
-
-test('parseable', function (t) {
- common.npm(['run', '-p'], { cwd: cwd }, function (er, code, so) {
- if (er) throw er
- t.notOk(code)
- t.similar(so, new RegExp('\\ntest:' + tsregexp + '\\n'))
- t.end()
- })
-})
-
-test('parseable', function (t) {
- common.npm(['run', '--json'], { cwd: cwd }, function (er, code, so) {
- if (er) throw er
- t.notOk(code)
- t.equal(JSON.parse(so).test, testscript)
- t.end()
- })
-})
diff --git a/deps/npm/test/tap/tree-style.js b/deps/npm/test/tap/tree-style.js
deleted file mode 100644
index 5d8abef369..0000000000
--- a/deps/npm/test/tap/tree-style.js
+++ /dev/null
@@ -1,127 +0,0 @@
-'use strict'
-var Bluebird = require('bluebird')
-var test = require('tap').test
-var path = require('path')
-var mkdirp = require('mkdirp')
-var rimraf = require('rimraf')
-var fs = require('graceful-fs')
-var common = require('../common-tap')
-
-var base = common.pkg
-var modA = path.resolve(base, 'modA')
-var modB = path.resolve(base, 'modB')
-var modC = path.resolve(base, 'modC')
-var testNormal = path.resolve(base, 'testNormal')
-var testGlobal = path.resolve(base, 'testGlobal')
-var testLegacy = path.resolve(base, 'testLegacy')
-
-var json = {
- 'name': 'test-tree-style',
- 'version': '1.0.0',
- 'dependencies': {
- 'modA': modA + '-1.0.0.tgz'
- }
-}
-
-var modAJson = {
- 'name': 'modA',
- 'version': '1.0.0',
- 'dependencies': {
- 'modB': modB + '-1.0.0.tgz'
- }
-}
-
-var modBJson = {
- 'name': 'modB',
- 'version': '1.0.0',
- 'dependencies': {
- 'modC': modC + '-1.0.0.tgz'
- }
-}
-
-var modCJson = {
- 'name': 'modC',
- 'version': '1.0.0'
-}
-
-function modJoin () {
- var modules = Array.prototype.slice.call(arguments)
- return modules.reduce(function (a, b) {
- return path.resolve(a, 'node_modules', b)
- })
-}
-
-function writeJson (mod, data) {
- fs.writeFileSync(path.resolve(mod, 'package.json'), JSON.stringify(data))
-}
-
-function setup () {
- cleanup()
- ;[modA, modB, modC, testNormal, testGlobal, testLegacy].forEach(function (mod) {
- mkdirp.sync(mod)
- })
- writeJson(modA, modAJson)
- writeJson(modB, modBJson)
- writeJson(modC, modCJson)
- ;[testNormal, testGlobal, testLegacy].forEach(function (mod) { writeJson(mod, json) })
-}
-
-function cleanup () {
- rimraf.sync(base)
-}
-
-test('setup', function (t) {
- setup()
- return Bluebird.try(() => {
- return common.npm(['pack', 'file:modC'], {cwd: base})
- }).spread((code) => {
- t.is(code, 0, 'pack modC')
- return common.npm(['pack', 'file:modB'], {cwd: base})
- }).spread((code) => {
- t.is(code, 0, 'pack modB')
- return common.npm(['pack', 'file:modA'], {cwd: base})
- }).spread((code) => {
- t.is(code, 0, 'pack modA')
- })
-})
-
-function exists (t, filepath, msg) {
- try {
- fs.statSync(filepath)
- t.pass(msg)
- return true
- } catch (ex) {
- t.fail(msg, {found: null, wanted: 'exists', compare: 'fs.stat(' + filepath + ')'})
- return false
- }
-}
-
-test('tree-style', function (t) {
- t.plan(12)
- common.npm(['install'], {cwd: testNormal}, function (err, code, stdout, stderr) {
- if (err) throw err
- t.is(code, 0, 'normal install; result code')
- t.is(stderr, '', 'normal install; no errors')
- exists(t, modJoin(testNormal, 'modA'), 'normal install; module A')
- exists(t, modJoin(testNormal, 'modB'), 'normal install; module B')
- exists(t, modJoin(testNormal, 'modC'), 'normal install; module C')
- })
- common.npm(['install', '--global-style'], {cwd: testGlobal}, function (err, code, stdout, stderr) {
- if (err) throw err
- t.is(code, 0, 'global-style install; result code')
- t.is(stderr, '', 'global-style install; no errors')
- exists(t, modJoin(testGlobal, 'modA', 'modB'), 'global-style install; module B')
- exists(t, modJoin(testGlobal, 'modA', 'modC'), 'global-style install; module C')
- })
- common.npm(['install', '--legacy-bundling'], {cwd: testLegacy}, function (err, code, stdout, stderr) {
- if (err) throw err
- t.is(code, 0, 'legacy-bundling install; result code')
- t.is(stderr, '', 'legacy-bundling install; no errors')
- exists(t, modJoin(testLegacy, 'modA', 'modB', 'modC'), 'legacy-bundling install; module C')
- })
-})
-
-test('cleanup', function (t) {
- cleanup()
- t.end()
-})
diff --git a/deps/npm/test/tap/umask-lifecycle.js b/deps/npm/test/tap/umask-lifecycle.js
deleted file mode 100644
index dc365c94ab..0000000000
--- a/deps/npm/test/tap/umask-lifecycle.js
+++ /dev/null
@@ -1,61 +0,0 @@
-var fs = require('fs')
-
-var mkdirp = require('mkdirp')
-var rimraf = require('rimraf')
-var test = require('tap').test
-var sprintf = require('sprintf-js').sprintf
-
-var escapeExecPath = require('../../lib/utils/escape-exec-path.js')
-var escapeArg = require('../../lib/utils/escape-arg.js')
-var common = require('../common-tap.js')
-var pkg = common.pkg
-
-var nodeCmd = escapeExecPath(common.nodeBin)
-var npmCmd = nodeCmd + ' ' + escapeArg(common.bin)
-var umaskScript = npmCmd + ' config get umask && ' + nodeCmd + ' -pe "[process.env.npm_config_umask, process.umask()]"'
-
-var pj = JSON.stringify({
- name: 'x',
- version: '1.2.3',
- scripts: { umask: umaskScript }
-}, null, 2) + '\n'
-
-var umask = process.umask()
-var expected = [
- '',
- '> x@1.2.3 umask ' + pkg,
- '> ' + umaskScript,
- '',
- sprintf('%04o', umask),
- "[ '" + sprintf('%04o', umask) + "', " +
- sprintf('%d', umask) + ' ]',
- ''
-].join('\n')
-
-test('setup', function (t) {
- rimraf.sync(pkg)
- mkdirp.sync(pkg)
- fs.writeFileSync(pkg + '/package.json', pj)
- t.end()
-})
-
-test('umask script', function (t) {
- common.npm(['run', 'umask', '--scripts-prepend-node-path'], {
- cwd: pkg,
- env: {
- PATH: process.env.PATH,
- Path: process.env.Path,
- 'npm_config_loglevel': 'warn',
- nodeExecPath: process.execPath
- }
- }, function (er, code, sout, serr) {
- t.equal(sout, expected)
- t.equal(serr, '')
- t.end()
- })
-})
-
-test('clean', function (t) {
- rimraf.sync(pkg)
- t.end()
-})
diff --git a/deps/npm/test/tap/uninstall-in-reverse.js b/deps/npm/test/tap/uninstall-in-reverse.js
deleted file mode 100644
index 5a13e904f3..0000000000
--- a/deps/npm/test/tap/uninstall-in-reverse.js
+++ /dev/null
@@ -1,38 +0,0 @@
-'use strict'
-var test = require('tap').test
-var requireInject = require('require-inject')
-var log = require('npmlog')
-
-/*
-The remove actions need to happen in the opposite of their normally defined
-order. That is, they need to go shallow -> deep.
-*/
-
-var unbuilt = []
-var npm = requireInject.installGlobally('../../lib/npm.js', {
- '../../lib/install/action/unbuild.js': function (staging, pkg, log, next) {
- unbuilt.push(pkg.package.name)
- next()
- }
-})
-
-test('setup', function (t) {
- npm.load(function () {
- t.pass('npm loaded')
- t.end()
- })
-})
-
-test('abc', function (t) {
- var Installer = require('../../lib/install.js').Installer
- var inst = new Installer(__dirname, false, [])
- inst.progress = {executeActions: log}
- inst.todo = [
- ['unbuild', {package: {name: 'first'}}],
- ['unbuild', {package: {name: 'second'}}]
- ]
- inst.executeActions(function () {
- t.isDeeply(unbuilt, ['second', 'first'])
- t.end()
- })
-})
diff --git a/deps/npm/test/tap/uninstall-link-clean.js b/deps/npm/test/tap/uninstall-link-clean.js
deleted file mode 100644
index e21c370f60..0000000000
--- a/deps/npm/test/tap/uninstall-link-clean.js
+++ /dev/null
@@ -1,113 +0,0 @@
-var fs = require('graceful-fs')
-var path = require('path')
-var existsSync = fs.existsSync || path.existsSync
-
-var mkdirp = require('mkdirp')
-var rimraf = require('rimraf')
-var test = require('tap').test
-
-var common = require('../common-tap.js')
-
-var testdir = common.pkg
-var pkg = path.join(testdir, 'pkg')
-var dep = path.join(testdir, 'dep')
-var work = path.join(testdir, 'uninstall-link-clean-TEST')
-var modules = path.join(work, 'node_modules')
-
-var EXEC_OPTS = { cwd: work, stdio: [0, 'ignore', 2] }
-
-var world = 'console.log("hello blrbld")\n'
-
-var json = {
- name: 'package',
- version: '0.0.0',
- bin: {
- hello: './world.js'
- },
- dependencies: {
- 'dep': 'file:../dep'
- }
-}
-
-var pjDep = {
- name: 'dep',
- 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(dep)
- fs.writeFileSync(
- path.join(dep, 'package.json'),
- JSON.stringify(pjDep, null, 2)
- )
- fs.writeFileSync(path.join(dep, 'world.js'), world)
-
- mkdirp.sync(modules)
-
- t.end()
-})
-
-test('installing package with links', function (t) {
- common.npm(
- [
- '--loglevel', 'error',
- '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, 'package', 'package.json')),
- 'package installed'
- )
- t.ok(existsSync(path.join(modules, '.bin')), 'binary link directory exists')
- t.ok(existsSync(path.join(modules, 'package', 'node_modules', '.bin')),
- 'nested binary link directory exists')
-
- t.end()
- }
- )
-})
-
-test('uninstalling package with links', function (t) {
- common.npm(
- [
- '--loglevel', 'error',
- 'uninstall', 'package'
- ],
- EXEC_OPTS,
- function (err, code) {
- t.ifError(err, 'uninstall ran to completion without error')
- t.notOk(code, 'npm uninstall exited with code 0')
-
- t.notOk(existsSync(path.join(modules, 'package')),
- 'package directory no longer exists')
- t.notOk(existsSync(path.join(modules, 'package', 'node_modules', '.bin')),
- 'nested binary link directory no longer exists')
-
- t.end()
- }
- )
-})
-
-test('cleanup', function (t) {
- cleanup()
- t.end()
-})
-
-function cleanup () {
- rimraf.sync(testdir)
-}
diff --git a/deps/npm/test/tap/uninstall-package.js b/deps/npm/test/tap/uninstall-package.js
deleted file mode 100644
index 3e0b404b6c..0000000000
--- a/deps/npm/test/tap/uninstall-package.js
+++ /dev/null
@@ -1,85 +0,0 @@
-var fs = require('graceful-fs')
-var path = require('path')
-
-var mr = require('npm-registry-mock')
-var test = require('tap').test
-
-var common = require('../common-tap.js')
-
-var pkg = common.pkg
-
-var EXEC_OPTS = { cwd: pkg, stdio: [0, 'pipe', 2] }
-
-var json = {
- name: 'uninstall-package',
- version: '0.0.0',
- dependencies: {
- underscore: '~1.3.1',
- request: '~0.9.0',
- '@isaacs/namespace-test': '1.x'
- }
-}
-
-test('setup', function (t) {
- fs.writeFileSync(
- path.join(pkg, 'package.json'),
- JSON.stringify(json, null, 2)
- )
- t.end()
-})
-
-test('returns a list of removed items', function (t) {
- mr({ port: common.port }, function (er, s) {
- common.npm(
- [
- '--registry', common.registry,
- '--loglevel', 'error',
- 'install', '.'
- ],
- EXEC_OPTS,
- function (err, code, stdout, stderr) {
- if (err) throw err
- t.notOk(code, 'install ran without raising error code')
- common.npm(
- [
- '--registry', common.registry,
- '--loglevel', 'error',
- '--parseable',
- 'uninstall', 'underscore', 'request', 'lala'
- ],
- EXEC_OPTS,
- function (err, code, stdout, stderr) {
- if (err) throw err
- t.notOk(code, 'uninstall ran without raising error code')
- t.has(stdout, /^remove\tunderscore\t1.3.3\t/m, 'underscore uninstalled')
- t.has(stdout, /^remove\trequest\t0.9.5\t/m, 'request uninstalled')
-
- s.close()
- t.end()
- }
- )
- }
- )
- })
-})
-
-test('does not fail if installed package lacks a name somehow', function (t) {
- const scope = path.resolve(pkg, 'node_modules/@isaacs')
- const scopePkg = path.resolve(scope, 'namespace-test')
- const pj = path.resolve(scopePkg, 'package.json')
- fs.writeFileSync(pj, JSON.stringify({
- lol: 'yolo',
- name: 99
- }))
- common.npm(
- ['uninstall', '@isaacs/namespace-test'],
- EXEC_OPTS,
- function (err, code, stdout, stderr) {
- if (err) throw err
- t.equal(code, 0, 'should exit successfully')
- t.has(stdout, /removed 1 package in/)
- t.notOk(fs.existsSync(scope), 'scoped package removed')
- t.end()
- }
- )
-})
diff --git a/deps/npm/test/tap/uninstall-save.js b/deps/npm/test/tap/uninstall-save.js
deleted file mode 100644
index bf1683edca..0000000000
--- a/deps/npm/test/tap/uninstall-save.js
+++ /dev/null
@@ -1,72 +0,0 @@
-var fs = require('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 = common.pkg
-
-var EXEC_OPTS = { cwd: pkg, stdio: [0, 'ignore', 2] }
-
-var json = {
- name: 'uninstall-save',
- version: '0.0.1'
-}
-
-test('setup', function (t) {
- mkdirp.sync(path.resolve(pkg, 'node_modules'))
- fs.writeFileSync(
- path.join(pkg, 'package.json'),
- JSON.stringify(json, null, 2)
- )
- mr({ port: common.port }, function (er, s) {
- t.ifError(er, 'started mock registry')
- t.parent.teardown(() => s.close())
- t.end()
- })
-})
-
-test('uninstall --save removes rm-ed package from package.json', function (t) {
- var config = [
- '--registry', common.registry,
- '--save-prefix', '^',
- '--save',
- '--loglevel=error'
- ]
- return common.npm(config.concat(['install', 'underscore@latest']), EXEC_OPTS).spread((code) => {
- 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'
- )
-
- var installed = path.join(pkg, 'node_modules', 'underscore')
- rimraf.sync(installed)
-
- return common.npm(config.concat(['uninstall', 'underscore']), EXEC_OPTS)
- }).spread((code) => {
- var pkgJson = JSON.parse(fs.readFileSync(
- path.join(pkg, 'package.json'),
- 'utf8'
- ))
-
- t.deepEqual(
- pkgJson.dependencies,
- { },
- 'dependency removed as expected'
- )
- })
-})
diff --git a/deps/npm/test/tap/unit-child-path.js b/deps/npm/test/tap/unit-child-path.js
deleted file mode 100644
index 902e8f5ec7..0000000000
--- a/deps/npm/test/tap/unit-child-path.js
+++ /dev/null
@@ -1,16 +0,0 @@
-'use strict'
-var test = require('tap').test
-var childPath = require('../../lib/utils/child-path.js')
-var path = require('path')
-
-test('childPath', function (t) {
- t.is(
- path.resolve(childPath('/path/to', {name: 'abc'})),
- path.resolve('/path/to/node_modules/abc'),
- 'basic use')
- t.is(
- path.resolve(childPath('/path/to', {package: {name: '@zed/abc'}})),
- path.resolve('/path/to/node_modules/@zed/abc'),
- 'scoped use')
- t.end()
-})
diff --git a/deps/npm/test/tap/unit-deps-earliestInstallable.js b/deps/npm/test/tap/unit-deps-earliestInstallable.js
deleted file mode 100644
index 47d1ab4119..0000000000
--- a/deps/npm/test/tap/unit-deps-earliestInstallable.js
+++ /dev/null
@@ -1,114 +0,0 @@
-'use strict'
-var test = require('tap').test
-var requireInject = require('require-inject')
-var npa = require('npm-package-arg')
-var log = require('npmlog')
-
-// we're just mocking to avoid having to call `npm.load`
-var deps = requireInject('../../lib/install/deps.js', {
- '../../lib/npm.js': {
- config: {
- get: function (val) { return (val === 'global-style' || val === 'legacy-bundling') ? false : 'mock' }
- },
- limit: {
- fetch: 10
- }
- }
-})
-
-var earliestInstallable = deps.earliestInstallable
-
-test('earliestInstallable should consider devDependencies', function (t) {
- var dep1 = {
- children: [],
- package: {
- name: 'dep1',
- dependencies: { dep2: '2.0.0' }
- },
- path: '/dep1',
- realpath: '/dep1'
- }
-
- // a library required by the base package
- var dep2 = {
- package: {
- name: 'dep2',
- version: '1.0.0'
- },
- path: '/dep2',
- realpath: '/dep2'
- }
-
- // an incompatible version of dep2. required by dep1
- var dep2a = {
- package: {
- name: 'dep2',
- version: '2.0.0',
- _requested: npa('dep2@2.0.0')
- },
- parent: dep1,
- path: '/dep1/node_modules/dep2a',
- realpath: '/dep1/node_modules/dep2a'
- }
-
- var pkg = {
- isTop: true,
- children: [dep1, dep2],
- package: {
- name: 'pkg',
- dependencies: { dep1: '1.0.0' },
- devDependencies: { dep2: '1.0.0' }
- },
- path: '/',
- realpath: '/'
- }
-
- dep1.parent = pkg
- dep2a.parent = dep1
- dep2.parent = pkg
-
- var earliest = earliestInstallable(dep1, dep1, dep2a.package, log)
- t.isDeeply(earliest, dep1, 'should hoist package when an incompatible devDependency is present')
- t.end()
-})
-
-test('earliestInstallable should reuse shared prod/dev deps when they are identical', function (t) {
- var dep1 = {
- children: [],
- package: {
- name: 'dep1',
- dependencies: { dep2: '1.0.0' }
- },
- path: '/dep1',
- realpath: '/dep1'
- }
-
- var dep2 = {
- package: {
- name: 'dep2',
- version: '1.0.0',
- _requested: npa('dep2@^1.0.0')
- },
- path: '/dep2',
- realpath: '/dep2'
- }
-
- var pkg = {
- isTop: true,
- children: [dep1],
- package: {
- name: 'pkg',
- dependencies: { dep1: '1.0.0' },
- devDependencies: { dep2: '^1.0.0' }
- },
- path: '/',
- realpath: '/'
- }
-
- dep1.parent = pkg
- dep2.parent = pkg
-
- var earliest = earliestInstallable(dep1, dep1, dep2.package, log)
- t.isDeeply(earliest, pkg, 'should reuse identical shared dev/prod deps when installing both')
- t.end()
-})
diff --git a/deps/npm/test/tap/unit-deps-removeObsoleteDep.js b/deps/npm/test/tap/unit-deps-removeObsoleteDep.js
deleted file mode 100644
index 71ae608637..0000000000
--- a/deps/npm/test/tap/unit-deps-removeObsoleteDep.js
+++ /dev/null
@@ -1,44 +0,0 @@
-'use strict'
-var test = require('tap').test
-var requireInject = require('require-inject')
-
-// we're just mocking to avoid having to call `npm.load`
-var deps = requireInject('../../lib/install/deps.js', {
- '../../lib/npm.js': {
- config: {
- get: function () { return 'mock' }
- },
- limit: {
- fetch: 10
- }
- }
-})
-
-var removeObsoleteDep = deps.removeObsoleteDep
-
-test('removeObsoleteDep', function (t) {
- var child1 = {requiredBy: []}
- var test1 = {
- removed: true,
- requires: [ child1 ]
- }
- removeObsoleteDep(test1)
- t.is(child1.removed, undefined, 'no recursion on deps flagged as removed already')
-
- var child2 = {requiredBy: []}
- var test2 = {
- requires: [ child2 ]
- }
- child2.requiredBy.push(test2)
- removeObsoleteDep(test2)
- t.is(child2.removed, true, 'required by no other modules, removing')
-
- var child3 = {requiredBy: [{isTop: true}]}
- var test3 = {
- requires: [ child3 ]
- }
- child3.requiredBy.push(test3)
- removeObsoleteDep(test3)
- t.is(child3.removed, undefined, 'required by other modules, keeping')
- t.done()
-})
diff --git a/deps/npm/test/tap/unit-deps-replaceModule.js b/deps/npm/test/tap/unit-deps-replaceModule.js
deleted file mode 100644
index 15cce005d5..0000000000
--- a/deps/npm/test/tap/unit-deps-replaceModule.js
+++ /dev/null
@@ -1,65 +0,0 @@
-'use strict'
-var test = require('tap').test
-var npm = require('../../lib/npm')
-
-test('setup', function (t) {
- npm.load({}, t.done)
-})
-
-test('replaceModuleByName', function (t) {
- var replaceModuleByName = require('../../lib/install/deps')._replaceModuleByName
- var mods = []
- for (var ii = 0; ii < 10; ++ii) {
- mods.push({package: {name: String(ii)}, path: '/path/to/' + ii})
- }
-
- var test = {}
- test.A = mods.slice(0, 4)
- replaceModuleByName(test, 'A', mods[2])
- t.isDeeply(test.A, mods.slice(0, 4), 'replacing an existing module leaves the order alone')
- replaceModuleByName(test, 'A', mods[7])
- t.isDeeply(test.A, mods.slice(0, 4).concat(mods[7]), 'replacing a new module appends')
-
- test.B = mods.slice(0, 4)
- var replacement = {package: {name: '1'}, isReplacement: true}
- replaceModuleByName(test, 'B', replacement)
- t.isDeeply(test.B, [mods[0], replacement, mods[2], mods[3]], 'replacing existing module swaps out for the new version')
-
- replaceModuleByName(test, 'C', mods[7])
- t.isDeeply(test.C, [mods[7]], 'replacing when the key does not exist yet, causes its creation')
-
- test.D = mods.slice(0, 4)
- var duplicateByPath = {package: {name: 'dup'}, path: test.D[0].path}
- replaceModuleByName(test, 'D', duplicateByPath)
- t.isDeeply(test.D, mods.slice(0, 4).concat(duplicateByPath), 'replacing with a duplicate path but diff names appends')
- t.end()
-})
-
-test('replaceModuleByPath', function (t) {
- var replaceModuleByPath = require('../../lib/install/deps')._replaceModuleByPath
- var mods = []
- for (var ii = 0; ii < 10; ++ii) {
- mods.push({package: {name: String(ii)}, path: '/path/to/' + ii})
- }
-
- var test = {}
- test.A = mods.slice(0, 4)
- replaceModuleByPath(test, 'A', mods[2])
- t.isDeeply(test.A, mods.slice(0, 4), 'replacing an existing module leaves the order alone')
- replaceModuleByPath(test, 'A', mods[7])
- t.isDeeply(test.A, mods.slice(0, 4).concat(mods[7]), 'replacing a new module appends')
-
- test.B = mods.slice(0, 4)
- var replacement = {package: {name: '1'}, isReplacement: true, path: '/path/to/1'}
- replaceModuleByPath(test, 'B', replacement)
- t.isDeeply(test.B, [mods[0], replacement, mods[2], mods[3]], 'replacing existing module swaps out for the new version')
-
- replaceModuleByPath(test, 'C', mods[7])
- t.isDeeply(test.C, [mods[7]], 'replacing when the key does not exist yet, causes its creation')
-
- test.D = mods.slice(0, 4)
- var duplicateByPath = {package: {name: 'dup'}, path: test.D[0].path}
- replaceModuleByPath(test, 'D', duplicateByPath)
- t.isDeeply(test.D, [duplicateByPath].concat(mods.slice(1, 4)), 'replacing with a duplicate path but diff names replaces')
- t.end()
-})
diff --git a/deps/npm/test/tap/unit-module-name.js b/deps/npm/test/tap/unit-module-name.js
deleted file mode 100644
index 59d4b44f0b..0000000000
--- a/deps/npm/test/tap/unit-module-name.js
+++ /dev/null
@@ -1,40 +0,0 @@
-'use strict'
-var test = require('tap').test
-var moduleName = require('../../lib/utils/module-name.js')
-
-test('pathToPackageName', function (t) {
- var pathToPackageName = moduleName.test.pathToPackageName
- t.is(pathToPackageName('/foo/bar/baz/bark'), 'bark', 'simple module name')
- t.is(pathToPackageName('/foo/bar/@baz/bark'), '@baz/bark', 'scoped module name')
- t.is(pathToPackageName('/foo'), 'foo', 'module at top')
- t.is(pathToPackageName('/@foo'), '@foo', 'invalid module at top')
- t.is(pathToPackageName('/'), '', 'root, empty result')
- t.is(pathToPackageName(''), '', 'empty, empty')
- t.is(pathToPackageName(undefined), '', 'undefined is empty')
- t.is(pathToPackageName(null), '', 'null is empty')
- t.done()
-})
-
-test('isNotEmpty', function (t) {
- var isNotEmpty = moduleName.test.isNotEmpty
- t.is(isNotEmpty('abc'), true, 'string is not empty')
- t.is(isNotEmpty(''), false, 'empty string is empty')
- t.is(isNotEmpty(null), false, 'null is empty')
- t.is(isNotEmpty(undefined), false, 'undefined is empty')
- t.is(isNotEmpty(0), true, 'zero is not empty')
- t.is(isNotEmpty(true), true, 'true is not empty')
- t.is(isNotEmpty([]), true, 'empty array is not empty')
- t.is(isNotEmpty({}), true, 'object is not empty')
- t.done()
-})
-
-test('moduleName', function (t) {
- t.is(moduleName({package: {name: 'foo'}}), 'foo', 'package named')
- t.is(moduleName({name: 'foo'}), 'foo', 'package named, no tree')
- t.is(moduleName({path: '/foo/bar'}), 'bar', 'path named')
- t.is(moduleName({}), '!invalid#1', 'no named')
- t.is(moduleName({path: '/'}), '!invalid#2', 'invalid named')
- var obj = {}
- t.is(moduleName(obj), moduleName(obj), 'once computed, an invalid module name will not change')
- t.done()
-})
diff --git a/deps/npm/test/tap/unit-package-id.js b/deps/npm/test/tap/unit-package-id.js
deleted file mode 100644
index 19590d82ef..0000000000
--- a/deps/npm/test/tap/unit-package-id.js
+++ /dev/null
@@ -1,17 +0,0 @@
-'use strict'
-var test = require('tap').test
-var packageId = require('../../lib/utils/package-id.js')
-
-test('packageId', function (t) {
- t.is(packageId({package: {_id: 'abc@123'}}), 'abc@123', 'basic')
- t.is(packageId({_id: 'abc@123'}), 'abc@123', 'basic no tree')
- t.is(packageId({package: {name: 'abc', version: '123'}}), 'abc@123', 'computed')
- t.is(packageId({package: {_id: '@', name: 'abc', version: '123'}}), 'abc@123', 'computed, ignore invalid id')
- t.is(packageId({package: {name: 'abc'}}), 'abc', 'no version')
- t.is(packageId({package: {version: '123'}}), '!invalid#1@123', 'version, no name')
- t.is(packageId({package: {version: '123'}, path: '/path/to/abc'}), 'abc@123', 'version path-name')
- t.is(packageId({package: {version: '123'}, path: '/path/@to/abc'}), '@to/abc@123', 'version scoped-path-name')
- t.is(packageId({path: '/path/to/abc'}), 'abc', 'path name, no version')
- t.is(packageId({}), '!invalid#2', 'nothing')
- t.done()
-})
diff --git a/deps/npm/test/tap/unit-token-validate-cidr.js b/deps/npm/test/tap/unit-token-validate-cidr.js
deleted file mode 100644
index cda91b8f1e..0000000000
--- a/deps/npm/test/tap/unit-token-validate-cidr.js
+++ /dev/null
@@ -1,18 +0,0 @@
-'use strict'
-const test = require('tap').test
-const validateCIDRList = require('../../lib/token.js')._validateCIDRList
-
-test('validateCIDRList', (t) => {
- t.plan(10)
- const single = ['127.0.0.0/24']
- const double = ['127.0.0.0/24', '192.168.0.0/16']
- const ipv6 = '2620:0:2d0:200::7/32'
- const ipv6Mixed = ['127.0.0/24', '2620:0:2d0:200::7/32', '192.168.0.0/16']
- t.doesNotThrow(() => t.isDeeply(validateCIDRList(single.join(',')), single), 'single string ipv4')
- t.doesNotThrow(() => t.isDeeply(validateCIDRList(single), single), 'single array ipv4')
- t.doesNotThrow(() => t.isDeeply(validateCIDRList(double.join(',')), double), 'double string ipv4')
- t.doesNotThrow(() => t.isDeeply(validateCIDRList(double), double), 'double array ipv4')
- t.throws(() => validateCIDRList(ipv6))
- t.throws(() => validateCIDRList(ipv6Mixed))
- t.done()
-})
diff --git a/deps/npm/test/tap/unpack-foreign-tarball.js b/deps/npm/test/tap/unpack-foreign-tarball.js
deleted file mode 100644
index b3a9026f84..0000000000
--- a/deps/npm/test/tap/unpack-foreign-tarball.js
+++ /dev/null
@@ -1,84 +0,0 @@
-var fs = require('graceful-fs')
-var path = require('path')
-
-var t = require('tap')
-var mkdirp = require('mkdirp')
-var rimraf = require('rimraf')
-
-var common = require('../common-tap.js')
-
-var fixtures = path.resolve(__dirname, '..', 'fixtures')
-
-var pkg = common.pkg
-var nm = path.resolve(pkg, 'node_modules')
-var target = path.resolve(nm, 'npm-test-gitignore')
-var cache = common.cache
-var tmp = path.resolve(pkg, 'tmp')
-
-var EXEC_OPTS = {
- env: {
- 'npm_config_cache': cache,
- 'npm_config_tmp': tmp
- },
- cwd: pkg
-}
-
-function verify (t, files, code) {
- if (code) {
- return t.fail('exited with failure: ' + code)
- }
- var actual = fs.readdirSync(target).sort()
- var expect = files.concat(['.npmignore', 'package.json']).sort()
- t.same(actual, expect)
-}
-
-t.comment('test for https://github.com/npm/npm/issues/5658')
-
-t.test('npmignore only', function (t) {
- t.test('setup', setup)
- var file = path.resolve(fixtures, 'npmignore.tgz')
- return t.test('test', t => common.npm(['install', file], EXEC_OPTS)
- .then(([code]) => verify(t, ['foo'], code)))
-})
-
-t.test('gitignore only', function (t) {
- t.test('setup', setup)
- var file = path.resolve(fixtures, 'gitignore.tgz')
- return t.test('test', t => common.npm(['install', file], EXEC_OPTS)
- .then(([code]) => verify(t, ['foo'], code)))
-})
-
-t.test('gitignore and npmignore', function (t) {
- t.test('setup', setup)
- var file = path.resolve(fixtures, 'gitignore-and-npmignore.tgz')
- return t.test('test', t => common.npm(['install', file], EXEC_OPTS)
- .then(([code]) => verify(t, ['foo', 'bar'], code)))
-})
-
-t.test('gitignore and npmignore, not gzipped 1/2', function (t) {
- t.test('setup', setup)
- var file = path.resolve(fixtures, 'gitignore-and-npmignore.tar')
- return t.test('test', t => common.npm(['install', file], EXEC_OPTS)
- .then(([code]) => verify(t, ['foo', 'bar'], code)))
-})
-
-t.test('gitignore and npmignore, not gzipped 2/2', function (t) {
- t.test('setup', setup)
- var file = path.resolve(fixtures, 'gitignore-and-npmignore-2.tar')
- return t.test('test', t => common.npm(['install', file], EXEC_OPTS)
- .then(([code]) => verify(t, ['foo', 'bar'], code)))
-})
-
-function setup (t) {
- t.test('destroy', t => {
- t.plan(2)
- t.test('node_modules', t => rimraf(nm, t.end))
- t.test('tmp', t => rimraf(tmp, t.end))
- })
- t.test('create', t => {
- mkdirp.sync(nm)
- mkdirp.sync(tmp)
- t.end()
- })
- t.end()
-}
diff --git a/deps/npm/test/tap/unpublish-config.js b/deps/npm/test/tap/unpublish-config.js
deleted file mode 100644
index 6d5c981d08..0000000000
--- a/deps/npm/test/tap/unpublish-config.js
+++ /dev/null
@@ -1,70 +0,0 @@
-var fs = require('graceful-fs')
-var http = require('http')
-var path = require('path')
-
-var test = require('tap').test
-
-var common = require('../common-tap.js')
-var pkg = common.pkg
-var fixturePath = path.join(pkg, 'fixture_npmrc')
-
-var json = {
- name: 'npm-test-unpublish-config',
- version: '1.2.3',
- publishConfig: { registry: common.registry }
-}
-
-test('setup', function (t) {
- fs.writeFileSync(
- path.join(pkg, 'package.json'),
- JSON.stringify(json), 'utf8'
- )
- fs.writeFileSync(
- fixturePath,
- '//localhost:' + common.port + '/:_authToken = beeeeeeeeeeeeef\n' +
- 'registry = http://lvh.me:4321/registry/path\n'
- )
-
- t.end()
-})
-
-test('cursory test of unpublishing with config', function (t) {
- var child
- t.plan(4)
- http.createServer(function (req, res) {
- t.pass('got request on the fakey fake registry')
- this.close()
- res.statusCode = 500
- res.end(JSON.stringify({
- error: 'shh no tears, only dreams now'
- }))
- child.kill('SIGINT')
- }).listen(common.port, function () {
- t.pass('server is listening')
-
- child = common.npm(
- [
- '--userconfig', fixturePath,
- '--loglevel', 'error',
- '--force',
- 'unpublish'
- ],
- {
- cwd: pkg,
- stdio: 'inherit',
- env: {
- 'npm_config_cache_lock_stale': 1000,
- 'npm_config_cache_lock_wait': 1000,
- HOME: process.env.HOME,
- Path: process.env.PATH,
- PATH: process.env.PATH,
- USERPROFILE: process.env.USERPROFILE
- }
- },
- function (err, code) {
- t.ifError(err, 'publish command finished successfully')
- t.notOk(code, 'npm install exited with code 0')
- }
- )
- })
-})
diff --git a/deps/npm/test/tap/unsupported.js b/deps/npm/test/tap/unsupported.js
deleted file mode 100644
index 2ebbd2d654..0000000000
--- a/deps/npm/test/tap/unsupported.js
+++ /dev/null
@@ -1,48 +0,0 @@
-'use strict'
-var test = require('tap').test
-var unsupported = require('../../lib/utils/unsupported.js')
-
-var versions = [
- // broken unsupported
- ['v0.1.103', true, true],
- ['v0.2.0', true, true],
- ['v0.3.5', true, true],
- ['v0.4.7', true, true],
- ['v0.5.3', true, true],
- ['v0.6.17', true, true],
- ['v0.7.8', true, true],
- ['v0.8.28', true, true],
- ['v0.9.6', true, true],
- ['v0.10.48', true, true],
- ['v0.11.16', true, true],
- ['v0.12.9', true, true],
- ['v1.0.1', true, true],
- ['v1.6.0', true, true],
- ['v2.3.1', true, true],
- ['v3.0.0', true, true],
- ['v4.5.0', true, true],
- ['v4.8.4', true, true],
- ['v5.7.1', true, true],
- ['v6.8.1', false, false],
- ['v7.0.0-beta23', false, true],
- ['v7.2.3', false, true],
- ['v8.4.0', false, false],
- ['v9.3.0', false, false],
- ['v10.0.0-0', false, false],
- ['v11.0.0-0', false, false],
- ['v12.0.0-0', false, false],
- ['v13.0.0-0', false, false]
-]
-
-test('versions', function (t) {
- t.plan(versions.length * 2)
- versions.forEach(function (verinfo) {
- var version = verinfo[0]
- var broken = verinfo[1]
- var unsupp = verinfo[2]
- var nodejs = unsupported.checkVersion(version)
- t.is(nodejs.broken, broken, version + ' ' + (broken ? '' : 'not ') + 'broken')
- t.is(nodejs.unsupported, unsupp, version + ' ' + (unsupp ? 'unsupported' : 'supported'))
- })
- t.done()
-})
diff --git a/deps/npm/test/tap/update-examples.js b/deps/npm/test/tap/update-examples.js
deleted file mode 100644
index 2217386de8..0000000000
--- a/deps/npm/test/tap/update-examples.js
+++ /dev/null
@@ -1,221 +0,0 @@
-var common = require('../common-tap.js')
-var test = require('tap').test
-var mkdirp = require('mkdirp')
-var mr = require('npm-registry-mock')
-var requireInject = require('require-inject')
-
-var PKG_DIR = common.pkg
-var CACHE_DIR = common.cache
-
-// ** constant templates for mocks **
-var DEFAULT_PKG = {
- 'name': 'update-examples',
- 'version': '1.2.3',
- 'dependencies': {
- 'dep1': '*'
- }
-}
-
-var DEP_PKG = {
- name: 'dep1',
- version: '1.1.1',
- _from: '^1.1.1'
-}
-
-var INSTALLED = {
- path: '/mock/root',
- realpath: '/mock/root',
- isLink: false,
- package: DEFAULT_PKG,
- children: [
- {
- path: '/mock/root/node_modules/dep1',
- realpath: '/mock/root/node_modules/dep1',
- isLink: false,
- package: DEP_PKG,
- children: []
- }
- ]
-}
-
-var DEP1_REGISTRY = { name: 'dep1',
- 'dist-tags': { latest: '1.2.2' },
- versions: {
- '1.2.2': { version: '1.2.2' },
- '1.2.1': { version: '1.2.1' },
- '1.2.0': { version: '1.2.0' },
- '1.1.2': { version: '1.1.2' },
- '1.1.1': { version: '1.1.1' },
- '1.0.0': { version: '1.0.0' },
- '0.4.1': { version: '0.4.1' },
- '0.4.0': { version: '0.4.0' },
- '0.2.0': { version: '0.2.0' }
- }
-}
-
-var registryMocks = {
- 'get': {
- '/dep1': [200, DEP1_REGISTRY]
- }
-}
-
-// ** dynamic mocks, cloned from templates and modified **
-var mockDepJson = clone(DEP_PKG)
-var mockInstalled = clone(INSTALLED)
-var mockParentJson = clone(DEFAULT_PKG)
-
-// target
-var installAskedFor
-
-function clone (a) {
- return extend({}, a)
-}
-
-function extend (a, b) {
- for (var key in b) {
- a[key] = b[key]
- }
- return a
-}
-
-const path = require('path')
-let cacheIteration = 0
-const isRoot = process.getuid && process.getuid() === 0
-const sudoUID = isRoot ? +process.env.SUDO_UID : null
-const sudoGID = isRoot ? +process.env.SUDO_GID : null
-const { chownSync } = require('fs')
-function resetPackage (options) {
- CACHE_DIR = path.resolve(common.cache, '' + cacheIteration++)
- npm.config.set('cache', CACHE_DIR)
- mkdirp.sync(CACHE_DIR)
-
- if (isRoot && sudoUID && sudoGID) {
- chownSync(CACHE_DIR, sudoUID, sudoGID)
- }
-
- installAskedFor = undefined
-
- mockParentJson = clone(DEFAULT_PKG)
- mockInstalled = clone(INSTALLED)
- mockDepJson = clone(DEP_PKG)
-
- if (options.wanted) {
- mockParentJson.dependencies.dep1 = options.wanted
- mockInstalled.package.dependencies.dep1 = options.wanted
- mockDepJson._from = options.wanted
- }
-
- if (options.installed) {
- mockInstalled.package.dependencies.dep1 = options.installed
- mockInstalled.children[0].package.version = options.installed
- mockDepJson.version = options.installed
- }
-}
-
-function mockReadPackageTree (dir, cb) {
- cb(null, mockInstalled)
-}
-
-function mockReadJson (file, cb) {
- cb(null, file.match(/dep1/) ? mockDepJson : mockParentJson)
-}
-
-function mockCommand (npm, name, fn) {
- delete npm.commands[name]
- npm.commands[name] = fn
-}
-
-function mockInstaller (where, dryrun, what) {
- installAskedFor = what[0]
-}
-mockInstaller.prototype = {}
-mockInstaller.prototype.run = function (cb) {
- return cb ? cb() : Promise.resolve()
-}
-
-var npm = requireInject.installGlobally('../../lib/npm.js', {
- 'read-package-tree': mockReadPackageTree,
- 'read-package-json': mockReadJson,
- '../../lib/install': {
- Installer: mockInstaller
- }
-})
-
-test('setup', function (t) {
- t.plan(5)
- process.chdir(PKG_DIR)
- t.pass('made ' + PKG_DIR)
-
- mr({ port: common.port, mocks: registryMocks }, function (er, server) {
- t.pass('mock registry active')
- npm.load({
- cache: CACHE_DIR,
- registry: common.registry,
- cwd: PKG_DIR
- }, function (err) {
- t.ifError(err, 'started server')
- t.parent.teardown(() => server.close())
-
- t.pass('npm.load complete')
-
- mockCommand(npm, 'install', function mockInstall (where, what, cb) {
- installAskedFor = what
- cb(null)
- })
-
- t.pass('mocks configured')
- t.end()
- })
- })
-})
-
-test('update caret dependency to latest', function (t) {
- resetPackage({ wanted: '^1.1.1' })
-
- npm.config.set('loglevel', 'silly')
- npm.commands.update([], function (err) {
- t.ifError(err)
- t.equal(installAskedFor, 'dep1@1.2.2', 'should want to install dep@1.2.2')
- t.end()
- })
-})
-
-test('update tilde dependency to latest', function (t) {
- resetPackage({ wanted: '~1.1.1' })
-
- npm.commands.update([], function (err) {
- t.ifError(err)
- t.equal(installAskedFor, 'dep1@1.1.2', 'should want to install dep@1.1.2')
- t.end()
- })
-})
-
-test('hold tilde dependency at wanted (#6441)', function (t) {
- resetPackage({ wanted: '~1.1.2', installed: '1.1.2' })
-
- npm.commands.update([], function (err) {
- t.ifError(err)
- t.notOk(installAskedFor, 'should not want to install anything')
- t.end()
- })
-})
-
-test('update old caret dependency with no newer', function (t) {
- resetPackage({ wanted: '^0.2.0', installed: '^0.2.0' })
-
- npm.commands.update([], function (err) {
- t.ifError(err)
- t.equal(installAskedFor, 'dep1@0.2.0', 'should want to install dep@0.2.0')
- t.end()
- })
-})
-
-test('update old caret dependency with newer', function (t) {
- resetPackage({ wanted: '^0.4.0', installed: '^0.4.0' })
-
- npm.commands.update([], function (err) {
- t.ifError(err)
- t.equal(installAskedFor, 'dep1@0.4.1', 'should want to install dep@0.4.1')
- t.end()
- })
-})
diff --git a/deps/npm/test/tap/update-path.js b/deps/npm/test/tap/update-path.js
deleted file mode 100644
index 1578669a25..0000000000
--- a/deps/npm/test/tap/update-path.js
+++ /dev/null
@@ -1,35 +0,0 @@
-'use strict'
-var test = require('tap').test
-var requireInject = require('require-inject')
-
-var mockNpm = {
- config: {
- get: function (key) {
- return false
- }
- },
- commands: {
- outdated: function (args, silent, cb) {
- cb(null, [
- [{path: '/incorrect', parent: {path: '/correct'}}, 'abc', '1.0.0', '1.1.0', '1.1.0', '^1.1.0']
- ])
- }
- }
-}
-
-// What we're testing here is that updates use the parent module's path to
-// install from.
-test('update', function (t) {
- var update = requireInject('../../lib/update.js', {
- '../../lib/npm.js': mockNpm,
- '../../lib/install.js': {
- 'Installer': function (where, dryrun, args) {
- t.is(where, '/correct', 'We should be installing to the parent of the modules being updated')
- this.run = function (cb) { cb() }
- }
- }
- })
- update(['abc'], function () {
- t.end()
- })
-})
diff --git a/deps/npm/test/tap/update-symlink.js b/deps/npm/test/tap/update-symlink.js
deleted file mode 100644
index eda07c56e1..0000000000
--- a/deps/npm/test/tap/update-symlink.js
+++ /dev/null
@@ -1,109 +0,0 @@
-'use strict'
-const path = require('path')
-const test = require('tap').test
-const mr = require('npm-registry-mock')
-const Tacks = require('tacks')
-const File = Tacks.File
-const Symlink = Tacks.Symlink
-const Dir = Tacks.Dir
-const common = require('../common-tap.js')
-
-const basedir = common.pkg
-const testdir = path.join(basedir, 'testdir')
-const cachedir = common.cache
-const globaldir = path.join(basedir, 'global')
-const tmpdir = path.join(basedir, 'tmp')
-
-const conf = {
- cwd: path.join(testdir, 'main'),
- env: Object.assign({}, process.env, {
- npm_config_cache: cachedir,
- npm_config_tmp: tmpdir,
- npm_config_prefix: globaldir,
- npm_config_registry: common.registry,
- npm_config_loglevel: 'warn'
- })
-}
-
-let server
-const fixture = new Tacks(Dir({
- cache: Dir(),
- global: Dir(),
- tmp: Dir(),
- testdir: Dir({
- broken: Dir({
- 'package.json': File({
- name: 'broken',
- version: '1.0.0'
- })
- }),
- main: Dir({
- node_modules: Dir({
- unbroken: Symlink('/testdir/unbroken')
- }),
- 'package-lock.json': File({
- name: 'main',
- version: '1.0.0',
- lockfileVersion: 1,
- requires: true,
- dependencies: {
- broken: {
- version: 'file:../broken'
- },
- unbroken: {
- version: 'file:../unbroken'
- }
- }
- }),
- 'package.json': File({
- name: 'main',
- version: '1.0.0',
- dependencies: {
- broken: 'file:../broken',
- unbroken: 'file:../unbroken'
- }
- })
- }),
- unbroken: Dir({
- 'package.json': File({
- name: 'unbroken',
- version: '1.0.0'
- })
- })
- })
-}))
-
-function setup () {
- cleanup()
- fixture.create(basedir)
-}
-
-function cleanup () {
- fixture.remove(basedir)
-}
-
-test('setup', function (t) {
- setup()
- mr({port: common.port, throwOnUnmatched: true}, function (err, s) {
- if (err) throw err
- server = s
- t.done()
- })
-})
-
-test('update fixes broken links', function (t) {
- common.npm(['update'], conf, function (err, code, stdout, stderr) {
- if (err) throw err
- t.is(code, 0, 'command ran ok')
- t.comment(stdout.trim())
- t.comment(stderr.trim())
- t.match(stdout, '+ broken@1.0.0')
- t.done()
- })
-})
-
-test('cleanup', function (t) {
- server.close()
- cleanup()
- t.done()
-})
diff --git a/deps/npm/test/tap/upgrade-lifecycles.js b/deps/npm/test/tap/upgrade-lifecycles.js
deleted file mode 100644
index 0821cacba6..0000000000
--- a/deps/npm/test/tap/upgrade-lifecycles.js
+++ /dev/null
@@ -1,88 +0,0 @@
-'use strict'
-var path = require('path')
-var test = require('tap').test
-var Tacks = require('tacks')
-var File = Tacks.File
-var Dir = Tacks.Dir
-var common = require('../common-tap.js')
-
-var basedir = common.pkg
-var testdir = path.join(basedir, 'testdir')
-var cachedir = common.cache
-var globaldir = path.join(basedir, 'global')
-var tmpdir = path.join(basedir, 'tmp')
-
-var conf = {
- cwd: testdir,
- env: Object.assign({
- npm_config_cache: cachedir,
- npm_config_tmp: tmpdir,
- npm_config_prefix: globaldir,
- npm_config_registry: common.registry,
- npm_config_loglevel: 'warn'
- }, process.env)
-}
-
-var cycler = {
- name: 'cycler',
- version: '1.0.0',
- scripts: {
- uninstall: 'echo #UNINSTALL#',
- install: 'echo #INSTALL#'
- }
-}
-
-var fixture = new Tacks(Dir({
- cache: Dir(),
- global: Dir(),
- tmp: Dir(),
- testdir: Dir({
- 'cycler': Dir({
- 'package.json': File(cycler)
- }),
- node_modules: Dir({
- 'cycler': Dir({
- 'package.json': File(cycler)
- })
- }),
- 'package.json': File({
- name: 'upgrade-lifecycles',
- version: '1.0.0',
- dependencies: {
- 'cycler': 'file:cycler'
- }
- })
- })
-}))
-
-function setup () {
- cleanup()
- fixture.create(basedir)
-}
-
-function cleanup () {
- fixture.remove(basedir)
-}
-
-test('setup', function (t) {
- setup()
- t.done()
-})
-
-test('upgrade-lifecycles', function (t) {
- common.npm(['install', 'file:cycler'], conf, function (err, code, stdout, stderr) {
- if (err) throw err
- t.is(code, 0, 'command ran ok')
-
- t.comment(stdout.trim())
- t.comment(stderr.trim())
- t.match(stdout, /#INSTALL#/, 'ran install lifecycle')
- t.match(stdout, /#UNINSTALL#/, 'ran uninstall lifecycle')
- t.done()
- })
-})
-
-test('cleanup', function (t) {
- cleanup()
- t.done()
-})
diff --git a/deps/npm/test/tap/url-dependencies.js b/deps/npm/test/tap/url-dependencies.js
deleted file mode 100644
index 14da5d1fc4..0000000000
--- a/deps/npm/test/tap/url-dependencies.js
+++ /dev/null
@@ -1,61 +0,0 @@
-var fs = require('graceful-fs')
-var path = require('path')
-
-var mr = require('npm-registry-mock')
-var test = require('tap').test
-
-var common = require('../common-tap')
-
-var pkg = common.pkg
-
-var json = {
- author: 'Steve Mason',
- name: 'url-dependencies',
- version: '0.0.0',
- dependencies: {
- underscore: common.registry + '/underscore/-/underscore-1.3.1.tgz'
- }
-}
-
-var mockRoutes = {
- 'get': {
- '/underscore/-/underscore-1.3.1.tgz': [200]
- }
-}
-
-const tarballWasFetched = output => output.includes(
- `GET 200 ${common.registry}/underscore/-/underscore-1.3.1.tgz`)
-
-const performInstall = () => common.npm(['install'], {
- cwd: pkg,
- env: {
- npm_config_registry: common.registry,
- npm_config_cache_lock_stale: 1000,
- npm_config_cache_lock_wait: 1000,
- npm_config_loglevel: 'http',
- HOME: process.env.HOME,
- Path: process.env.PATH,
- PATH: process.env.PATH
- }
-})
-
-test('setup', function (t) {
- fs.writeFileSync(
- path.join(pkg, 'package.json'),
- JSON.stringify(json, null, 2)
- )
- mr({ port: common.port, mocks: mockRoutes }, function (er, s) {
- t.parent.teardown(() => s.close())
- t.end()
- })
-})
-
-test('url-dependencies: download first time', t =>
- performInstall().then(([code, _, output]) => {
- t.equal(code, 0, 'exited successfully')
- t.ok(tarballWasFetched(output), 'download first time')
- })
- .then(() => performInstall()).then(([code, _, output]) => {
- t.equal(code, 0, 'exited successfully')
- t.notOk(tarballWasFetched(output), 'do not download second time')
- }))
diff --git a/deps/npm/test/tap/utils.funding.js b/deps/npm/test/tap/utils.funding.js
deleted file mode 100644
index 4276f3e43a..0000000000
--- a/deps/npm/test/tap/utils.funding.js
+++ /dev/null
@@ -1,657 +0,0 @@
-'use strict'
-
-const { test } = require('tap')
-const { retrieveFunding, getFundingInfo } = require('../../lib/utils/funding')
-
-test('empty tree', (t) => {
- t.deepEqual(
- getFundingInfo({}),
- {
- name: null,
- dependencies: {},
- length: 0
- },
- 'should return empty list'
- )
- t.end()
-})
-
-test('single item missing funding', (t) => {
- t.deepEqual(
- getFundingInfo({ name: 'project',
- dependencies: {
- 'single-item': {
- name: 'single-item',
- version: '1.0.0'
- }
- }}),
- {
- name: 'project',
- dependencies: {},
- length: 0
- },
- 'should return empty list'
- )
- t.end()
-})
-
-test('funding object missing url', (t) => {
- t.deepEqual(
- getFundingInfo({ name: 'project',
- dependencies: {
- 'single-item': {
- name: 'single-item',
- version: '1.0.0',
- funding: {
- type: 'Foo'
- }
- }
- }}),
- {
- name: 'project',
- dependencies: {},
- length: 0
- },
- 'should return empty list'
- )
- t.end()
-})
-
-test('use path if name is missing', (t) => {
- t.deepEqual(
- getFundingInfo({ name: undefined,
- path: '/tmp/foo',
- children: {
- 'single-item': {
- name: 'single-item',
- version: '1.0.0'
- }
- }}),
- {
- name: '/tmp/foo',
- dependencies: {},
- length: 0
- },
- 'should use path as top level name'
- )
- t.end()
-})
-
-test('single item tree', (t) => {
- t.deepEqual(
- getFundingInfo({ name: 'project',
- dependencies: {
- 'single-item': {
- name: 'single-item',
- version: '1.0.0',
- funding: {
- type: 'foo',
- url: 'http://example.com'
- }
- }
- }}),
- {
- name: 'project',
- dependencies: {
- 'single-item': {
- version: '1.0.0',
- funding: {
- type: 'foo',
- url: 'http://example.com'
- }
- }
- },
- length: 1
- },
- 'should return list with a single item'
- )
- t.end()
-})
-
-test('top-level funding info', (t) => {
- t.deepEqual(
- getFundingInfo({ name: 'project',
- funding: 'http://example.com'
- }),
- {
- name: 'project',
- funding: {
- url: 'http://example.com'
- },
- dependencies: {},
- length: 0
- },
- 'should return top-level item with normalized funding info'
- )
- t.end()
-})
-
-test('use string shorthand', (t) => {
- t.deepEqual(
- getFundingInfo({ name: 'project',
- dependencies: {
- 'single-item': {
- name: 'single-item',
- version: '1.0.0',
- funding: 'http://example.com'
- }
- }}),
- {
- name: 'project',
- dependencies: {
- 'single-item': {
- version: '1.0.0',
- funding: {
- url: 'http://example.com'
- }
- }
- },
- length: 1
- },
- 'should return item with normalized funding info'
- )
- t.end()
-})
-
-test('duplicate items along the tree', (t) => {
- t.deepEqual(
- getFundingInfo({ name: 'project',
- version: '2.3.4',
- dependencies: {
- 'single-item': {
- name: 'single-item',
- version: '1.0.0',
- funding: {
- type: 'foo',
- url: 'https://example.com'
- },
- dependencies: {
- 'shared-top-first': {
- name: 'shared-top-first',
- version: '1.0.0',
- funding: {
- type: 'foo',
- url: 'https://example.com'
- }
- },
- 'sub-dep': {
- name: 'sub-dep',
- version: '1.0.0',
- funding: {
- type: 'foo',
- url: 'https://example.com'
- },
- dependencies: {
- 'shared-nested-first': {
- name: 'shared-nested-first',
- version: '1.0.0',
- funding: {
- type: 'foo',
- url: 'https://example.com'
- },
- dependencies: {
- 'shared-top-first': {
- name: 'shared-top-first',
- version: '1.0.0',
- funding: {
- type: 'foo',
- url: 'https://example.com'
- }
- }
- }
- }
- }
- },
- 'shared-nested-first': {
- name: 'shared-nested-first',
- version: '1.0.0',
- funding: {
- type: 'foo',
- url: 'https://example.com'
- }
- }
- }
- }
- }}),
- {
- name: 'project',
- version: '2.3.4',
- dependencies: {
- 'single-item': {
- version: '1.0.0',
- funding: {
- type: 'foo',
- url: 'https://example.com'
- },
- dependencies: {
- 'shared-top-first': {
- version: '1.0.0',
- funding: {
- type: 'foo',
- url: 'https://example.com'
- }
- },
- 'sub-dep': {
- version: '1.0.0',
- funding: {
- type: 'foo',
- url: 'https://example.com'
- }
- },
- 'shared-nested-first': {
- version: '1.0.0',
- funding: {
- type: 'foo',
- url: 'https://example.com'
- }
- }
- }
- }
- },
- length: 4
- },
- 'should return list with a single item'
- )
- t.end()
-})
-
-test('multi-level nested items tree', (t) => {
- t.deepEqual(
- getFundingInfo({ name: 'project',
- dependencies: {
- 'first-level-dep': {
- name: 'first-level-dep',
- version: '1.0.0',
- funding: {
- type: 'foo',
- url: 'https://example.com'
- },
- dependencies: {
- 'sub-dep': {
- name: 'sub-dep',
- version: '1.0.0',
- funding: {
- type: 'foo',
- url: 'https://example.com'
- },
- dependencies: {
- package: {
- name: 'sub-sub-dep',
- version: '1.0.0',
- funding: {
- type: 'foo',
- url: 'https://example.com'
- },
- dependencies: {}
- }
- }
- }
- }
- }
- }}),
- {
- name: 'project',
- dependencies: {
- 'first-level-dep': {
- version: '1.0.0',
- funding: {
- type: 'foo',
- url: 'https://example.com'
- },
- dependencies: {
- 'sub-dep': {
- version: '1.0.0',
- funding: {
- type: 'foo',
- url: 'https://example.com'
- },
- dependencies: {
- 'sub-sub-dep': {
- version: '1.0.0',
- funding: {
- type: 'foo',
- url: 'https://example.com'
- }
- }
- }
- }
- }
- }
- },
- length: 3
- },
- 'should return list with all items'
- )
- t.end()
-})
-
-test('missing fund nested items tree', (t) => {
- t.deepEqual(
- getFundingInfo({ name: 'project',
- dependencies: {
- 'first-level-dep': {
- name: 'first-level-dep',
- version: '1.0.0',
- funding: {
- type: 'foo'
- },
- dependencies: {
- 'sub-dep': {
- name: 'sub-dep',
- version: '1.0.0',
- dependencies: {
- 'sub-sub-dep-01': {
- name: 'sub-sub-dep-01',
- version: '1.0.0',
- funding: {
- type: 'foo',
- url: 'https://example.com'
- },
- dependencies: {
- 'non-funding-child': {
- name: 'non-funding-child',
- version: '1.0.0',
- dependencies: {
- 'sub-sub-sub-dep': {
- name: 'sub-sub-sub-dep',
- version: '1.0.0',
- funding: {
- type: 'foo',
- url: 'https://example.com'
- }
- }
- }
- }
- }
- },
- 'sub-sub-dep-02': {
- name: 'sub-sub-dep-02',
- version: '1.0.0',
- funding: {
- type: 'foo',
- url: 'https://example.com'
- },
- dependencies: {}
- },
- 'sub-sub-dep-03': {
- name: 'sub-sub-dep-03',
- version: '1.0.0',
- funding: {
- type: 'foo',
- url: 'git://example.git'
- },
- dependencies: {
- 'sub-sub-sub-dep-03': {
- name: 'sub-sub-sub-dep-03',
- version: '1.0.0',
- dependencies: {
- 'sub-sub-sub-sub-dep': {
- name: 'sub-sub-sub-sub-dep',
- version: '1.0.0',
- funding: {
- type: 'foo',
- url: 'http://example.com'
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }}),
- {
- name: 'project',
- dependencies: {
- 'sub-sub-dep-01': {
- version: '1.0.0',
- funding: {
- type: 'foo',
- url: 'https://example.com'
- },
- dependencies: {
- 'sub-sub-sub-dep': {
- version: '1.0.0',
- funding: {
- type: 'foo',
- url: 'https://example.com'
- }
- }
- }
- },
- 'sub-sub-dep-02': {
- version: '1.0.0',
- funding: {
- type: 'foo',
- url: 'https://example.com'
- }
- },
- 'sub-sub-sub-sub-dep': {
- version: '1.0.0',
- funding: {
- type: 'foo',
- url: 'http://example.com'
- }
- }
- },
- length: 4
- },
- 'should return list excluding missing funding items'
- )
- t.end()
-})
-
-test('countOnly option', (t) => {
- t.deepEqual(
- getFundingInfo({ name: 'project',
- dependencies: {
- 'first-level-dep': {
- name: 'first-level-dep',
- version: '1.0.0',
- funding: {
- type: 'foo'
- },
- dependencies: {
- 'sub-dep': {
- name: 'sub-dep',
- version: '1.0.0',
- funding: {
- type: 'foo',
- url: 'https://example.com'
- },
- dependencies: {
- 'sub-sub-dep': {
- name: 'sub-sub-dep',
- version: '1.0.0',
- funding: {
- type: 'foo',
- url: 'https://example.com'
- }
- },
- dependencies: {}
- }
- },
- 'sub-sub-dep': {
- name: 'sub-sub-dep',
- version: '1.0.0',
- funding: {
- type: 'foo',
- url: 'https://example.com'
- }
- }
- }
- }
- }}, { countOnly: true }),
- {
- length: 2
- },
- 'should return only the length property'
- )
- t.end()
-})
-
-test('handle different versions', (t) => {
- t.deepEqual(
- getFundingInfo({ name: 'project',
- dependencies: {
- foo: {
- name: 'foo',
- version: '1.0.0',
- funding: {
- type: 'foo',
- url: 'https://example.com'
- },
- dependencies: {
- bar: {
- name: 'bar',
- version: '1.0.0',
- funding: {
- type: 'foo',
- url: 'https://example.com'
- }
- }
- }
- },
- lorem: {
- dependencies: {
- fooo: {
- name: 'foo',
- version: '2.0.0',
- funding: {
- type: 'foo',
- url: 'https://example.com'
- },
- dependencies: {
- 'foo-bar': {
- name: 'foo-bar',
- version: '1.0.0',
- funding: {
- type: 'foo',
- url: 'https://example.com'
- }
- }
- }
- }
- }
- }
- }
- }, { countOnly: true }),
- {
- length: 4
- },
- 'should treat different versions as diff packages'
- )
- t.end()
-})
-
-test('retrieve funding info from valid objects', (t) => {
- t.deepEqual(
- retrieveFunding({
- url: 'http://example.com',
- type: 'Foo'
- }),
- {
- url: 'http://example.com',
- type: 'Foo'
- },
- 'should return standard object fields'
- )
- t.deepEqual(
- retrieveFunding({
- extra: 'Foo',
- url: 'http://example.com',
- type: 'Foo'
- }),
- {
- extra: 'Foo',
- url: 'http://example.com',
- type: 'Foo'
- },
- 'should leave untouched extra fields'
- )
- t.deepEqual(
- retrieveFunding({
- url: 'http://example.com'
- }),
- {
- url: 'http://example.com'
- },
- 'should accept url-only objects'
- )
- t.end()
-})
-
-test('retrieve funding info from invalid objects', (t) => {
- t.deepEqual(
- retrieveFunding({}),
- {},
- 'should passthrough empty objects'
- )
- t.deepEqual(
- retrieveFunding(),
- undefined,
- 'should not care about undefined'
- )
- t.deepEqual(
- retrieveFunding(),
- null,
- 'should not care about null'
- )
- t.end()
-})
-
-test('retrieve funding info string shorthand', (t) => {
- t.deepEqual(
- retrieveFunding('http://example.com'),
- {
- url: 'http://example.com'
- },
- 'should accept string shorthand'
- )
- t.end()
-})
-
-test('retrieve funding info from an array', (t) => {
- t.deepEqual(
- retrieveFunding([
- 'http://example.com',
- {
- url: 'http://two.example.com'
- },
- 'http://three.example.com',
- {
- url: 'http://three.example.com',
- type: 'dos'
- },
- {
- url: 'http://three.example.com',
- type: 'third copy!',
- extra: 'extra metadata!'
- }
- ]),
- [
- {
- url: 'http://example.com'
- },
- {
- url: 'http://two.example.com'
- },
- {
- url: 'http://three.example.com'
- },
- {
- url: 'http://three.example.com',
- type: 'dos'
- },
- {
- url: 'http://three.example.com',
- type: 'third copy!',
- extra: 'extra metadata!'
- }
- ],
- 'should accept and normalize multiple funding sources'
- )
- t.end()
-})
diff --git a/deps/npm/test/tap/verify-no-lifecycle-on-repo.js b/deps/npm/test/tap/verify-no-lifecycle-on-repo.js
deleted file mode 100644
index c9232715a7..0000000000
--- a/deps/npm/test/tap/verify-no-lifecycle-on-repo.js
+++ /dev/null
@@ -1,73 +0,0 @@
-'use strict'
-var path = require('path')
-var fs = require('graceful-fs')
-var mkdirp = require('mkdirp')
-var rimraf = require('rimraf')
-var test = require('tap').test
-var requireInject = require('require-inject')
-const common = require('../common-tap.js')
-
-var base = common.pkg
-
-var baseJSON = {
- name: 'base',
- version: '1.0.0',
- repository: {
- type: 'git',
- url: 'http://example.com'
- },
- scripts: {
- prepublish: 'false'
- }
-}
-
-var lastOpened
-var npm = requireInject.installGlobally('../../lib/npm.js', {
- '../../lib/utils/lifecycle.js': function (pkg, stage, wd, moreOpts, cb) {
- if (typeof moreOpts === 'function') {
- cb = moreOpts
- }
-
- cb(new Error("Shouldn't be calling lifecycle scripts"))
- },
- opener: function (url, options, cb) {
- lastOpened = {url: url, options: options}
- cb()
- }
-})
-
-test('setup', function (t) {
- cleanup()
- setup()
- t.end()
-})
-
-test('repo', function (t) {
- process.chdir(base)
- npm.load({browser: 'echo'}, function () {
- npm.commands.repo([], function (err) {
- t.ifError(err, 'no errors')
- t.match(lastOpened.url, baseJSON.repository.url, 'opened the right url')
- t.is(lastOpened.options.command, 'echo', 'opened with a specified browser')
- t.end()
- })
- })
-})
-
-test('cleanup', function (t) {
- cleanup()
- t.end()
-})
-
-function saveJson (pkgPath, json) {
- mkdirp.sync(pkgPath)
- fs.writeFileSync(path.join(pkgPath, 'package.json'), JSON.stringify(json, null, 2))
-}
-
-function setup () {
- saveJson(base, baseJSON)
-}
-
-function cleanup () {
- rimraf.sync(base)
-}
diff --git a/deps/npm/test/tap/version-allow-same-version.js b/deps/npm/test/tap/version-allow-same-version.js
deleted file mode 100644
index 14506aac7d..0000000000
--- a/deps/npm/test/tap/version-allow-same-version.js
+++ /dev/null
@@ -1,70 +0,0 @@
-const fs = require('graceful-fs')
-const path = require('path')
-const t = require('tap')
-const common = require('../common-tap.js')
-const npm = require('../../')
-const pkg = common.pkg
-const cache = common.cache
-const npmrc = path.resolve(pkg, './.npmrc')
-const configContents = 'sign-git-tag=false\n'
-
-t.test('setup', t => {
- process.chdir(pkg)
- fs.writeFileSync(npmrc, configContents, 'ascii')
- fs.writeFileSync(path.resolve(pkg, 'package.json'), JSON.stringify({
- author: 'Lucas Theisen',
- name: 'version-allow-same-version',
- version: '0.0.1',
- description: 'Test for npm version without --allow-same-version'
- }), 'utf8')
- npm.load({cache: cache, 'allow-same-version': false, registry: common.registry}, t.end)
-})
-
-t.test('without --allow-same-version', t => {
- npm.config.set('allow-same-version', false)
-
- const version = require('../../lib/version')
-
- const commit1 = version.buildCommitArgs()
- const commit2 = version.buildCommitArgs([ 'commit' ])
- const commit3 = version.buildCommitArgs([ 'commit', '-m', 'some commit message' ])
-
- t.same(commit1, [ 'commit' ])
- t.same(commit2, [ 'commit' ])
- t.same(commit3, [ 'commit', '-m', 'some commit message' ])
-
- const tag = version.buildTagFlags()
-
- t.same(tag, '-m')
-
- npm.commands.version(['0.0.1'], function (err) {
- t.isa(err, Error, 'got an error')
- t.like(err.message, /Version not changed/)
- t.end()
- })
-})
-
-t.test('with --allow-same-version', t => {
- npm.config.set('allow-same-version', true)
-
- const version = require('../../lib/version')
-
- const commit1 = version.buildCommitArgs()
- const commit2 = version.buildCommitArgs([ 'commit' ])
- const commit3 = version.buildCommitArgs([ 'commit', '-m', 'some commit message' ])
-
- t.same(commit1, [ 'commit', '--allow-empty' ])
- t.same(commit2, [ 'commit', '--allow-empty' ])
- t.same(commit3, [ 'commit', '--allow-empty', '-m', 'some commit message' ])
-
- const tag = version.buildTagFlags()
-
- t.same(tag, '-fm')
-
- npm.commands.version(['0.0.1'], function (err) {
- if (err) {
- throw err
- }
- t.end()
- })
-})
diff --git a/deps/npm/test/tap/version-commit-hooks-default.js b/deps/npm/test/tap/version-commit-hooks-default.js
deleted file mode 100644
index 890aa55410..0000000000
--- a/deps/npm/test/tap/version-commit-hooks-default.js
+++ /dev/null
@@ -1,13 +0,0 @@
-var test = require('tap').test
-var npm = require('../../')
-
-// This test has to be separate from `version-commit-hooks.js`, due to
-// mutual exclusivity with the first test in that file. Initial configuration
-// seems to only work as expected for defaults during the first `npm.load()`.
-
-test('npm config `commit-hooks` defaults to `true`', function (t) {
- npm.load({}, function () {
- t.same(npm.config.get('commit-hooks'), true)
- t.end()
- })
-})
diff --git a/deps/npm/test/tap/version-commit-hooks.js b/deps/npm/test/tap/version-commit-hooks.js
deleted file mode 100644
index 36694d7eae..0000000000
--- a/deps/npm/test/tap/version-commit-hooks.js
+++ /dev/null
@@ -1,55 +0,0 @@
-const fs = require('graceful-fs')
-const path = require('path')
-const common = require('../common-tap.js')
-const pkg = common.pkg
-
-var test = require('tap').test
-var npm = require('../../')
-
-delete process.env['npm_config_commit_hooks']
-
-test('npm version <semver> with commit-hooks disabled in .npmrc', function (t) {
- var npmrc = path.resolve(pkg, '.npmrc')
- fs.writeFileSync(npmrc, 'commit-hooks=false\n', 'ascii')
- process.chdir(pkg)
-
- npm.load({ prefix: pkg, userconfig: npmrc }, function (err, conf) {
- if (err) {
- t.fail('error loading npm')
- }
- t.same(npm.config.get('commit-hooks'), false)
- t.end()
- })
-})
-
-test('npm version <semver> with commit-hooks disabled', function (t) {
- npm.load({}, function () {
- npm.config.set('commit-hooks', false)
-
- var version = require('../../lib/version')
- var args1 = version.buildCommitArgs()
- var args2 = version.buildCommitArgs([ 'commit' ])
- var args3 = version.buildCommitArgs([ 'commit', '-m', 'some commit message' ])
-
- t.same(args1, [ 'commit', '-n' ])
- t.same(args2, [ 'commit', '-n' ])
- t.same(args3, [ 'commit', '-n', '-m', 'some commit message' ])
- t.end()
- })
-})
-
-test('npm version <semver> with commit-hooks enabled (default)', function (t) {
- npm.load({}, function () {
- npm.config.set('commit-hooks', true)
-
- var version = require('../../lib/version')
- var args1 = version.buildCommitArgs()
- var args2 = version.buildCommitArgs([ 'commit' ])
- var args3 = version.buildCommitArgs([ 'commit', '-m', 'some commit message' ])
-
- t.same(args1, [ 'commit' ])
- t.same(args2, [ 'commit' ])
- t.same(args3, [ 'commit', '-m', 'some commit message' ])
- t.end()
- })
-})
diff --git a/deps/npm/test/tap/version-consistent-newlines.js b/deps/npm/test/tap/version-consistent-newlines.js
deleted file mode 100644
index 583874db7a..0000000000
--- a/deps/npm/test/tap/version-consistent-newlines.js
+++ /dev/null
@@ -1,80 +0,0 @@
-'use strict'
-
-const common = require('../common-tap.js')
-const test = require('tap').test
-const npm = require('../../')
-const path = require('path')
-const fs = require('fs')
-const mkdirp = require('mkdirp')
-const requireInject = require('require-inject')
-
-const pkg = common.pkg
-const cache = common.cache
-const gitDir = path.resolve(pkg, '.git')
-
-test('npm version does not alter the line endings in package.json (LF)', function (t) {
- setup('\n')
-
- npm.load({cache: cache, registry: common.registry}, function () {
- const version = requireInject('../../lib/version', {
- which: function (cmd, cb) {
- process.nextTick(function () {
- cb(new Error('ENOGIT!'))
- })
- }
- })
-
- version(['patch'], function (err) {
- if (!t.error(err)) return t.end()
-
- const pkgPath = path.resolve(pkg, 'package.json')
- const pkgStr = fs.readFileSync(pkgPath, 'utf8')
-
- t.match(pkgStr, '\n')
- t.notMatch(pkgStr, '\r')
-
- t.end()
- })
- })
-})
-
-test('npm version does not alter the line endings in package.json (CRLF)', function (t) {
- setup('\r\n')
-
- npm.load({cache: cache, registry: common.registry}, function () {
- const version = requireInject('../../lib/version', {
- which: function (cmd, cb) {
- process.nextTick(function () {
- cb(new Error('ENOGIT!'))
- })
- }
- })
-
- version(['patch'], function (err) {
- if (!t.error(err)) return t.end()
-
- const pkgPath = path.resolve(pkg, 'package.json')
- const pkgStr = fs.readFileSync(pkgPath, 'utf8')
-
- t.match(pkgStr, '\r\n')
- t.notMatch(pkgStr, /[^\r]\n/)
-
- t.end()
- })
- })
-})
-
-function setup (lineEnding) {
- mkdirp.sync(gitDir)
- fs.writeFileSync(
- path.resolve(pkg, 'package.json'),
- JSON.stringify({
- author: 'Terin Stock',
- name: 'version-no-git-test',
- version: '0.0.0',
- description: "Test for npm version if git binary doesn't exist"
- }, null, 2).replace(/\n/g, lineEnding),
- 'utf8'
- )
- process.chdir(pkg)
-}
diff --git a/deps/npm/test/tap/version-from-git.js b/deps/npm/test/tap/version-from-git.js
deleted file mode 100644
index e63865a733..0000000000
--- a/deps/npm/test/tap/version-from-git.js
+++ /dev/null
@@ -1,220 +0,0 @@
-var common = require('../common-tap.js')
-var fs = require('fs')
-var path = require('path')
-
-var mkdirp = require('mkdirp')
-var rimraf = require('rimraf')
-var test = require('tap').test
-
-var npm = require('../../lib/npm.js')
-
-var pkg = common.pkg
-var packagePath = path.resolve(pkg, 'package.json')
-var cache = common.cache
-
-var json = { name: 'cat', version: '0.1.2' }
-
-test('npm version from-git with a valid tag creates a new commit', function (t) {
- var version = '1.2.3'
- setup()
- createTag(t, version, runVersion)
-
- function runVersion (er) {
- t.ifError(er, 'git tag ran without error')
- npm.config.set('sign-git-commit', false)
- npm.config.set('sign-git-tag', false)
- npm.commands.version(['from-git'], checkVersion)
- }
-
- function checkVersion (er) {
- var git = require('../../lib/utils/git.js')
- t.ifError(er, 'version command ran without error')
- git.whichAndExec(
- ['log'],
- { cwd: pkg, env: process.env },
- checkCommit
- )
- }
-
- function checkCommit (er, log, stderr) {
- t.ifError(er, 'git log ran without issue')
- t.notOk(stderr, 'no error output')
- t.ok(log.indexOf(version) !== -1, 'commit was created')
- t.end()
- }
-})
-
-test('npm version from-git with a valid tag updates the package.json version', function (t) {
- var version = '1.2.3'
- setup()
- createTag(t, version, runVersion)
-
- function runVersion (er) {
- t.ifError(er, 'git tag ran without error')
- npm.config.set('sign-git-commit', false)
- npm.config.set('sign-git-tag', false)
- npm.commands.version(['from-git'], checkManifest)
- }
-
- function checkManifest (er) {
- t.ifError(er, 'npm run version ran without error')
- fs.readFile(path.resolve(pkg, 'package.json'), 'utf8', function (er, data) {
- t.ifError(er, 'read manifest without error')
- var manifest = JSON.parse(data)
- t.equal(manifest.version, version, 'updated the package.json version')
- t.done()
- })
- }
-})
-
-test('npm version from-git strips tag-version-prefix', function (t) {
- var version = '1.2.3'
- var prefix = 'custom-'
- var tag = prefix + version
- setup()
- createTag(t, tag, runVersion)
-
- function runVersion (er) {
- t.ifError(er, 'git tag ran without error')
- npm.config.set('sign-git-commit', false)
- npm.config.set('sign-git-tag', false)
- npm.config.set('tag-version-prefix', prefix)
- npm.commands.version(['from-git'], checkVersion)
- }
-
- function checkVersion (er) {
- var git = require('../../lib/utils/git.js')
- t.ifError(er, 'version command ran without error')
- git.whichAndExec(
- ['log', '--pretty=medium'],
- { cwd: pkg, env: process.env },
- checkCommit
- )
- }
-
- function checkCommit (er, log, stderr) {
- t.ifError(er, 'git log ran without issue')
- t.notOk(stderr, 'no error output')
- t.ok(log.indexOf(tag) === -1, 'commit should not include prefix')
- t.ok(log.indexOf(version) !== -1, 'commit should include version')
- t.end()
- }
-})
-
-test('npm version from-git only strips tag-version-prefix if it is a prefix', function (t) {
- var prefix = 'test'
- var version = '1.2.3-' + prefix
- setup()
- createTag(t, version, runVersion)
-
- function runVersion (er) {
- t.ifError(er, 'git tag ran without error')
- npm.config.set('sign-git-commit', false)
- npm.config.set('sign-git-tag', false)
- npm.config.set('tag-version-prefix', prefix)
- npm.commands.version(['from-git'], checkVersion)
- }
-
- function checkVersion (er) {
- var git = require('../../lib/utils/git.js')
- t.ifError(er, 'version command ran without error')
- git.whichAndExec(
- ['log'],
- { cwd: pkg, env: process.env },
- checkCommit
- )
- }
-
- function checkCommit (er, log, stderr) {
- t.ifError(er, 'git log ran without issue')
- t.notOk(stderr, 'no error output')
- t.ok(log.indexOf(version) !== -1, 'commit should include the full version')
- t.end()
- }
-})
-
-test('npm version from-git with an existing version', function (t) {
- var tag = 'v' + json.version
- setup()
- createTag(t, tag, runVersion)
-
- function runVersion (er) {
- t.ifError(er, 'git tag ran without error')
- npm.config.set('sign-git-commit', false)
- npm.config.set('sign-git-tag', false)
- npm.commands.version(['from-git'], checkVersion)
- }
-
- function checkVersion (er) {
- t.like(er.message, /Version not changed/)
- t.done()
- }
-})
-
-test('npm version from-git with an invalid version tag', function (t) {
- var tag = 'invalidversion'
- setup()
- createTag(t, tag, runVersion)
-
- function runVersion (er) {
- t.ifError(er, 'git tag ran without error')
- npm.config.set('sign-git-commit', false)
- npm.config.set('sign-git-tag', false)
- npm.commands.version(['from-git'], checkVersion)
- }
-
- function checkVersion (er) {
- t.equal(er.message, tag + ' is not a valid version')
- t.done()
- }
-})
-
-test('npm version from-git without any versions', function (t) {
- setup()
- createGitRepo(t, runVersion)
-
- function runVersion (er) {
- t.ifError(er, 'created git repo without errors')
- npm.config.set('sign-git-commit', false)
- npm.config.set('sign-git-tag', false)
- npm.commands.version(['from-git'], checkVersion)
- }
-
- function checkVersion (er) {
- t.equal(er.message, 'No tags found')
- t.done()
- }
-})
-
-function setup () {
- process.chdir(__dirname)
- rimraf.sync(pkg)
- mkdirp.sync(pkg)
- process.chdir(pkg)
- fs.writeFileSync(packagePath, JSON.stringify(json), 'utf8')
-}
-
-function createGitRepo (t, cb) {
- npm.load({ cache: cache }, function (er) {
- t.ifError(er, 'npm load ran without issue')
- common.makeGitRepo({
- path: pkg,
- added: ['package.json']
- }, cb)
- })
-}
-
-function createTag (t, tag, cb) {
- var opts = { cwd: pkg, env: { PATH: process.env.PATH } }
- npm.load({ cache: cache }, function (er) {
- t.ifError(er, 'npm load ran without issue')
-
- // git must be called after npm.load because it uses config
- var git = require('../../lib/utils/git.js')
- common.makeGitRepo({
- path: pkg,
- added: ['package.json'],
- commands: [git.chainableExec(['tag', tag, '-am', tag], opts)]
- }, cb)
- })
-}
diff --git a/deps/npm/test/tap/version-git-not-clean.js b/deps/npm/test/tap/version-git-not-clean.js
deleted file mode 100644
index 486e2e0766..0000000000
--- a/deps/npm/test/tap/version-git-not-clean.js
+++ /dev/null
@@ -1,79 +0,0 @@
-var common = require('../common-tap.js')
-var test = require('tap').test
-var npm = require('../../')
-var fs = require('fs')
-var which = require('which')
-var spawn = require('child_process').spawn
-
-var pkg = common.pkg
-var cache = common.cache
-
-test('npm version <semver> with working directory not clean', function (t) {
- process.chdir(pkg)
- npm.load({ cache: cache, registry: common.registry, prefix: pkg }, function () {
- which('git', function (err, git) {
- t.ifError(err, 'git found')
-
- function addPackageJSON (_cb) {
- var data = JSON.stringify({ name: 'blah', version: '0.1.2' })
- fs.writeFile('package.json', data, function () {
- var child = spawn(git, ['add', 'package.json'])
- child.on('exit', function () {
- var child2 = spawn(git, ['commit', 'package.json', '-m', 'init'])
- var out = ''
- child2.stdout.on('data', function (d) {
- out += d.toString()
- })
- child2.on('exit', function () {
- return _cb(out)
- })
- })
- })
- }
-
- common.makeGitRepo({path: pkg}, function () {
- addPackageJSON(function () {
- var data = JSON.stringify({ name: 'blah', version: '0.1.3' })
- fs.writeFile('package.json', data, function () {
- npm.commands.version(['patch'], function (err) {
- if (!err) {
- t.fail('should fail on non-clean working directory')
- } else {
- t.ok(err.message.match(/Git working directory not clean./))
- t.ok(err.message.match(/M package.json/))
- }
- t.end()
- })
- })
- })
- })
- })
- })
-})
-
-test('npm version <semver> --force with working directory not clean', function (t) {
- common.npm(
- [
- '--force',
- '--no-sign-git-commit',
- '--no-sign-git-tag',
- '--registry', common.registry,
- '--prefix', pkg,
- 'version',
- 'patch'
- ],
- { cwd: pkg, env: {PATH: process.env.PATH} },
- function (err, code, stdout, stderr) {
- t.ifError(err, 'npm version ran without issue')
- t.notOk(code, 'exited with a non-error code')
- var errorLines = stderr.trim().split('\n')
- .map(function (line) {
- return line.trim()
- })
- .filter(function (line) {
- return !line.indexOf('using --force')
- })
- t.notOk(errorLines.length, 'no error output')
- t.end()
- })
-})
diff --git a/deps/npm/test/tap/version-lifecycle.js b/deps/npm/test/tap/version-lifecycle.js
deleted file mode 100644
index 590ae86aa4..0000000000
--- a/deps/npm/test/tap/version-lifecycle.js
+++ /dev/null
@@ -1,202 +0,0 @@
-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.js')
-var npm = require('../../')
-var pkg = common.pkg
-var cache = common.cache
-var npmrc = path.resolve(pkg, './.npmrc')
-var configContents = 'sign-git-commit=false\nsign-git-tag=false\n'
-
-test('npm version <semver> with failing preversion lifecycle script', function (t) {
- setup()
- fs.writeFileSync(path.resolve(pkg, 'package.json'), JSON.stringify({
- author: 'Alex Wolfe',
- name: 'version-lifecycle',
- version: '0.0.0',
- description: 'Test for npm version if preversion script fails',
- scripts: {
- preversion: 'node ./fail.js'
- }
- }), 'utf8')
- fs.writeFileSync(path.resolve(pkg, 'fail.js'), 'process.exit(50)', 'utf8')
- npm.load({
- cache: cache,
- 'sign-git-commit': false,
- 'sign-git-tag': false,
- registry: common.registry
- }, function () {
- var version = require('../../lib/version')
- version(['patch'], function (err) {
- t.ok(err)
- t.ok(err.message.match(/Exit status 50/))
- t.end()
- })
- })
-})
-
-test('npm version <semver> with failing version lifecycle script', function (t) {
- setup()
- fs.writeFileSync(path.resolve(pkg, 'package.json'), JSON.stringify({
- author: 'Alex Wolfe',
- name: 'version-lifecycle',
- version: '0.0.0',
- description: 'Test for npm version if postversion script fails',
- scripts: {
- version: 'node ./fail.js'
- }
- }), 'utf8')
- fs.writeFileSync(path.resolve(pkg, 'fail.js'), 'process.exit(50)', 'utf8')
- npm.load({
- cache: cache,
- 'sign-git-commit': false,
- 'sign-git-tag': false,
- registry: common.registry
- }, function () {
- var version = require('../../lib/version')
- version(['patch'], function (err) {
- t.ok(err)
- t.ok(err.message.match(/Exit status 50/))
- t.end()
- })
- })
-})
-
-test('npm version <semver> with failing postversion lifecycle script', function (t) {
- setup()
- fs.writeFileSync(path.resolve(pkg, 'package.json'), JSON.stringify({
- author: 'Alex Wolfe',
- name: 'version-lifecycle',
- version: '0.0.0',
- description: 'Test for npm version if postversion script fails',
- scripts: {
- postversion: 'node ./fail.js'
- }
- }), 'utf8')
- fs.writeFileSync(path.resolve(pkg, 'fail.js'), 'process.exit(50)', 'utf8')
- npm.load({
- cache: cache,
- 'sign-git-commit': false,
- 'sign-git-tag': false,
- registry: common.registry
- }, function () {
- var version = require('../../lib/version')
- version(['patch'], function (err) {
- t.ok(err)
- t.ok(err.message.match(/Exit status 50/))
- t.end()
- })
- })
-})
-
-test('npm version <semver> execution order', function (t) {
- setup()
- fs.writeFileSync(path.resolve(pkg, 'package.json'), JSON.stringify({
- author: 'Alex Wolfe',
- name: 'version-lifecycle',
- version: '0.0.0',
- description: 'Test for npm version if postversion script fails',
- scripts: {
- preversion: 'node ./preversion.js',
- version: 'node ./version.js',
- postversion: 'node ./postversion.js'
- }
- }), 'utf8')
- makeScript('preversion')
- makeScript('version')
- makeScript('postversion')
- npm.load({
- cache: cache,
- 'sign-git-commit': false,
- 'sign-git-tag': false,
- registry: common.registry
- }, function () {
- common.makeGitRepo({path: pkg}, function (err, git) {
- t.ifError(err, 'git bootstrap ran without error')
-
- var version = require('../../lib/version')
- version(['patch'], function (err) {
- t.ifError(err, 'version command complete')
-
- t.equal('0.0.0', readPackage('preversion').version, 'preversion')
- t.deepEqual(readStatus('preversion', t), {
- 'preversion-package.json': 'A'
- })
-
- t.equal('0.0.1', readPackage('version').version, 'version')
- t.deepEqual(readStatus('version', t), {
- 'package.json': 'M',
- 'preversion-package.json': 'A',
- 'version-package.json': 'A'
- })
-
- t.equal('0.0.1', readPackage('postversion').version, 'postversion')
- t.deepEqual(readStatus('postversion', t), {
- 'postversion-package.json': 'A'
- })
- t.end()
- })
- })
- })
-})
-
-function setup () {
- process.chdir(__dirname)
- rimraf.sync(pkg)
- mkdirp.sync(pkg)
- mkdirp.sync(path.join(pkg, 'node_modules'))
- fs.writeFileSync(npmrc, configContents, 'ascii')
- process.chdir(pkg)
-}
-
-function makeScript (lifecycle) {
- function contents (lifecycle) {
- var fs = require('fs')
- var exec = require('child_process').exec
- fs.createReadStream('package.json')
- .pipe(fs.createWriteStream(lifecycle + '-package.json'))
- .on('close', function () {
- exec(
- 'git add ' + lifecycle + '-package.json',
- function () {
- exec(
- 'git status --porcelain',
- function (err, stdout) {
- if (err) throw err
- fs.writeFileSync(lifecycle + '-git.txt', stdout)
- }
- )
- }
- )
- })
- }
- var scriptPath = path.join(pkg, lifecycle + '.js')
- fs.writeFileSync(
- scriptPath,
- '(' + contents.toString() + ')(\'' + lifecycle + '\')',
- 'utf-8')
-}
-
-function readPackage (lifecycle) {
- return JSON.parse(fs.readFileSync(path.join(pkg, lifecycle + '-package.json'), 'utf-8'))
-}
-
-function readStatus (lifecycle, t) {
- var status = {}
- fs.readFileSync(path.join(pkg, lifecycle + '-git.txt'), 'utf-8')
- .trim()
- .split('\n')
- .forEach(function (line) {
- line = line.trim()
- if (line && !line.match(/^\?\? /)) {
- var parts = line.split(/\s+/)
- t.equal(parts.length, 2, lifecycle + ' : git status has too many words : ' + line)
- status[parts[1].trim()] = parts[0].trim()
- }
- })
- return status
-}
diff --git a/deps/npm/test/tap/version-message-config.js b/deps/npm/test/tap/version-message-config.js
deleted file mode 100644
index 94e9e951e7..0000000000
--- a/deps/npm/test/tap/version-message-config.js
+++ /dev/null
@@ -1,58 +0,0 @@
-var common = require('../common-tap.js')
-var fs = require('fs')
-var path = require('path')
-
-var test = require('tap').test
-
-var npm = require('../../lib/npm.js')
-
-var pkg = common.pkg
-var npmrc = path.resolve(pkg, '.npmrc')
-var packagePath = path.resolve(pkg, 'package.json')
-
-var json = { name: 'blah', version: '0.1.2' }
-
-var configContents = 'sign-git-commit=false\nsign-git-tag=false\nmessage=":bookmark: %s"\n'
-
-test('npm version <semver> with message config', function (t) {
- setup()
-
- npm.load({ prefix: pkg, userconfig: npmrc }, function () {
- var git = require('../../lib/utils/git.js')
-
- common.makeGitRepo({ path: pkg }, function (er) {
- t.ifErr(er, 'git bootstrap ran without error')
-
- common.npm(
- [
- 'version',
- 'patch',
- '--loglevel', 'silent'
- // package config is picked up from env
- ],
- { cwd: pkg, env: { PATH: process.env.PATH } },
- function (err, code, stdout, stderr) {
- t.ifError(err, 'npm version ran without issue')
- t.notOk(code, 'exited with a non-error code')
- t.notOk(stderr, 'no error output')
-
- git.whichAndExec(
- ['log'],
- { cwd: pkg, env: process.env },
- function (er, log, stderr) {
- t.ok(log.match(/:bookmark: 0\.1\.3/g), 'config was picked up by version')
- t.end()
- }
- )
- }
- )
- })
- })
-})
-
-function setup () {
- process.chdir(pkg)
-
- fs.writeFileSync(packagePath, JSON.stringify(json), 'utf8')
- fs.writeFileSync(npmrc, configContents, 'ascii')
-}
diff --git a/deps/npm/test/tap/version-no-git.js b/deps/npm/test/tap/version-no-git.js
deleted file mode 100644
index cea8b55ddc..0000000000
--- a/deps/npm/test/tap/version-no-git.js
+++ /dev/null
@@ -1,43 +0,0 @@
-var common = require('../common-tap.js')
-var test = require('tap').test
-var npm = require('../../')
-var path = require('path')
-var fs = require('fs')
-var mkdirp = require('mkdirp')
-var requireInject = require('require-inject')
-
-var pkg = common.pkg
-var cache = common.cache
-var gitDir = path.resolve(pkg, '.git')
-
-test('npm version <semver> in a git repo without the git binary', function (t) {
- setup()
- npm.load({cache: cache, registry: common.registry}, function () {
- var version = requireInject('../../lib/version', {
- which: function (cmd, cb) {
- process.nextTick(function () {
- cb(new Error('ENOGIT!'))
- })
- }
- })
-
- version(['patch'], function (err) {
- if (!t.error(err)) return t.end()
- var p = path.resolve(pkg, 'package')
- var testPkg = require(p)
- t.equal('0.0.1', testPkg.version, '\'' + testPkg.version + '\' === \'0.0.1\'')
- t.end()
- })
- })
-})
-
-function setup () {
- mkdirp.sync(gitDir)
- fs.writeFileSync(path.resolve(pkg, 'package.json'), JSON.stringify({
- author: 'Terin Stock',
- name: 'version-no-git-test',
- version: '0.0.0',
- description: "Test for npm version if git binary doesn't exist"
- }), 'utf8')
- process.chdir(pkg)
-}
diff --git a/deps/npm/test/tap/version-no-package.js b/deps/npm/test/tap/version-no-package.js
deleted file mode 100644
index 60c0e3be7a..0000000000
--- a/deps/npm/test/tap/version-no-package.js
+++ /dev/null
@@ -1,23 +0,0 @@
-var common = require('../common-tap.js')
-var test = require('tap').test
-
-var pkg = common.pkg
-
-test('npm version in a prefix with no package.json', function (t) {
- process.chdir(pkg)
- common.npm(
- ['version', '--json', '--prefix', pkg],
- { cwd: pkg, nodeExecPath: process.execPath },
- function (er, code, stdout, stderr) {
- t.ifError(er, "npm version doesn't care that there's no package.json")
- t.notOk(code, 'npm version ran without barfing')
- t.ok(stdout, 'got version output')
- t.notOk(stderr, 'no error output')
- t.doesNotThrow(function () {
- var metadata = JSON.parse(stdout)
- t.equal(metadata.node, process.versions.node, 'node versions match')
- }, 'able to reconstitute version object from stdout')
- t.end()
- }
- )
-})
diff --git a/deps/npm/test/tap/version-no-tags.js b/deps/npm/test/tap/version-no-tags.js
deleted file mode 100644
index c2c11d875b..0000000000
--- a/deps/npm/test/tap/version-no-tags.js
+++ /dev/null
@@ -1,58 +0,0 @@
-var common = require('../common-tap.js')
-var test = require('tap').test
-var npm = require('../../')
-var path = require('path')
-var fs = require('fs')
-var which = require('which')
-var spawn = require('child_process').spawn
-
-var pkg = common.pkg
-var cache = common.cache
-
-test('npm version <semver> without git tag', function (t) {
- setup()
- npm.load({ cache: cache, registry: common.registry }, function () {
- which('git', function (err, git) {
- t.ifError(err, 'git found on system')
- function tagExists (tag, _cb) {
- var child1 = spawn(git, ['tag', '-l', tag])
- var out = ''
- child1.stdout.on('data', function (d) {
- out += d.toString()
- })
- child1.on('exit', function () {
- return _cb(null, Boolean(~out.indexOf(tag)))
- })
- }
-
- var child2 = spawn(git, ['init'])
- child2.stdout.pipe(process.stdout)
- child2.on('exit', function () {
- npm.config.set('git-tag-version', false)
- npm.commands.version(['patch'], function (err) {
- if (err) return t.fail('Error perform version patch')
- var p = path.resolve(pkg, 'package')
- var testPkg = require(p)
- if (testPkg.version !== '0.0.1') t.fail(testPkg.version + ' !== \'0.0.1\'')
- t.equal('0.0.1', testPkg.version)
- tagExists('v0.0.1', function (err, exists) {
- t.ifError(err, 'tag found to exist')
- t.equal(exists, false, 'git tag DOES exist')
- t.pass('git tag does not exist')
- t.end()
- })
- })
- })
- })
- })
-})
-
-function setup () {
- fs.writeFileSync(path.resolve(pkg, 'package.json'), JSON.stringify({
- author: 'Evan Lucas',
- name: 'version-no-tags-test',
- version: '0.0.0',
- description: 'Test for git-tag-version flag'
- }), 'utf8')
- process.chdir(pkg)
-}
diff --git a/deps/npm/test/tap/version-prerelease-id.js b/deps/npm/test/tap/version-prerelease-id.js
deleted file mode 100644
index 0e248423cd..0000000000
--- a/deps/npm/test/tap/version-prerelease-id.js
+++ /dev/null
@@ -1,37 +0,0 @@
-var fs = require('fs')
-var path = require('path')
-
-var test = require('tap').test
-
-var npm = require('../../')
-var common = require('../common-tap.js')
-
-var pkg = common.pkg
-
-var EXEC_OPTS = { cwd: pkg }
-
-test('npm version --preid=rc uses prerelease id', function (t) {
- setup()
-
- npm.load({ cache: pkg + '/cache', registry: common.registry }, function () {
- common.npm(['version', 'prerelease', '--preid=rc'], EXEC_OPTS, function (err) {
- if (err) return t.fail('Error perform version prerelease')
- var newVersion = require(path.resolve(pkg, 'package.json')).version
- t.equal(newVersion, '0.0.1-rc.0', 'got expected version')
- t.end()
- })
- })
-})
-
-function setup () {
- var contents = {
- author: 'Daniel Wilches',
- name: 'version-prerelease-id',
- version: '0.0.0',
- description: 'Test for version of prereleases with preids'
- }
-
- fs.writeFileSync(path.resolve(pkg, 'package.json'), JSON.stringify(contents), 'utf8')
- fs.writeFileSync(path.resolve(pkg, 'npm-shrinkwrap.json'), JSON.stringify(contents), 'utf8')
- process.chdir(pkg)
-}
diff --git a/deps/npm/test/tap/version-sub-directory-shrinkwrap.js b/deps/npm/test/tap/version-sub-directory-shrinkwrap.js
deleted file mode 100644
index 5f2d688f42..0000000000
--- a/deps/npm/test/tap/version-sub-directory-shrinkwrap.js
+++ /dev/null
@@ -1,65 +0,0 @@
-var common = require('../common-tap.js')
-var fs = require('fs')
-var path = require('path')
-
-var mkdirp = require('mkdirp')
-var test = require('tap').test
-
-var npm = require('../../lib/npm.js')
-
-var pkg = common.pkg
-var subDirectory = path.resolve(pkg, 'sub-directory')
-var packagePath = path.resolve(pkg, 'package.json')
-var shrinkwrapPath = path.resolve(pkg, 'npm-shrinkwrap.json')
-var cache = common.cache
-
-var json = { name: 'cat', version: '0.1.2' }
-
-test('npm version <semver> from a subdirectory', function (t) {
- setup()
- npmLoad()
-
- function npmLoad () {
- npm.load({ cache: cache }, function () {
- common.makeGitRepo({
- path: pkg,
- added: ['package.json', 'npm-shrinkwrap.json']
- }, version)
- })
- }
-
- function version (er, stdout, stderr) {
- t.ifError(er, 'git repo initialized without issue')
- t.notOk(stderr, 'no error output')
- npm.config.set('sign-git-tag', false)
- npm.commands.version(['patch'], checkVersion)
- }
-
- function checkVersion (er) {
- var newShrinkwrap = JSON.parse(fs.readFileSync(shrinkwrapPath))
- t.is(newShrinkwrap.version, '0.1.3', 'shrinkwrap has right version')
- var newPackage = JSON.parse(fs.readFileSync(packagePath))
- t.is(newPackage.version, '0.1.3', 'package.json has right version')
- var git = require('../../lib/utils/git.js')
- t.ifError(er, 'version command ran without error')
- git.whichAndExec(
- ['log'],
- { cwd: pkg, env: process.env },
- checkCommit
- )
- }
-
- function checkCommit (er, log, stderr) {
- t.ifError(er, 'git log ran without issue')
- t.notOk(stderr, 'no error output')
- t.ok(log.match(/0\.1\.3/g), 'commited from subdirectory')
- t.end()
- }
-})
-
-function setup () {
- mkdirp.sync(subDirectory)
- process.chdir(subDirectory)
- fs.writeFileSync(packagePath, JSON.stringify(json), 'utf8')
- fs.writeFileSync(shrinkwrapPath, JSON.stringify(json), 'utf8')
-}
diff --git a/deps/npm/test/tap/version-sub-directory.js b/deps/npm/test/tap/version-sub-directory.js
deleted file mode 100644
index fc4a41f36e..0000000000
--- a/deps/npm/test/tap/version-sub-directory.js
+++ /dev/null
@@ -1,56 +0,0 @@
-var common = require('../common-tap.js')
-var fs = require('fs')
-var path = require('path')
-
-var mkdirp = require('mkdirp')
-var test = require('tap').test
-
-var npm = require('../../lib/npm.js')
-
-var pkg = common.pkg
-var subDirectory = path.resolve(pkg, 'sub-directory')
-var packagePath = path.resolve(pkg, 'package.json')
-var cache = common.cache
-
-var json = { name: 'cat', version: '0.1.2' }
-
-test('npm version <semver> from a subdirectory', function (t) {
- mkdirp.sync(subDirectory)
- process.chdir(subDirectory)
- fs.writeFileSync(packagePath, JSON.stringify(json), 'utf8')
- npmLoad()
-
- function npmLoad () {
- npm.load({ cache: cache }, function () {
- common.makeGitRepo({
- path: pkg,
- added: ['package.json']
- }, version)
- })
- }
-
- function version (er, stdout, stderr) {
- t.ifError(er, 'git repo initialized without issue')
- t.notOk(stderr, 'no error output')
- npm.config.set('sign-git-commit', false)
- npm.config.set('sign-git-tag', false)
- npm.commands.version(['patch'], checkVersion)
- }
-
- function checkVersion (er) {
- var git = require('../../lib/utils/git.js')
- t.ifError(er, 'version command ran without error')
- git.whichAndExec(
- ['log'],
- { cwd: pkg, env: process.env },
- checkCommit
- )
- }
-
- function checkCommit (er, log, stderr) {
- t.ifError(er, 'git log ran without issue')
- t.notOk(stderr, 'no error output')
- t.ok(log.match(/0\.1\.3/g), 'commited from subdirectory')
- t.end()
- }
-})
diff --git a/deps/npm/test/tap/version-update-shrinkwrap.js b/deps/npm/test/tap/version-update-shrinkwrap.js
deleted file mode 100644
index e6ba5ee618..0000000000
--- a/deps/npm/test/tap/version-update-shrinkwrap.js
+++ /dev/null
@@ -1,127 +0,0 @@
-var fs = require('fs')
-var path = require('path')
-
-var mkdirp = require('mkdirp')
-var rimraf = require('rimraf')
-var test = require('tap').test
-
-var npm = require('../../')
-var common = require('../common-tap.js')
-
-var pkg = common.pkg
-var cache = common.cache
-
-test('npm version <semver> updates shrinkwrap - no git', function (t) {
- setup()
- npm.load({ cache: cache, registry: common.registry }, function () {
- npm.commands.version(['patch'], function (err) {
- if (err) return t.fail('Error perform version patch')
- var shrinkwrap = require(path.resolve(pkg, 'npm-shrinkwrap.json'))
- t.equal(shrinkwrap.version, '0.0.1', 'got expected version')
- t.end()
- })
- })
-})
-
-test('npm version <semver> updates git works with no shrinkwrap', function (t) {
- setup()
- rimraf.sync(path.resolve(pkg, 'npm-shrinkwrap.json'))
-
- npm.config.set('sign-git-commit', false)
- npm.config.set('sign-git-tag', false)
-
- common.makeGitRepo({
- path: pkg,
- added: ['package.json']
- }, version)
-
- function version (er, stdout, stderr) {
- t.ifError(er, 'git repo initialized without issue')
- t.notOk(stderr, 'no error output')
-
- npm.commands.version(['patch'], checkCommit)
- }
-
- function checkCommit (er) {
- t.ifError(er, 'version command ran without error')
-
- var shrinkwrap = require(path.resolve(pkg, 'npm-shrinkwrap.json'))
- t.equal(shrinkwrap.version, '0.0.1', 'got expected version')
-
- var opts = { cwd: pkg, env: { PATH: process.env.PATH } }
- var git = require('../../lib/utils/git.js')
- git.whichAndExec(
- ['show', 'HEAD', '--name-only'],
- opts,
- function (er, stdout, stderr) {
- t.ifError(er, 'git show ran without issues')
- t.notOk(stderr, 'no error output')
-
- var lines = stdout.split('\n')
- t.notEqual(lines.indexOf('package.json'), -1, 'package.json commited')
- t.equal(lines.indexOf('npm-shrinkwrap.json'), -1, 'npm-shrinkwrap.json not present')
-
- t.end()
- }
- )
- }
-})
-
-test('npm version <semver> updates shrinkwrap and updates git', function (t) {
- setup()
-
- npm.config.set('sign-git-commit', false)
- npm.config.set('sign-git-tag', false)
-
- common.makeGitRepo({
- path: pkg,
- added: ['package.json', 'npm-shrinkwrap.json']
- }, version)
-
- function version (er, stdout, stderr) {
- t.ifError(er, 'git repo initialized without issue')
- t.notOk(stderr, 'no error output')
-
- npm.commands.version(['patch'], checkCommit)
- }
-
- function checkCommit (er) {
- t.ifError(er, 'version command ran without error')
-
- var shrinkwrap = require(path.resolve(pkg, 'npm-shrinkwrap.json'))
- t.equal(shrinkwrap.version, '0.0.1', 'got expected version')
-
- var git = require('../../lib/utils/git.js')
- var opts = { cwd: pkg, env: { PATH: process.env.PATH } }
- git.whichAndExec(
- ['show', 'HEAD', '--name-only'],
- opts,
- function (er, stdout, stderr) {
- t.ifError(er, 'git show ran without issues')
- t.notOk(stderr, 'no error output')
-
- var lines = stdout.split('\n')
- t.notEqual(lines.indexOf('package.json'), -1, 'package.json commited')
- t.notEqual(lines.indexOf('npm-shrinkwrap.json'), -1, 'npm-shrinkwrap.json commited')
-
- t.end()
- }
- )
- }
-})
-
-function setup () {
- process.chdir(__dirname)
- rimraf.sync(pkg)
- mkdirp.sync(pkg)
- var contents = {
- author: 'Nathan Bowser && Faiq Raza',
- name: 'version-with-shrinkwrap-test',
- version: '0.0.0',
- description: 'Test for version with shrinkwrap update'
- }
-
- fs.writeFileSync(path.resolve(pkg, 'package.json'), JSON.stringify(contents), 'utf8')
- fs.writeFileSync(path.resolve(pkg, 'npm-shrinkwrap.json'), JSON.stringify(contents), 'utf8')
- process.chdir(pkg)
-}
diff --git a/deps/npm/test/tap/view.js b/deps/npm/test/tap/view.js
deleted file mode 100644
index 71d21487ae..0000000000
--- a/deps/npm/test/tap/view.js
+++ /dev/null
@@ -1,381 +0,0 @@
-var common = require('../common-tap.js')
-const t = require('tap')
-var test = t.test
-var osenv = require('osenv')
-var path = require('path')
-var fs = require('fs')
-var rimraf = require('rimraf')
-var mkdirp = require('mkdirp')
-
-// this test has to use a tmpdir so that it's outside of
-// the current package context of npm.
-var tmp = osenv.tmpdir()
-var t1dir = path.resolve(tmp, 'view-local-no-pkg')
-var t2dir = path.resolve(tmp, 'view-local-notmine')
-var t3dir = path.resolve(tmp, 'view-local-mine')
-var mr = require('npm-registry-mock')
-
-var server
-
-t.teardown(() => {
- rimraf.sync(t1dir)
- rimraf.sync(t2dir)
- rimraf.sync(t3dir)
- if (server) {
- server.close()
- }
-})
-
-test('setup', function (t) {
- mkdirp.sync(t1dir)
- mkdirp.sync(t2dir)
- mkdirp.sync(t3dir)
-
- fs.writeFileSync(t2dir + '/package.json', JSON.stringify({
- author: 'Evan Lucas',
- name: 'test-repo-url-https',
- version: '0.0.1'
- }), 'utf8')
-
- fs.writeFileSync(t3dir + '/package.json', JSON.stringify({
- author: 'Evan Lucas',
- name: 'biscuits',
- version: '0.0.1'
- }), 'utf8')
-
- t.pass('created fixtures')
-
- mr({ port: common.port, plugin: plugin }, function (er, s) {
- server = s
- t.end()
- })
-})
-
-function plugin (server) {
- server
- .get('/biscuits')
- .many()
- .reply(404, {'error': 'version not found'})
-}
-
-test('npm view . in global mode', function (t) {
- common.npm([
- 'view',
- '.',
- '--registry=' + common.registry,
- '--global'
- ], { cwd: t1dir }, function (err, code, stdout, stderr) {
- t.ifError(err, 'view command finished successfully')
- t.equal(code, 1, 'exit not ok')
- t.similar(stderr, /Cannot use view command in global mode./m)
- t.end()
- })
-})
-
-test('npm view --global', function (t) {
- common.npm([
- 'view',
- '--registry=' + common.registry,
- '--global'
- ], { cwd: t1dir }, function (err, code, stdout, stderr) {
- t.ifError(err, 'view command finished successfully')
- t.equal(code, 1, 'exit not ok')
- t.similar(stderr, /Cannot use view command in global mode./m)
- t.end()
- })
-})
-
-test('npm view . with no package.json', function (t) {
- common.npm([
- 'view',
- '.',
- '--registry=' + common.registry
- ], { cwd: t1dir }, function (err, code, stdout, stderr) {
- t.ifError(err, 'view command finished successfully')
- t.equal(code, 1, 'exit not ok')
- t.similar(stderr, /Invalid package.json/m)
- t.end()
- })
-})
-
-test('npm view . with no published package', function (t) {
- common.npm([
- 'view',
- '.',
- '--registry=' + common.registry
- ], { cwd: t3dir }, function (err, code, stdout, stderr) {
- t.ifError(err, 'view command finished successfully')
- t.equal(code, 1, 'exit not ok')
- t.similar(stderr, /not in the npm registry/m)
- t.end()
- })
-})
-
-test('npm view .', function (t) {
- common.npm([
- 'view',
- '.',
- '--registry=' + common.registry
- ], { cwd: t2dir }, function (err, code, stdout) {
- t.ifError(err, 'view command finished successfully')
- t.equal(code, 0, 'exit ok')
- t.matches(stdout, /test-repo-url-https/, 'has the right package')
- t.end()
- })
-})
-
-test('npm view . select fields', function (t) {
- common.npm([
- 'view',
- '.',
- 'main',
- '--registry=' + common.registry
- ], { cwd: t2dir }, function (err, code, stdout) {
- t.ifError(err, 'view command finished successfully')
- t.equal(code, 0, 'exit ok')
- t.equal(stdout.trim(), 'index.js', 'should print `index.js`')
- t.end()
- })
-})
-
-test('npm view .@<version>', function (t) {
- common.npm([
- 'view',
- '.@0.0.0',
- 'version',
- '--registry=' + common.registry
- ], { cwd: t2dir }, function (err, code, stdout) {
- t.ifError(err, 'view command finished successfully')
- t.equal(code, 0, 'exit ok')
- t.equal(stdout.trim(), '0.0.0', 'should print `0.0.0`')
- t.end()
- })
-})
-
-test('npm view .@<version> version --json', function (t) {
- common.npm([
- 'view',
- '.@0.0.0',
- 'version',
- '--json',
- '--registry=' + common.registry
- ], { cwd: t2dir }, function (err, code, stdout) {
- t.ifError(err, 'view command finished successfully')
- t.equal(code, 0, 'exit ok')
- t.equal(stdout.trim(), '"0.0.0"', 'should print `"0.0.0"`')
- t.end()
- })
-})
-
-test('npm view . --json author name version', function (t) {
- common.npm([
- 'view',
- '.',
- 'author',
- 'name',
- 'version',
- '--json',
- '--registry=' + common.registry
- ], { cwd: t2dir }, function (err, code, stdout) {
- var expected = JSON.stringify({
- author: 'Evan Lucas <evanlucas@me.com>',
- name: 'test-repo-url-https',
- version: '0.0.1'
- }, null, 2)
- t.ifError(err, 'view command finished successfully')
- t.equal(code, 0, 'exit ok')
- t.equal(stdout.trim(), expected, 'should print ' + expected)
- t.end()
- })
-})
-
-test('npm view .@<version> --json author name version', function (t) {
- common.npm([
- 'view',
- '.@0.0.0',
- 'author',
- 'name',
- 'version',
- '--json',
- '--registry=' + common.registry
- ], { cwd: t2dir }, function (err, code, stdout) {
- var expected = JSON.stringify({
- author: 'Evan Lucas <evanlucas@me.com>',
- name: 'test-repo-url-https',
- version: '0.0.0'
- }, null, 2)
- t.ifError(err, 'view command finished successfully')
- t.equal(code, 0, 'exit ok')
- t.equal(stdout.trim(), expected, 'should print ' + expected)
- t.end()
- })
-})
-
-test('npm view <package name>', function (t) {
- common.npm([
- 'view',
- 'underscore',
- '--registry=' + common.registry
- ], { cwd: t2dir }, function (err, code, stdout) {
- t.ifError(err, 'view command finished successfully')
- t.equal(code, 0, 'exit ok')
- t.matches(stdout, /underscore/, 'should have name `underscore`')
- t.end()
- })
-})
-
-test('npm view <package name> --global', function (t) {
- common.npm([
- 'view',
- 'underscore',
- '--global',
- '--registry=' + common.registry
- ], { cwd: t2dir }, function (err, code, stdout) {
- t.ifError(err, 'view command finished successfully')
- t.equal(code, 0, 'exit ok')
- t.matches(stdout, /underscore/, 'should have name `underscore`')
- t.end()
- })
-})
-
-test('npm view <package name>@<semver range> versions', function (t) {
- common.npm([
- 'view',
- 'underscore@^1.5.0',
- 'versions',
- '--registry=' + common.registry
- ], { cwd: t2dir }, function (err, code, stdout) {
- t.ifError(err, 'view command finished successfully')
- t.equal(code, 0, 'exit ok')
- var re = new RegExp('1.5.0')
- t.similar(stdout, re, 'should have version `1.5.0`')
- t.end()
- })
-})
-
-test('npm view <package name>@<semver range> version --json', function (t) {
- common.npm([
- 'view',
- 'underscore@~1.5.0',
- 'version',
- '--json',
- '--registry=' + common.registry
- ], { cwd: t2dir }, function (err, code, stdout) {
- t.ifError(err, 'view command finished successfully')
- t.equal(code, 0, 'exit ok')
- t.equal(stdout.trim(), JSON.stringify([
- '1.5.0',
- '1.5.1'
- ], null, 2), 'should have three versions')
- t.end()
- })
-})
-
-test('npm view <package name> --json', function (t) {
- t.plan(3)
- common.npm([
- 'view',
- 'underscore',
- '--json',
- '--registry=' + common.registry
- ], { cwd: t2dir }, function (err, code, stdout) {
- t.ifError(err, 'view command finished successfully')
- t.equal(code, 0, 'exit ok')
- try {
- var out = JSON.parse(stdout.trim())
- t.similar(out, {
- maintainers: ['jashkenas <jashkenas@gmail.com>']
- }, 'should have the same maintainer')
- } catch (er) {
- t.fail('Unable to parse JSON')
- }
- })
-})
-
-test('npm view <package name>@<invalid version>', function (t) {
- common.npm([
- 'view',
- 'underscore@12345',
- '--registry=' + common.registry
- ], { cwd: t2dir }, function (err, code, stdout) {
- t.ifError(err, 'view command finished successfully')
- t.equal(code, 0, 'exit ok')
- t.equal(stdout.trim(), '', 'should return empty')
- t.end()
- })
-})
-
-test('npm view <package name>@<invalid version> --json', function (t) {
- common.npm([
- 'view',
- 'underscore@12345',
- '--json',
- '--registry=' + common.registry
- ], { cwd: t2dir }, function (err, code, stdout) {
- t.ifError(err, 'view command finished successfully')
- t.equal(code, 0, 'exit ok')
- t.equal(stdout.trim(), '', 'should return empty')
- t.end()
- })
-})
-
-test('npm view <package name> <field>', function (t) {
- common.npm([
- 'view',
- 'underscore',
- 'homepage',
- '--registry=' + common.registry
- ], { cwd: t2dir }, function (err, code, stdout) {
- t.ifError(err, 'view command finished successfully')
- t.equal(code, 0, 'exit ok')
- t.equal(stdout.trim(), 'http://underscorejs.org',
- 'homepage should equal `http://underscorejs.org`')
- t.end()
- })
-})
-
-test('npm view with invalid package name', function (t) {
- var invalidName = 'InvalidPackage'
-
- server.get('/' + invalidName).reply('404', {'error': 'not found'})
- common.npm([
- 'view',
- invalidName,
- '--registry=' + common.registry
- ], {}, function (err, code, stdout, stderr) {
- t.ifError(err, 'view command finished successfully')
- t.equal(code, 1, 'exit not ok')
-
- t.similar(stderr, new RegExp('is not in the npm registry'),
- 'Package should NOT be found')
-
- t.dissimilar(stderr, new RegExp('use the name yourself!'),
- 'Suggestion should not be there')
-
- t.similar(stderr, new RegExp('name can no longer contain capital letters'),
- 'Suggestion about Capital letter should be there')
-
- t.end()
- })
-})
-
-test('npm view with valid but non existent package name', function (t) {
- server.get('/valid-but-non-existent-package').reply(404, {'error': 'not found'})
- common.npm([
- 'view',
- 'valid-but-non-existent-package',
- '--registry=' + common.registry
- ], {}, function (err, code, stdout, stderr) {
- t.ifError(err, 'view command finished successfully')
- t.equal(code, 1, 'exit not ok')
-
- t.similar(stderr,
- new RegExp("'valid-but-non-existent-package' is not in the npm registry\\."),
- 'Package should NOT be found')
-
- t.similar(stderr, new RegExp('use the name yourself!'),
- 'Suggestion should be there')
-
- t.end()
- })
-})
diff --git a/deps/npm/test/tap/whoami.js b/deps/npm/test/tap/whoami.js
deleted file mode 100644
index aabf5b2821..0000000000
--- a/deps/npm/test/tap/whoami.js
+++ /dev/null
@@ -1,76 +0,0 @@
-var common = require('../common-tap.js')
-
-var fs = require('fs')
-var path = require('path')
-var createServer = require('http').createServer
-
-var test = require('tap').test
-var rimraf = require('rimraf')
-
-var opts = { cwd: __dirname }
-
-var FIXTURE_PATH = path.resolve(common.pkg, 'fixture_npmrc')
-
-test('npm whoami with basic auth', function (t) {
- 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, 0o644)
-
- common.npm(
- [
- 'whoami',
- '--userconfig=' + FIXTURE_PATH,
- '--registry=http://registry.lvh.me/'
- ],
- opts,
- function (err, code, stdout, stderr) {
- t.ifError(err)
-
- t.equal(stderr, '', 'got nothing on stderr')
- t.equal(code, 0, 'exit ok')
- t.equal(stdout, 'wombat\n', 'got username')
- t.end()
- }
- )
-})
-
-test('npm whoami with bearer auth', { timeout: 8000 }, function (t) {
- var s = '//localhost:' + common.port +
- '/:_authToken = wombat-developers-union\n'
- fs.writeFileSync(FIXTURE_PATH, s, 'ascii')
- fs.chmodSync(FIXTURE_PATH, 0o644)
-
- function verify (req, res) {
- t.equal(req.method, 'GET')
- t.equal(req.url, '/-/whoami')
-
- res.setHeader('content-type', 'application/json')
- res.writeHead(200)
- res.end(JSON.stringify({ username: 'wombat' }), 'utf8')
- }
-
- var server = createServer(verify)
-
- server.listen(common.port, function () {
- common.npm(
- [
- 'whoami',
- '--userconfig=' + FIXTURE_PATH,
- '--registry=http://localhost:' + common.port + '/'
- ],
- opts,
- function (err, code, stdout, stderr) {
- t.ifError(err)
-
- t.equal(stderr, '', 'got nothing on stderr')
- t.equal(code, 0, 'exit ok')
- t.equal(stdout, 'wombat\n', 'got username')
- rimraf.sync(FIXTURE_PATH)
- server.close()
- t.end()
- }
- )
- })
-})