refactor: use own options

BREAKING CHANGE:

storeController is not an optional parameter anymore
This commit is contained in:
Zoltan Kochan
2018-01-05 01:02:46 +02:00
parent d0be3b64c8
commit bb7aff4af6
56 changed files with 1204 additions and 663 deletions

View File

@@ -32,20 +32,18 @@ Install packages.
**Arguments:**
* `pkgsToInstall` - *Object | String[]* - either an object that maps package names to version ranges or inputs usually passed to `npm install` (e.g., `foo@1.0.0`, `foo`).
* `options.storeController` - *Object* - required. An object that does all the manipulations with the store.
* `options.store` - *String* - required. Location of the store.
* `options.saveProd` - *Boolean* - package will appear in `dependencies`.
* `options.saveDev` - *Boolean* - package will appear in `devDependencies`.
* `options.saveOptional` - *Boolean* - package will appear in `optionalDependencies`.
* `options.saveExact` - *Boolean* - saved dependencies will be configured with an exact version rather than using npm's default semver range operator.
* `options.global` - *Boolean* - the packages will be installed globally rather than locally.
* `options.prefix` - *String* - the directory in which the installation will be performed. By default the `process.cwd()` value is used.
* `options.metaCache` - *Map* - a cache for package meta info.
* `options.networkConcurrency` - *Number* - `16` by default. Max amount of network requests to perform concurrently.
* `options.offline` - *Boolean* - `false` by default. Install packages using only the local registry mirror, w/o doing any network requests.
* `options.reporter` - *Function* - A function that listens for logs.
* `options.packageManager` - *Object* - The `package.json` of the package manager.
* `options.hooks` - *Object* - A property that contains installation hooks. Hooks are [documented separately](#hooks).
* `options.ignoreFile` - *Function & (filename: string) => boolean* - A function that decides which files in a package are ignored. For instance,
there's no need in `.travis.yml` files in production, so you can set `{ignoreFile: fn => fn === '.travis.yml'}`.
* `options.packageImportMethod` - *auto | hardlink | reflink | copy* - how to import the packages from the store into node_modules. Defaults to `auto`, which will attempt to do hardlinks, and then copy if hardlinks fail.
* `options.shrinkwrapOnly` - *Boolean* - `false` by default. When `true`, only updates `shrinkwrap.yaml` and `package.json` instead of checking `node_modules` and downloading dependencies.

View File

@@ -20,8 +20,6 @@
},
"dependencies": {
"@pnpm/check-package": "^1.0.0",
"@pnpm/default-fetcher": "^0.3.0",
"@pnpm/default-resolver": "^0.1.0",
"@pnpm/fs-locker": "^1.0.0",
"@pnpm/package-requester": "^0.6.0",
"@pnpm/pkgid-to-filename": "^1.0.0",
@@ -65,7 +63,7 @@
"p-filter": "^1.0.0",
"p-limit": "^1.1.0",
"p-series": "^1.0.0",
"package-store": "^0.13.0",
"package-store": "^0.13.1",
"path-absolute": "^1.0.0",
"path-exists": "^3.0.0",
"path-name": "^1.0.0",
@@ -87,6 +85,8 @@
"@commitlint/cli": "^4.2.0",
"@commitlint/config-angular": "^4.2.0",
"@commitlint/prompt-cli": "^4.2.0",
"@pnpm/default-fetcher": "^0.3.1",
"@pnpm/default-resolver": "^0.1.1",
"@pnpm/logger": "^1.0.0",
"@types/mkdirp": "^0.5.1",
"@types/sinon": "^4.1.2",

View File

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,171 @@
import path = require('path')
import logger from '@pnpm/logger'
import pnpmPkgJson from '../pnpmPkgJson'
import {LAYOUT_VERSION} from '../fs/modulesController'
import normalizeRegistryUrl = require('normalize-registry-url')
import {resolveStore, StoreController} from 'package-store'
import { ReporterFunction } from '../types'
import { ReadPackageHook } from '@pnpm/types'
export type InstallOptions = {
storeController: StoreController,
store: string,
reporter?: ReporterFunction,
shrinkwrapOnly?: boolean,
force?: boolean,
update?: boolean,
depth?: number,
repeatInstallDepth?: number,
prefix?: string,
offline?: boolean,
rawNpmConfig?: object,
verifyStoreIntegrity?: boolean,
engineStrict?: boolean,
nodeVersion?: string,
packageManager?: {
name: string,
version: string,
},
hooks?: {
readPackage?: ReadPackageHook,
},
saveExact?: boolean,
savePrefix?: string,
saveDev?: boolean,
saveOptional?: boolean,
global?: boolean,
bin?: string,
production?: boolean,
development?: boolean,
optional?: boolean,
independentLeaves?: boolean,
packageImportMethod?: 'auto' | 'hardlink' | 'copy' | 'reflink',
ignoreScripts?: boolean,
childConcurrency?: number,
userAgent?: string,
unsafePerm?: boolean,
registry?: string,
lock?: boolean,
lockStaleDuration?: number,
tag?: string,
locks?: string,
}
export type StrictInstallOptions = InstallOptions & {
shrinkwrapOnly: boolean,
force: boolean,
update: boolean,
prefix: string,
depth: number,
repeatInstallDepth: number,
engineStrict: boolean,
nodeVersion: string,
offline: boolean,
rawNpmConfig: object,
verifyStoreIntegrity: boolean,
packageManager: {
name: string,
version: string,
},
hooks: {
readPackage?: ReadPackageHook,
},
saveExact: boolean,
savePrefix: string,
saveDev: boolean,
saveOptional: boolean,
global: boolean,
bin: string,
production: boolean,
development: boolean,
optional: boolean,
independentLeaves: boolean,
packageImportMethod: 'auto' | 'hardlink' | 'copy' | 'reflink',
ignoreScripts: boolean,
childConcurrency: number,
userAgent: string,
lock: boolean,
registry: string,
lockStaleDuration: number,
tag: string,
locks: string,
}
const defaults = async (opts: InstallOptions) => {
const packageManager = opts.packageManager || {
name: pnpmPkgJson.name,
version: pnpmPkgJson.version,
}
const prefix = opts.prefix || process.cwd()
return <StrictInstallOptions>{
storeController: opts.storeController,
shrinkwrapOnly: false,
saveExact: false,
global: false,
store: opts.store,
locks: path.join(opts.store, '_locks'),
ignoreScripts: false,
tag: 'latest',
production: true,
development: true,
bin: path.join(prefix, 'node_modules', '.bin'),
prefix,
nodeVersion: process.version,
force: false,
depth: 0,
engineStrict: false,
lockStaleDuration: 60 * 1000, // 1 minute
lock: true,
childConcurrency: 5,
offline: false,
registry: 'https://registry.npmjs.org/',
userAgent: `${packageManager.name}/${packageManager.version} npm/? node/${process.version} ${process.platform} ${process.arch}`,
rawNpmConfig: {},
update: false,
repeatInstallDepth: -1,
optional: typeof opts.production === 'boolean' ? opts.production : true,
independentLeaves: false,
packageManager,
verifyStoreIntegrity: true,
hooks: {},
savePrefix: '^',
unsafePerm: process.platform === 'win32' ||
process.platform === 'cygwin' ||
!(process.getuid && process.setuid &&
process.getgid && process.setgid) ||
process.getuid() !== 0,
packageImportMethod: 'auto',
saveDev: false,
saveOptional: false,
}
}
export default async (
opts: InstallOptions,
): Promise<StrictInstallOptions> => {
if (opts) {
for (const key in opts) {
if (opts[key] === undefined) {
delete opts[key]
}
}
}
const defaultOpts = await defaults(opts)
const extendedOpts = {...defaultOpts, ...opts, store: defaultOpts.store}
if (extendedOpts.force) {
logger.warn('using --force I sure hope you know what you are doing')
}
if (extendedOpts.lock === false) {
logger.warn('using --no-lock I sure hope you know what you are doing')
}
if (extendedOpts.userAgent.startsWith('npm/')) {
extendedOpts.userAgent = `${extendedOpts.packageManager.name}/${extendedOpts.packageManager.version} ${extendedOpts.userAgent}`
}
extendedOpts.registry = normalizeRegistryUrl(extendedOpts.registry)
if (extendedOpts.global) {
const subfolder = LAYOUT_VERSION.toString() + (extendedOpts.independentLeaves ? '_independent_leaves' : '')
extendedOpts.prefix = path.join(extendedOpts.prefix, subfolder)
}
extendedOpts.rawNpmConfig['registry'] = extendedOpts.registry
return extendedOpts
}

View File

@@ -1,101 +0,0 @@
import path = require('path')
import logger from '@pnpm/logger'
import pnpmPkgJson from '../pnpmPkgJson'
import {LAYOUT_VERSION} from '../fs/modulesController'
import normalizeRegistryUrl = require('normalize-registry-url')
import {resolveStore} from 'package-store'
import { SupiOptions, StrictSupiOptions } from '../types';
const defaults = async (opts: SupiOptions) => {
const packageManager = opts.packageManager || {
name: pnpmPkgJson.name,
version: pnpmPkgJson.version,
}
const prefix = opts.prefix || process.cwd()
const store = await resolveStore(opts.store, prefix)
return <StrictSupiOptions>{
fetchRetries: 2,
fetchRetryFactor: 10,
fetchRetryMintimeout: 1e4, // 10 seconds
fetchRetryMaxtimeout: 6e4, // 1 minute
store,
locks: path.join(store, '_locks'),
ignoreScripts: false,
strictSsl: true,
tag: 'latest',
production: true,
development: true,
bin: path.join(prefix, 'node_modules', '.bin'),
prefix,
nodeVersion: process.version,
force: false,
depth: 0,
engineStrict: false,
metaCache: new Map(),
networkConcurrency: 16,
fetchingConcurrency: 16,
lockStaleDuration: 60 * 1000, // 1 minute
lock: true,
childConcurrency: 5,
offline: false,
registry: 'https://registry.npmjs.org/',
userAgent: `${packageManager.name}/${packageManager.version} npm/? node/${process.version} ${process.platform} ${process.arch}`,
rawNpmConfig: {},
alwaysAuth: false,
update: false,
repeatInstallDepth: -1,
optional: typeof opts.production === 'boolean' ? opts.production : true,
independentLeaves: false,
packageManager,
verifyStoreIntegrity: true,
hooks: {},
savePrefix: '^',
unsafePerm: process.platform === 'win32' ||
process.platform === 'cygwin' ||
!(process.getuid && process.setuid &&
process.getgid && process.setgid) ||
process.getuid() !== 0,
packageImportMethod: 'auto',
}
}
export default async (
opts?: SupiOptions,
// TODO: remove this option.
// extendOptions is now called twice, which should not really be happening
logWarnings?: boolean,
): Promise<StrictSupiOptions> => {
opts = opts || {}
if (opts) {
for (const key in opts) {
if (opts[key] === undefined) {
delete opts[key]
}
}
}
if (opts.storePath && !opts.store) {
if (logWarnings !== false) {
logger.warn('the `store-path` config is deprecated. Use `store` instead.')
}
opts.store = opts.storePath
}
const defaultOpts = await defaults(opts)
const extendedOpts = {...defaultOpts, ...opts, store: defaultOpts.store}
if (logWarnings !== false && extendedOpts.force) {
logger.warn('using --force I sure hope you know what you are doing')
}
if (logWarnings !== false && extendedOpts.lock === false) {
logger.warn('using --no-lock I sure hope you know what you are doing')
}
if (extendedOpts.userAgent.startsWith('npm/')) {
extendedOpts.userAgent = `${extendedOpts.packageManager.name}/${extendedOpts.packageManager.version} ${extendedOpts.userAgent}`
}
extendedOpts.registry = normalizeRegistryUrl(extendedOpts.registry)
if (extendedOpts.global) {
const subfolder = LAYOUT_VERSION.toString() + (extendedOpts.independentLeaves ? '_independent_leaves' : '')
extendedOpts.prefix = path.join(extendedOpts.prefix, subfolder)
}
extendedOpts.rawNpmConfig['registry'] = extendedOpts.registry
extendedOpts.pending = extendedOpts.rawNpmConfig['pending']
return extendedOpts
}

View File

@@ -0,0 +1,77 @@
import path = require('path')
import logger from '@pnpm/logger'
import pnpmPkgJson from '../pnpmPkgJson'
import {LAYOUT_VERSION} from '../fs/modulesController'
import normalizeRegistryUrl = require('normalize-registry-url')
import {StoreController} from 'package-store'
import { ReporterFunction } from '../types'
export type PruneOptions = {
prefix?: string,
store: string,
independentLeaves?: boolean,
force?: boolean,
storeController: StoreController,
global?: boolean,
registry?: string,
reporter?: ReporterFunction,
production?: boolean,
development?: boolean,
optional?: boolean,
bin?: string,
}
export type StrictPruneOptions = PruneOptions & {
prefix: string,
store: string,
independentLeaves: boolean,
force: boolean,
storeController: StoreController,
global: boolean,
registry: string,
bin: string,
production: boolean,
development: boolean,
optional: boolean,
}
const defaults = async (opts: PruneOptions) => {
const prefix = opts.prefix || process.cwd()
return <StrictPruneOptions>{
storeController: opts.storeController,
global: false,
store: opts.store,
bin: path.join(prefix, 'node_modules', '.bin'),
prefix,
force: false,
registry: 'https://registry.npmjs.org/',
independentLeaves: false,
production: true,
development: true,
optional: true,
}
}
export default async (
opts: PruneOptions,
): Promise<StrictPruneOptions> => {
if (opts) {
for (const key in opts) {
if (opts[key] === undefined) {
delete opts[key]
}
}
}
const defaultOpts = await defaults(opts)
const extendedOpts = {...defaultOpts, ...opts, store: defaultOpts.store}
if (extendedOpts.force) {
logger.warn('using --force I sure hope you know what you are doing')
}
extendedOpts.registry = normalizeRegistryUrl(extendedOpts.registry)
if (extendedOpts.global) {
const subfolder = LAYOUT_VERSION.toString() + (extendedOpts.independentLeaves ? '_independent_leaves' : '')
extendedOpts.prefix = path.join(extendedOpts.prefix, subfolder)
}
return extendedOpts
}

View File

@@ -0,0 +1,97 @@
import path = require('path')
import logger from '@pnpm/logger'
import pnpmPkgJson from '../pnpmPkgJson'
import {LAYOUT_VERSION} from '../fs/modulesController'
import normalizeRegistryUrl = require('normalize-registry-url')
import {StoreController} from 'package-store'
import { ReporterFunction } from '../types'
export type RebuildOptions = {
prefix?: string,
store: string, // TODO: remove this property
independentLeaves?: boolean,
force?: boolean,
global?: boolean,
registry?: string,
reporter?: ReporterFunction,
production?: boolean,
development?: boolean,
optional?: boolean,
bin?: string,
rawNpmConfig?: object,
userAgent?: string,
packageManager?: {
name: string,
version: string,
},
unsafePerm?: boolean,
pending?: boolean,
}
export type StrictRebuildOptions = RebuildOptions & {
prefix: string,
store: string,
independentLeaves: boolean,
force: boolean,
global: boolean,
registry: string,
bin: string,
rawNpmConfig: object,
userAgent: string,
packageManager: {
name: string,
version: string,
},
unsafePerm: boolean,
pending: boolean,
}
const defaults = async (opts: RebuildOptions) => {
const packageManager = opts.packageManager || {
name: pnpmPkgJson.name,
version: pnpmPkgJson.version,
}
const prefix = opts.prefix || process.cwd()
return <StrictRebuildOptions>{
pending: false,
global: false,
store: opts.store,
bin: path.join(prefix, 'node_modules', '.bin'),
userAgent: `${packageManager.name}/${packageManager.version} npm/? node/${process.version} ${process.platform} ${process.arch}`,
packageManager,
prefix,
force: false,
registry: 'https://registry.npmjs.org/',
rawNpmConfig: {},
independentLeaves: false,
unsafePerm: process.platform === 'win32' ||
process.platform === 'cygwin' ||
!(process.getuid && process.setuid &&
process.getgid && process.setgid) ||
process.getuid() !== 0,
}
}
export default async (
opts: RebuildOptions,
): Promise<StrictRebuildOptions> => {
if (opts) {
for (const key in opts) {
if (opts[key] === undefined) {
delete opts[key]
}
}
}
const defaultOpts = await defaults(opts)
const extendedOpts = {...defaultOpts, ...opts, store: defaultOpts.store}
if (extendedOpts.force) {
logger.warn('using --force I sure hope you know what you are doing')
}
extendedOpts.registry = normalizeRegistryUrl(extendedOpts.registry)
if (extendedOpts.global) {
const subfolder = LAYOUT_VERSION.toString() + (extendedOpts.independentLeaves ? '_independent_leaves' : '')
extendedOpts.prefix = path.join(extendedOpts.prefix, subfolder)
}
return extendedOpts
}

View File

@@ -0,0 +1,69 @@
import path = require('path')
import logger from '@pnpm/logger'
import pnpmPkgJson from '../pnpmPkgJson'
import {LAYOUT_VERSION} from '../fs/modulesController'
import normalizeRegistryUrl = require('normalize-registry-url')
import {resolveStore, StoreController} from 'package-store'
import { ReporterFunction } from '../types'
import { ReadPackageHook } from '@pnpm/types'
export type StoreStatusOptions = {
prefix?: string,
store: string,
independentLeaves?: boolean,
force?: boolean,
global?: boolean,
registry?: string,
reporter?: ReporterFunction,
production?: boolean,
development?: boolean,
optional?: boolean,
bin?: string,
}
export type StrictStoreStatusOptions = StoreStatusOptions & {
prefix: string,
store: string,
independentLeaves: boolean,
force: boolean,
global: boolean,
registry: string,
bin: string,
}
const defaults = async (opts: StoreStatusOptions) => {
const prefix = opts.prefix || process.cwd()
return <StrictStoreStatusOptions>{
global: false,
store: opts.store,
bin: path.join(prefix, 'node_modules', '.bin'),
prefix,
force: false,
registry: 'https://registry.npmjs.org/',
independentLeaves: false,
}
}
export default async (
opts: StoreStatusOptions,
): Promise<StrictStoreStatusOptions> => {
if (opts) {
for (const key in opts) {
if (opts[key] === undefined) {
delete opts[key]
}
}
}
const defaultOpts = await defaults(opts)
const extendedOpts = {...defaultOpts, ...opts, store: defaultOpts.store}
if (extendedOpts.force) {
logger.warn('using --force I sure hope you know what you are doing')
}
extendedOpts.registry = normalizeRegistryUrl(extendedOpts.registry)
if (extendedOpts.global) {
const subfolder = LAYOUT_VERSION.toString() + (extendedOpts.independentLeaves ? '_independent_leaves' : '')
extendedOpts.prefix = path.join(extendedOpts.prefix, subfolder)
}
return extendedOpts
}

View File

@@ -0,0 +1,94 @@
import path = require('path')
import logger from '@pnpm/logger'
import pnpmPkgJson from '../pnpmPkgJson'
import {LAYOUT_VERSION} from '../fs/modulesController'
import normalizeRegistryUrl = require('normalize-registry-url')
import {StoreController} from 'package-store'
import { ReporterFunction } from '../types'
export type UninstallOptions = {
prefix?: string,
store: string,
independentLeaves?: boolean,
force?: boolean,
storeController: StoreController,
global?: boolean,
registry?: string,
reporter?: ReporterFunction,
lock?: boolean,
lockStaleDuration?: number,
locks?: string,
bin?: string,
packageManager?: {
name: string,
version: string,
},
}
export type StrictUninstallOptions = UninstallOptions & {
prefix: string,
store: string,
independentLeaves: boolean,
force: boolean,
storeController: StoreController,
global: boolean,
registry: string,
lock: boolean,
lockStaleDuration: number,
locks: string,
bin: string,
packageManager: {
name: string,
version: string,
},
}
const defaults = async (opts: UninstallOptions) => {
const packageManager = opts.packageManager || {
name: pnpmPkgJson.name,
version: pnpmPkgJson.version,
}
const prefix = opts.prefix || process.cwd()
return <StrictUninstallOptions>{
storeController: opts.storeController,
global: false,
store: opts.store,
locks: path.join(opts.store, '_locks'),
bin: path.join(prefix, 'node_modules', '.bin'),
prefix,
force: false,
lockStaleDuration: 60 * 1000, // 1 minute
lock: true,
registry: 'https://registry.npmjs.org/',
independentLeaves: false,
packageManager,
}
}
export default async (
opts: UninstallOptions,
): Promise<StrictUninstallOptions> => {
if (opts) {
for (const key in opts) {
if (opts[key] === undefined) {
delete opts[key]
}
}
}
const defaultOpts = await defaults(opts)
const extendedOpts = {...defaultOpts, ...opts, store: defaultOpts.store}
if (extendedOpts.force) {
logger.warn('using --force I sure hope you know what you are doing')
}
if (extendedOpts.lock === false) {
logger.warn('using --no-lock I sure hope you know what you are doing')
}
extendedOpts.registry = normalizeRegistryUrl(extendedOpts.registry)
if (extendedOpts.global) {
const subfolder = LAYOUT_VERSION.toString() + (extendedOpts.independentLeaves ? '_independent_leaves' : '')
extendedOpts.prefix = path.join(extendedOpts.prefix, subfolder)
}
return extendedOpts
}

View File

@@ -2,9 +2,6 @@ import path = require('path')
import isCI = require('is-ci')
import {fromDir as readPkgFromDir} from '../fs/readPkg'
import writePkg = require('write-pkg')
import createStore, {
StoreController,
} from 'package-store'
import {StrictSupiOptions} from '../types'
import {
readWanted as readWantedShrinkwrap,
@@ -22,12 +19,9 @@ import removeAllExceptOuterLinks = require('remove-all-except-outer-links')
import logger from '@pnpm/logger'
import checkCompatibility from './checkCompatibility'
import {packageJsonLogger} from '../loggers'
import createFetcher from '@pnpm/default-fetcher'
import createResolver from '@pnpm/default-resolver'
export type PnpmContext = {
pkg: PackageJson,
storeController: StoreController,
storePath: string,
root: string,
existsWantedShrinkwrap: boolean,
@@ -38,7 +32,17 @@ export type PnpmContext = {
pendingBuilds: string[],
}
export default async function getContext (opts: StrictSupiOptions, installType?: 'named' | 'general'): Promise<PnpmContext> {
export default async function getContext (
opts: {
prefix: string,
store: string,
independentLeaves: boolean,
force: boolean,
global: boolean,
registry: string,
},
installType?: 'named' | 'general',
): Promise<PnpmContext> {
const root = normalizePath(opts.prefix)
const storePath = opts.store
@@ -74,18 +78,6 @@ export default async function getContext (opts: StrictSupiOptions, installType?:
(opts.global ? readGlobalPkgJson(opts.prefix) : readPkgFromDir(opts.prefix)),
readWantedShrinkwrap(root, shrOpts),
readCurrentShrinkwrap(root, shrOpts),
opts.storeController
? Promise.resolve(opts.storeController)
: createStore(
createResolver(opts),
createFetcher(opts) as {},
{
networkConcurrency: opts.networkConcurrency,
store: opts.store,
locks: opts.lock ? opts.locks : undefined,
lockStaleDuration: opts.lockStaleDuration,
}
),
mkdirp(storePath),
])
const ctx: PnpmContext = {
@@ -96,7 +88,6 @@ export default async function getContext (opts: StrictSupiOptions, installType?:
currentShrinkwrap: files[2] || createShrinkwrap(opts.registry),
existsWantedShrinkwrap: !!files[1],
existsCurrentShrinkwrap: !!files[2],
storeController: files[3],
skipped: new Set(modules && modules.skipped || []),
pendingBuilds: modules && modules.pendingBuilds || [],
}

View File

@@ -3,6 +3,7 @@ import {
PackageJson,
PnpmOptions,
StrictPnpmOptions,
ReadPackageHook,
} from '@pnpm/types'
import * as dp from 'dependency-path'
import path = require('path')
@@ -24,6 +25,7 @@ import {fromDir as safeReadPkgFromDir} from '../fs/safeReadPkg'
import {
WantedDependency,
SupiOptions,
ReporterFunction,
} from '../types'
import getContext, {PnpmContext} from './getContext'
import installMultiple, {InstalledPackage} from '../install/installMultiple'
@@ -32,7 +34,10 @@ import linkPackages from '../link'
import save from '../save'
import getSaveType from '../getSaveType'
import postInstall, {npmRunScript} from '../install/postInstall'
import extendOptions from './extendOptions'
import extendOptions, {
InstallOptions,
StrictInstallOptions,
} from './extendInstallOptions'
import lock from './lock'
import {
write as saveShrinkwrap,
@@ -126,7 +131,7 @@ export type InstallContext = {
},
}
export async function install (maybeOpts?: SupiOptions) {
export async function install (maybeOpts: InstallOptions) {
const reporter = maybeOpts && maybeOpts.reporter
if (reporter) {
streamParser.on('data', reporter)
@@ -227,13 +232,15 @@ function specsToInstallFromPackage(
* @example
* install({'lodash': '1.0.0', 'foo': '^2.1.0' }, { silent: true })
*/
export async function installPkgs (fuzzyDeps: string[] | Dependencies, maybeOpts?: SupiOptions) {
export async function installPkgs (
fuzzyDeps: string[] | Dependencies,
maybeOpts: InstallOptions,
) {
const reporter = maybeOpts && maybeOpts.reporter
if (reporter) {
streamParser.on('data', reporter)
}
maybeOpts = maybeOpts || {}
if (maybeOpts.update === undefined) maybeOpts.update = true
const opts = await extendOptions(maybeOpts)
@@ -297,7 +304,7 @@ async function installInContext (
selector: string,
},
},
opts: StrictPnpmOptions
opts: StrictInstallOptions,
) {
// Unfortunately, the private shrinkwrap file may differ from the public one.
// A user might run named installations on a project that has a shrinkwrap.yaml file before running a noop install
@@ -354,7 +361,7 @@ async function installInContext (
engineStrict: opts.engineStrict,
nodeVersion: opts.nodeVersion,
pnpmVersion: opts.packageManager.name === 'pnpm' ? opts.packageManager.version : '',
storeController: ctx.storeController,
storeController: opts.storeController,
preferredVersions,
}
const installOpts = {
@@ -524,7 +531,7 @@ async function installInContext (
skipped: ctx.skipped,
pkg: newPkg || ctx.pkg,
independentLeaves: opts.independentLeaves,
storeController: ctx.storeController,
storeController: opts.storeController,
makePartialCurrentShrinkwrap,
updateShrinkwrapMinorVersion: installType === 'general' || R.isEmpty(ctx.currentShrinkwrap.packages),
outdatedPkgs: installCtx.outdatedPkgs,
@@ -616,7 +623,7 @@ async function installInContext (
summaryLogger.info(undefined)
await ctx.storeController.close()
await opts.storeController.close()
}
function buildTree (

View File

@@ -6,14 +6,16 @@ import {install} from './install'
import pathAbsolute = require('path-absolute')
import {linkPkgBins} from '../link/linkBins'
import {PnpmOptions} from '@pnpm/types'
import extendOptions from './extendOptions'
import extendOptions, {
InstallOptions,
} from './extendInstallOptions'
const linkLogger = logger('link')
export default async function link (
linkFrom: string,
linkTo: string,
maybeOpts?: PnpmOptions & {
maybeOpts: InstallOptions & {
skipInstall?: boolean,
linkToBin?: string,
}
@@ -53,7 +55,7 @@ async function linkToModules (linkFrom: string, modules: string) {
export async function linkFromGlobal (
pkgName: string,
linkTo: string,
maybeOpts: PnpmOptions & {globalPrefix: string}
maybeOpts: InstallOptions & {globalPrefix: string}
) {
const reporter = maybeOpts && maybeOpts.reporter
if (reporter) {
@@ -71,7 +73,7 @@ export async function linkFromGlobal (
export async function linkToGlobal (
linkFrom: string,
maybeOpts: PnpmOptions & {
maybeOpts: InstallOptions & {
globalPrefix: string,
globalBin: string,
}

View File

@@ -3,7 +3,10 @@ import path = require('path')
import R = require('ramda')
import getContext from './getContext'
import {PnpmOptions} from '@pnpm/types'
import extendOptions from './extendOptions'
import extendOptions, {
PruneOptions,
StrictPruneOptions,
} from './extendPruneOptions'
import getPkgDirs from '../fs/getPkgDirs'
import {fromDir as readPkgFromDir} from '../fs/readPkg'
import removeOrphanPkgs from './removeOrphanPkgs'
@@ -13,7 +16,9 @@ import {
} from 'pnpm-shrinkwrap'
import {streamParser} from '@pnpm/logger'
export async function prune(maybeOpts?: PnpmOptions): Promise<void> {
export async function prune (
maybeOpts: PruneOptions,
): Promise<void> {
const reporter = maybeOpts && maybeOpts.reporter
if (reporter) {
streamParser.on('data', reporter)
@@ -39,7 +44,7 @@ export async function prune(maybeOpts?: PnpmOptions): Promise<void> {
oldShrinkwrap: ctx.currentShrinkwrap,
newShrinkwrap: prunedShr,
prefix: ctx.root,
storeController: ctx.storeController,
storeController: opts.storeController,
pruneStore: true,
bin: opts.bin,
})

View File

@@ -1,5 +1,8 @@
import {PnpmOptions, StrictPnpmOptions} from '@pnpm/types'
import extendOptions from './extendOptions'
import extendOptions, {
RebuildOptions,
StrictRebuildOptions,
} from './extendRebuildOptions'
import getContext from './getContext'
import logger, {streamParser} from '@pnpm/logger'
import R = require('ramda')
@@ -50,14 +53,16 @@ type PackageSelector = string | {
range: string,
}
export async function rebuildPkgs (pkgSpecs: string[], maybeOpts: PnpmOptions) {
export async function rebuildPkgs (
pkgSpecs: string[],
maybeOpts: RebuildOptions,
) {
const reporter = maybeOpts && maybeOpts.reporter
if (reporter) {
streamParser.on('data', reporter)
}
const opts = await extendOptions(maybeOpts)
const ctx = await getContext(opts)
await ctx.storeController.close() // TODO: storeController should not be created at all in this case
const modules = path.join(opts.prefix, 'node_modules')
if (!ctx.currentShrinkwrap || !ctx.currentShrinkwrap.packages) return
@@ -97,14 +102,13 @@ function matches (
})
}
export async function rebuild (maybeOpts: PnpmOptions) {
export async function rebuild (maybeOpts: RebuildOptions) {
const reporter = maybeOpts && maybeOpts.reporter
if (reporter) {
streamParser.on('data', reporter)
}
const opts = await extendOptions(maybeOpts)
const ctx = await getContext(opts)
await ctx.storeController.close() // TODO: storeController should not be created at all in this case
const modules = path.join(opts.prefix, 'node_modules')
let idsToRebuild: string[] = []
@@ -135,7 +139,7 @@ async function _rebuild (
pkgs: PackageToRebuild[],
modules: string,
registry: string,
opts: StrictPnpmOptions
opts: StrictRebuildOptions,
) {
await pSeries(
pkgs

View File

@@ -1,18 +1,20 @@
import {PnpmOptions} from '@pnpm/types'
import extendOptions from './extendOptions'
import getContext from './getContext'
import {StoreController} from 'package-store'
import {streamParser} from '@pnpm/logger'
import {ReporterFunction} from '../types'
export default async function (maybeOpts: PnpmOptions) {
const reporter = maybeOpts && maybeOpts.reporter
export default async function (
opts: {
reporter?: ReporterFunction,
storeController: StoreController,
},
) {
const reporter = opts && opts.reporter
if (reporter) {
streamParser.on('data', reporter)
}
const opts = await extendOptions(maybeOpts)
const ctx = await getContext(opts)
await ctx.storeController.prune()
await ctx.storeController.saveState()
await ctx.storeController.close()
await opts.storeController.prune()
await opts.storeController.saveState()
await opts.storeController.close()
if (reporter) {
streamParser.removeListener('data', reporter)

View File

@@ -1,20 +1,20 @@
import path = require('path')
import pFilter = require('p-filter')
import {PnpmOptions} from '@pnpm/types'
import extendOptions from './extendOptions'
import extendOptions, {
StoreStatusOptions,
} from './extendStoreStatusOptions'
import getContext from './getContext'
import checkPackage from '@pnpm/check-package'
import * as dp from 'dependency-path'
import {streamParser} from '@pnpm/logger'
export default async function (maybeOpts: PnpmOptions) {
export default async function (maybeOpts: StoreStatusOptions) {
const reporter = maybeOpts && maybeOpts.reporter
if (reporter) {
streamParser.on('data', reporter)
}
const opts = await extendOptions(maybeOpts)
const ctx = await getContext(opts)
await ctx.storeController.close() // TODO: storeController should not be created at all in this case
if (!ctx.wantedShrinkwrap) return []
const pkgPaths = Object.keys(ctx.wantedShrinkwrap.packages || {})

View File

@@ -4,7 +4,10 @@ import * as dp from 'dependency-path'
import getContext, {PnpmContext} from './getContext'
import getSaveType from '../getSaveType'
import removeDeps from '../removeDeps'
import extendOptions from './extendOptions'
import extendOptions, {
UninstallOptions,
StrictUninstallOptions,
} from './extendUninstallOptions'
import {PnpmOptions, StrictPnpmOptions} from '@pnpm/types'
import lock from './lock'
import {
@@ -23,7 +26,10 @@ import removeTopDependency from '../removeTopDependency'
import shrinkwrapsEqual from './shrinkwrapsEqual'
import { SupiOptions, StrictSupiOptions } from '../types';
export default async function uninstall (pkgsToUninstall: string[], maybeOpts?: SupiOptions) {
export default async function uninstall (
pkgsToUninstall: string[],
maybeOpts: UninstallOptions,
) {
const reporter = maybeOpts && maybeOpts.reporter
if (reporter) {
streamParser.on('data', reporter)
@@ -52,7 +58,11 @@ export default async function uninstall (pkgsToUninstall: string[], maybeOpts?:
}
}
export async function uninstallInContext (pkgsToUninstall: string[], ctx: PnpmContext, opts: StrictSupiOptions) {
export async function uninstallInContext (
pkgsToUninstall: string[],
ctx: PnpmContext,
opts: StrictUninstallOptions,
) {
const makePartialCurrentShrinkwrap = !shrinkwrapsEqual(ctx.currentShrinkwrap, ctx.wantedShrinkwrap)
const pkgJsonPath = path.join(ctx.root, 'package.json')
@@ -63,11 +73,11 @@ export async function uninstallInContext (pkgsToUninstall: string[], ctx: PnpmCo
oldShrinkwrap: ctx.currentShrinkwrap,
newShrinkwrap: newShr,
prefix: ctx.root,
storeController: ctx.storeController,
storeController: opts.storeController,
bin: opts.bin,
})
ctx.pendingBuilds = ctx.pendingBuilds.filter(pkgId => !removedPkgIds.has(dp.resolve(newShr.registry, pkgId)))
await ctx.storeController.close()
await opts.storeController.close()
const currentShrinkwrap = makePartialCurrentShrinkwrap
? pruneShrinkwrap(ctx.currentShrinkwrap, pkg)
: newShr

View File

@@ -1,6 +1,8 @@
import path = require('path')
import {PnpmOptions, StrictPnpmOptions} from '@pnpm/types'
import extendOptions from './extendOptions'
import extendOptions, {
InstallOptions,
StrictInstallOptions,
} from './extendInstallOptions'
import isInnerLink = require('is-inner-link')
import logger, {streamParser} from '@pnpm/logger'
import rimraf = require('rimraf-then')
@@ -15,7 +17,7 @@ import isSubdir = require('is-subdir')
export async function unlinkPkgs (
pkgNames: string[],
maybeOpts: PnpmOptions
maybeOpts: InstallOptions
) {
const reporter = maybeOpts && maybeOpts.reporter
if (reporter) {
@@ -34,7 +36,7 @@ export async function unlinkPkgs (
export async function _unlinkPkgs (
pkgNames: string[],
opts: StrictPnpmOptions
opts: StrictInstallOptions
) {
const modules = path.join(opts.prefix, 'node_modules')
const pkg = await readPkgFromDir(opts.prefix)
@@ -57,7 +59,7 @@ export async function _unlinkPkgs (
await installPkgs(packagesToInstall, opts)
}
export async function unlink (maybeOpts: PnpmOptions) {
export async function unlink (maybeOpts: InstallOptions) {
const reporter = maybeOpts && maybeOpts.reporter
if (reporter) {
streamParser.on('data', reporter)
@@ -109,7 +111,7 @@ async function isExternalLink (store: string, modules: string, pkgName: string)
return !link.isInner && !isSubdir(store, link.target)
}
async function _extendOptions (maybeOpts: PnpmOptions): Promise<StrictPnpmOptions> {
async function _extendOptions (maybeOpts: InstallOptions): Promise<StrictInstallOptions> {
maybeOpts = maybeOpts || {}
if (maybeOpts.depth === undefined) maybeOpts.depth = -1
return await extendOptions(maybeOpts)

View File

@@ -15,6 +15,11 @@ export {
StatsLog,
} from './loggers'
export {InstallOptions} from './api/extendInstallOptions'
export {PruneOptions} from './api/extendPruneOptions'
export {RebuildOptions} from './api/extendRebuildOptions'
export {UninstallOptions} from './api/extendUninstallOptions'
import * as supiLogs from './loggers'
import * as packageRequesterLogs from '@pnpm/package-requester'

View File

@@ -85,7 +85,6 @@ export default async function installMultiple (
update: boolean,
readPackageHook?: ReadPackageHook,
hasManifestInShrinkwrap: boolean,
ignoreFile?: (filename: string) => boolean,
}
): Promise<PkgAddress[]> {
const resolvedDependencies = options.resolvedDependencies || {}
@@ -118,7 +117,6 @@ export default async function installMultiple (
parentIsInstallable: options.parentIsInstallable,
readPackageHook: options.readPackageHook,
hasManifestInShrinkwrap: options.hasManifestInShrinkwrap,
ignoreFile: options.ignoreFile,
update,
proceed,
},
@@ -502,7 +500,6 @@ async function installDependencies (
readPackageHook?: ReadPackageHook,
hasManifestInShrinkwrap: boolean,
useManifestInfoFromShrinkwrap: boolean,
ignoreFile?: (filename: string) => boolean,
}
): Promise<PkgAddress[]> {

View File

@@ -17,10 +17,12 @@ export type WantedDependency = {
}
export type SupiOptions = PnpmOptions & {
storeController?: StoreController
storeController: StoreController
}
export type StrictSupiOptions = StrictPnpmOptions & {
storeController?: StoreController
storeController: StoreController
pending?: boolean
}
export type ReporterFunction = (logObj: LogBase) => void

View File

@@ -1,5 +1,6 @@
import test = require('tape')
import * as pnpm from 'supi'
import {testDefaults} from './utils'
test('API', t => {
t.equal(typeof pnpm.install, 'function', 'exports install()')
@@ -18,7 +19,7 @@ test('API', t => {
// the dependency will be saved
test.skip('install fails when all saving types are false', async (t: test.Test) => {
try {
await pnpm.install({save: false, saveDev: false, saveOptional: false})
await pnpm.install(await testDefaults({save: false, saveDev: false, saveOptional: false}))
t.fail('installation should have failed')
} catch (err) {
t.equal(err.message, 'Cannot install with save/saveDev/saveOptional all being equal false')
@@ -28,7 +29,7 @@ test.skip('install fails when all saving types are false', async (t: test.Test)
test('install fails on optional = true but production = false', async (t: test.Test) => {
try {
await pnpm.install({optional: true, production: false})
await pnpm.install(await testDefaults({optional: true, production: false}))
t.fail('installation should have failed')
} catch (err) {
t.equal(err.message, 'Optional dependencies cannot be installed without production dependencies')

View File

@@ -2,20 +2,17 @@ import tape = require('tape')
import promisifyTape from 'tape-promise'
import fs = require('mz/fs')
import mkdirp = require('mkdirp-promise')
import path = require('path')
import isCI = require('is-ci')
import {prepare, testDefaults} from './utils'
import {installPkgs, install} from 'supi'
const test = promisifyTape(tape)
const STORE_VERSION = '2'
test('fail on non-compatible node_modules', async t => {
const project = prepare(t)
const opts = testDefaults()
const opts = await testDefaults()
await saveModulesYaml('0.50.0', path.join(opts.store, STORE_VERSION))
await saveModulesYaml('0.50.0', opts.store)
try {
await installPkgs(['is-negative'], opts)
@@ -27,9 +24,9 @@ test('fail on non-compatible node_modules', async t => {
test("don't fail on non-compatible node_modules when forced", async t => {
const project = prepare(t)
const opts = testDefaults({force: true})
const opts = await testDefaults({force: true})
await saveModulesYaml('0.50.0', path.join(opts.store, STORE_VERSION))
await saveModulesYaml('0.50.0', opts.store)
await install(opts)
@@ -38,9 +35,9 @@ test("don't fail on non-compatible node_modules when forced", async t => {
test('fail on non-compatible node_modules when forced with a named installation', async t => {
const project = prepare(t)
const opts = testDefaults({force: true})
const opts = await testDefaults({force: true})
await saveModulesYaml('0.50.0', path.join(opts.store, STORE_VERSION))
await saveModulesYaml('0.50.0', opts.store)
try {
await installPkgs(['is-negative'], opts)
@@ -52,9 +49,9 @@ test('fail on non-compatible node_modules when forced with a named installation'
test("don't fail on non-compatible store when forced", async t => {
const project = prepare(t)
const opts = testDefaults({force: true})
const opts = await testDefaults({force: true})
await saveModulesYaml('0.32.0', path.join(opts.store, STORE_VERSION))
await saveModulesYaml('0.32.0', opts.store)
await install(opts)
@@ -63,9 +60,9 @@ test("don't fail on non-compatible store when forced", async t => {
test('fail on non-compatible store when forced during named installation', async t => {
const project = prepare(t)
const opts = testDefaults({force: true})
const opts = await testDefaults({force: true})
await saveModulesYaml('0.32.0', path.join(opts.store, STORE_VERSION))
await saveModulesYaml('0.32.0', opts.store)
try {
await installPkgs(['is-negative'], opts)
@@ -90,7 +87,7 @@ test('fail on non-compatible shrinkwrap.yaml', async t => {
await fs.writeFile('shrinkwrap.yaml', '')
try {
await installPkgs(['is-negative'], testDefaults())
await installPkgs(['is-negative'], await testDefaults())
t.fail('should have failed')
} catch (err) {
t.equal(err.code, 'SHRINKWRAP_BREAKING_CHANGE', 'shrinkwrap breaking change error is thrown')
@@ -101,7 +98,7 @@ test("don't fail on non-compatible shrinkwrap.yaml when forced", async t => {
const project = prepare(t)
await fs.writeFile('shrinkwrap.yaml', '')
await installPkgs(['is-negative'], testDefaults({force: true}))
await installPkgs(['is-negative'], await testDefaults({force: true}))
t.pass('install did not fail')
})

View File

@@ -1,5 +1,9 @@
import {installPkgs, install} from 'supi'
import {prepare, addDistTag, testDefaults} from './utils'
import {
prepare,
addDistTag,
testDefaults,
} from './utils'
import tape = require('tape')
import promisifyTape from 'tape-promise'
import exists = require('path-exists')
@@ -14,13 +18,13 @@ test('should fail to update when requests are cached', async function (t) {
await addDistTag('dep-of-pkg-with-1-dep', '100.0.0', 'latest')
await installPkgs(['pkg-with-1-dep'], testDefaults({save: true, metaCache}))
await installPkgs(['pkg-with-1-dep'], await testDefaults({save: true, metaCache}))
await project.storeHas('dep-of-pkg-with-1-dep', '100.0.0')
await addDistTag('dep-of-pkg-with-1-dep', '100.1.0', 'latest')
await install(testDefaults({depth: 1, metaCache, update: true}))
await install(await testDefaults({depth: 1, metaCache, update: true}))
await project.storeHas('dep-of-pkg-with-1-dep', '100.0.0')
})
@@ -30,13 +34,13 @@ test('should not cache when cache is not used', async (t: tape.Test) => {
await addDistTag('dep-of-pkg-with-1-dep', '100.0.0', 'latest')
await installPkgs(['pkg-with-1-dep'], testDefaults({save: true}))
await installPkgs(['pkg-with-1-dep'], await testDefaults({save: true}))
await project.storeHas('dep-of-pkg-with-1-dep', '100.0.0')
await addDistTag('dep-of-pkg-with-1-dep', '100.1.0', 'latest')
await install(testDefaults({depth: 1, update: true}))
await install(await testDefaults({depth: 1, update: true}))
await project.storeHas('dep-of-pkg-with-1-dep', '100.1.0')
})

View File

@@ -15,7 +15,7 @@ const test = promisifyTape(tape)
test('installing aliased dependency', async (t: tape.Test) => {
const project = prepare(t)
await installPkgs(['negative@npm:is-negative@1.0.0'], testDefaults())
await installPkgs(['negative@npm:is-negative@1.0.0'], await testDefaults())
const m = project.requireModule('negative')
t.ok(typeof m === 'function', 'negative() is available')
@@ -47,7 +47,7 @@ test('installing aliased dependency', async (t: tape.Test) => {
test('a dependency has an aliased subdependency', async (t: tape.Test) => {
const project = prepare(t)
await installPkgs(['pkg-with-1-aliased-dep'], testDefaults())
await installPkgs(['pkg-with-1-aliased-dep'], await testDefaults())
t.equal(project.requireModule('pkg-with-1-aliased-dep')().name, 'dep-of-pkg-with-1-dep', 'can require aliased subdep')

View File

@@ -27,10 +27,14 @@ test('a package that need authentication', async function (t: tape.Test) {
}, (err: Error, data: Object) => err ? reject(err) : resolve(data))
})
await installPkgs(['needs-auth'], testDefaults({
rawNpmConfig: {
'//localhost:4873/:_authToken': data['token'],
},
let rawNpmConfig = {
registry: 'http://localhost:4873/',
'//localhost:4873/:_authToken': data['token'],
}
await installPkgs(['needs-auth'], await testDefaults({}, {
rawNpmConfig,
}, {
rawNpmConfig,
}))
const m = project.requireModule('needs-auth')
@@ -42,12 +46,15 @@ test('a package that need authentication', async function (t: tape.Test) {
await rimraf('node_modules')
await rimraf(path.join('..', '.store'))
await installPkgs(['needs-auth'], testDefaults({
rawNpmConfig = {
registry: 'https://registry.npmjs.org/',
rawNpmConfig: {
registry: 'https://registry.npmjs.org/',
'//localhost:4873/:_authToken': data['token'],
},
'//localhost:4873/:_authToken': data['token'],
}
await installPkgs(['needs-auth'], await testDefaults({}, {
registry: 'https://registry.npmjs.org/',
rawNpmConfig,
}, {
rawNpmConfig,
}))
await project.has('needs-auth')
@@ -68,12 +75,15 @@ test('a package that need authentication, legacy way', async function (t: tape.T
}, (err: Error, data: Object) => err ? reject(err) : resolve(data))
})
await installPkgs(['needs-auth'], testDefaults({
rawNpmConfig: {
'_auth': 'Zm9vOmJhcg==', // base64 encoded foo:bar
'always-auth': true,
registry: 'http://localhost:4873',
},
const rawNpmConfig = {
'_auth': 'Zm9vOmJhcg==', // base64 encoded foo:bar
'always-auth': true,
registry: 'http://localhost:4873',
}
await installPkgs(['needs-auth'], await testDefaults({}, {
rawNpmConfig,
}, {
rawNpmConfig,
}))
const m = project.requireModule('needs-auth')
@@ -96,13 +106,16 @@ test('a scoped package that need authentication specific to scope', async functi
}, (err: Error, data: Object) => err ? reject(err) : resolve(data))
})
const opts = testDefaults({
const rawNpmConfig = {
registry: 'https://registry.npmjs.org/',
rawNpmConfig: {
registry: 'https://registry.npmjs.org/',
'@private:registry': 'http://localhost:4873/',
'//localhost:4873/:_authToken': data['token'],
},
'@private:registry': 'http://localhost:4873/',
'//localhost:4873/:_authToken': data['token'],
}
let opts = await testDefaults({}, {
registry: 'https://registry.npmjs.org/',
rawNpmConfig,
}, {
rawNpmConfig,
})
await installPkgs(['@private/foo'], opts)
@@ -112,6 +125,13 @@ test('a scoped package that need authentication specific to scope', async functi
await rimraf('node_modules')
await rimraf(path.join('..', '.store'))
// Recreating options to have a new storeController with clean cache
opts = await testDefaults({}, {
registry: 'https://registry.npmjs.org/',
rawNpmConfig,
}, {
rawNpmConfig,
})
await installPkgs(['@private/foo'], opts)
await project.has('@private/foo')
@@ -132,12 +152,18 @@ test('a package that need authentication reuses authorization tokens for tarball
}, (err: Error, data: Object) => err ? reject(err) : resolve(data))
})
await installPkgs(['needs-auth'], testDefaults({
const rawNpmConfig = {
registry: 'http://127.0.0.1:4873',
rawNpmConfig: {
'//127.0.0.1:4873/:_authToken': data['token'],
'//127.0.0.1:4873/:always-auth': true,
},
'//127.0.0.1:4873/:_authToken': data['token'],
'//127.0.0.1:4873/:always-auth': true,
}
await installPkgs(['needs-auth'], await testDefaults({
registry: 'http://127.0.0.1:4873',
}, {
registry: 'http://127.0.0.1:4873',
rawNpmConfig,
}, {
rawNpmConfig,
}))
const m = project.requireModule('needs-auth')
@@ -160,12 +186,18 @@ test('a package that need authentication reuses authorization tokens for tarball
}, (err: Error, data: Object) => err ? reject(err) : resolve(data))
})
const opts = testDefaults({
const rawNpmConfig = {
registry: 'http://127.0.0.1:4873',
rawNpmConfig: {
'//127.0.0.1:4873/:_authToken': data['token'],
'//127.0.0.1:4873/:always-auth': true,
},
'//127.0.0.1:4873/:_authToken': data['token'],
'//127.0.0.1:4873/:always-auth': true,
}
let opts = await testDefaults({
registry: 'http://127.0.0.1:4873',
}, {
registry: 'http://127.0.0.1:4873',
rawNpmConfig,
}, {
rawNpmConfig,
})
await installPkgs(['needs-auth'], opts)
@@ -174,6 +206,15 @@ test('a package that need authentication reuses authorization tokens for tarball
await rimraf(path.join('..', '.registry'))
await rimraf(path.join('..', '.store'))
// Recreating options to clean store cache
opts = await testDefaults({
registry: 'http://127.0.0.1:4873',
}, {
registry: 'http://127.0.0.1:4873',
rawNpmConfig,
}, {
rawNpmConfig,
})
await install(opts)
const m = project.requireModule('needs-auth')

View File

@@ -19,7 +19,7 @@ test('prefer version ranges specified for top dependencies', async (t: tape.Test
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
await install(testDefaults())
await install(await testDefaults())
const shr = await project.loadShrinkwrap()
t.ok(shr.packages['/dep-of-pkg-with-1-dep/100.0.0'])
@@ -35,8 +35,8 @@ test('prefer version ranges specified for top dependencies, when doing named ins
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
await install(testDefaults())
await installPkgs(['pkg-with-1-dep'], testDefaults())
await install(await testDefaults())
await installPkgs(['pkg-with-1-dep'], await testDefaults())
const shr = await project.loadShrinkwrap()
t.ok(shr.packages['/dep-of-pkg-with-1-dep/100.0.0'])
@@ -53,7 +53,7 @@ test('prefer version ranges specified for top dependencies, even if they are ali
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
await install(testDefaults())
await install(await testDefaults())
const shr = await project.loadShrinkwrap()
t.ok(shr.packages['/dep-of-pkg-with-1-dep/100.0.0'])
@@ -70,7 +70,7 @@ test('prefer version ranges specified for top dependencies, even if the subdepen
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
await install(testDefaults())
await install(await testDefaults())
const shr = await project.loadShrinkwrap()
t.ok(shr.packages['/dep-of-pkg-with-1-dep/100.0.0'])
@@ -87,7 +87,7 @@ test('ignore version of root dependency when it is incompatible with the indirec
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.0.0', distTag: 'latest' })
await install(testDefaults())
await install(await testDefaults())
const shr = await project.loadShrinkwrap()
t.ok(shr.packages['/dep-of-pkg-with-1-dep/100.0.0'])
@@ -105,7 +105,7 @@ test('prefer dist-tag specified for top dependency', async (t: tape.Test) => {
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.0.0', distTag: 'stable' })
await install(testDefaults())
await install(await testDefaults())
const shr = await project.loadShrinkwrap()
t.ok(shr.packages['/dep-of-pkg-with-1-dep/100.0.0'])

View File

@@ -19,7 +19,7 @@ const test = promisifyTape(tape)
test('from a github repo', async (t: tape.Test) => {
const project = prepare(t)
await installPkgs(['kevva/is-negative'], testDefaults())
await installPkgs(['kevva/is-negative'], await testDefaults())
const m = project.requireModule('is-negative')
@@ -34,7 +34,7 @@ test('from a github repo with different name via named installation', async func
const reporter = sinon.spy()
await installPkgs(['say-hi@github:zkochan/hi#4cdebec76b7b9d1f6e219e06c42d92a6b8ea60cd'], testDefaults({reporter}))
await installPkgs(['say-hi@github:zkochan/hi#4cdebec76b7b9d1f6e219e06c42d92a6b8ea60cd'], await testDefaults({reporter}))
const m = project.requireModule('say-hi')
@@ -73,7 +73,7 @@ test('from a github repo with different name', async function (t: tape.Test) {
const reporter = sinon.spy()
await install(testDefaults({reporter}))
await install(await testDefaults({reporter}))
const m = project.requireModule('say-hi')
@@ -105,7 +105,7 @@ test('from a github repo with different name', async function (t: tape.Test) {
test('a subdependency is from a github repo with different name', async function (t: tape.Test) {
const project = prepare(t)
await installPkgs(['has-aliased-git-dependency'], testDefaults())
await installPkgs(['has-aliased-git-dependency'], await testDefaults())
const m = project.requireModule('has-aliased-git-dependency')
@@ -130,7 +130,7 @@ test('from a git repo', async (t: tape.Test) => {
return t.end()
}
const project = prepare(t)
await installPkgs(['git+ssh://git@github.com/kevva/is-negative.git'], testDefaults())
await installPkgs(['git+ssh://git@github.com/kevva/is-negative.git'], await testDefaults())
const m = project.requireModule('is-negative')
@@ -140,7 +140,7 @@ test('from a git repo', async (t: tape.Test) => {
test('from a non-github git repo', async (t: tape.Test) => {
const project = prepare(t)
await installPkgs(['git+http://ikt.pm2.io/ikt.git#3325a3e39a502418dc2e2e4bf21529cbbde96228'], testDefaults())
await installPkgs(['git+http://ikt.pm2.io/ikt.git#3325a3e39a502418dc2e2e4bf21529cbbde96228'], await testDefaults())
const m = project.requireModule('ikt')

View File

@@ -11,7 +11,7 @@ const test = promisifyTape(tape)
test('tarball from npm registry', async function (t) {
const project = prepare(t)
await installPkgs(['http://registry.npmjs.org/is-array/-/is-array-1.0.1.tgz'], testDefaults())
await installPkgs(['http://registry.npmjs.org/is-array/-/is-array-1.0.1.tgz'], await testDefaults())
const m = project.requireModule('is-array')
@@ -25,7 +25,7 @@ test('tarball from npm registry', async function (t) {
test('tarball not from npm registry', async function (t) {
const project = prepare(t)
await installPkgs(['https://github.com/hegemonic/taffydb/tarball/master'], testDefaults())
await installPkgs(['https://github.com/hegemonic/taffydb/tarball/master'], await testDefaults())
const m = project.requireModule('taffydb')
@@ -36,7 +36,7 @@ test('tarball not from npm registry', async function (t) {
test('tarballs from GitHub (is-negative)', async function (t) {
const project = prepare(t)
await installPkgs(['is-negative@https://github.com/kevva/is-negative/archive/1d7e288222b53a0cab90a331f1865220ec29560c.tar.gz'], testDefaults())
await installPkgs(['is-negative@https://github.com/kevva/is-negative/archive/1d7e288222b53a0cab90a331f1865220ec29560c.tar.gz'], await testDefaults())
const m = project.requireModule('is-negative')

View File

@@ -2,7 +2,11 @@ import tape = require('tape')
import promisifyTape from 'tape-promise'
import path = require('path')
import readPkg = require('read-pkg')
import {prepare, testDefaults, addDistTag} from '../utils'
import {
prepare,
testDefaults,
addDistTag,
} from '../utils'
import {installPkgs} from 'supi'
const test = promisifyTape(tape)
@@ -12,7 +16,7 @@ const LAYOUT_VERSION = '1'
test('global installation', async function (t) {
prepare(t)
const globalPrefix = path.resolve('..', 'global')
const opts = testDefaults({global: true, prefix: globalPrefix})
const opts = await testDefaults({global: true, prefix: globalPrefix})
await installPkgs(['is-positive'], opts)
// there was an issue when subsequent installations were removing everything installed prior
@@ -31,7 +35,7 @@ test('always install latest when doing global installation without spec', async
const project = prepare(t)
const globalPrefix = process.cwd()
const opts = testDefaults({global: true, prefix: globalPrefix})
const opts = await testDefaults({global: true, prefix: globalPrefix})
await installPkgs(['peer-c@1'], opts)
await installPkgs(['peer-c'], opts)

View File

@@ -22,7 +22,7 @@ test('readPackage hook', async (t: tape.Test) => {
return pkg
}
await installPkgs(['pkg-with-1-dep'], testDefaults({
await installPkgs(['pkg-with-1-dep'], await testDefaults({
hooks: {readPackage: readPackageHook}
}))

View File

@@ -11,7 +11,7 @@ const test = promisifyTape(tape)
test('install with --independent-leaves', async function (t: tape.Test) {
const project = prepare(t)
await installPkgs(['rimraf@2.5.1'], testDefaults({independentLeaves: true}))
await installPkgs(['rimraf@2.5.1'], await testDefaults({independentLeaves: true}))
const m = project.requireModule('rimraf')
t.ok(typeof m === 'function', 'rimraf() is available')
@@ -20,10 +20,10 @@ test('install with --independent-leaves', async function (t: tape.Test) {
test('--independent-leaves throws exception when executed on node_modules installed w/o the option', async function (t: tape.Test) {
const project = prepare(t)
await installPkgs(['is-positive'], testDefaults({independentLeaves: false}))
await installPkgs(['is-positive'], await testDefaults({independentLeaves: false}))
try {
await installPkgs(['is-negative'], testDefaults({independentLeaves: true}))
await installPkgs(['is-negative'], await testDefaults({independentLeaves: true}))
t.fail('installation should have failed')
} catch (err) {
t.ok(err.message.indexOf('This node_modules was not installed with the --independent-leaves option.') === 0)
@@ -32,10 +32,10 @@ test('--independent-leaves throws exception when executed on node_modules instal
test('--no-independent-leaves throws exception when executed on node_modules installed with --independent-leaves', async function (t: tape.Test) {
const project = prepare(t)
await installPkgs(['is-positive'], testDefaults({independentLeaves: true}))
await installPkgs(['is-positive'], await testDefaults({independentLeaves: true}))
try {
await installPkgs(['is-negative'], testDefaults({independentLeaves: false}))
await installPkgs(['is-negative'], await testDefaults({independentLeaves: false}))
t.fail('installation should have failed')
} catch (err) {
t.ok(err.message.indexOf('This node_modules was installed with --independent-leaves option.') === 0)
@@ -45,7 +45,7 @@ test('--no-independent-leaves throws exception when executed on node_modules ins
test('global installation with --independent-leaves', async function (t: tape.Test) {
prepare(t)
const globalPrefix = path.resolve('..', 'global')
const opts = testDefaults({global: true, prefix: globalPrefix, independentLeaves: true})
const opts = await testDefaults({global: true, prefix: globalPrefix, independentLeaves: true})
await installPkgs(['is-positive'], opts)
// there was an issue when subsequent installations were removing everything installed prior

View File

@@ -9,7 +9,7 @@ test('fail if installed package does not support the current engine and engine-s
const project = prepare(t)
try {
await installPkgs(['not-compatible-with-any-os'], testDefaults({
await installPkgs(['not-compatible-with-any-os'], await testDefaults({
engineStrict: true
}))
t.fail()
@@ -22,7 +22,7 @@ test('fail if installed package does not support the current engine and engine-s
test('do not fail if installed package does not support the current engine and engine-strict = false', async function (t: tape.Test) {
const project = prepare(t)
await installPkgs(['not-compatible-with-any-os'], testDefaults({
await installPkgs(['not-compatible-with-any-os'], await testDefaults({
engineStrict: false
}))
@@ -36,7 +36,7 @@ test('do not fail if installed package does not support the current engine and e
test('do not fail if installed package requires the node version that was passed in and engine-strict = true', async function (t: tape.Test) {
const project = prepare(t)
await installPkgs(['for-legacy-node'], testDefaults({
await installPkgs(['for-legacy-node'], await testDefaults({
engineStrict: true,
nodeVersion: '0.10.0'
}))
@@ -51,7 +51,7 @@ test('do not fail if installed package requires the node version that was passed
test('save cpu field to shrinkwrap.yaml', async function (t: tape.Test) {
const project = prepare(t)
await installPkgs(['has-cpu-specified'], testDefaults())
await installPkgs(['has-cpu-specified'], await testDefaults())
const shr = await project.loadShrinkwrap()
@@ -65,7 +65,7 @@ test('save cpu field to shrinkwrap.yaml', async function (t: tape.Test) {
test('engines field is not added to shrinkwrap.yaml when "node": "*" is in "engines" field', async function (t: tape.Test) {
const project = prepare(t)
await installPkgs(['jsonify@0.0.0'], testDefaults())
await installPkgs(['jsonify@0.0.0'], await testDefaults())
const shr = await project.loadShrinkwrap()

View File

@@ -23,7 +23,7 @@ const test = promisifyTape(tape)
test('run pre/postinstall scripts', async function (t: tape.Test) {
const project = prepare(t)
await installPkgs(['pre-and-postinstall-scripts-example'], testDefaults({saveDev: true}))
await installPkgs(['pre-and-postinstall-scripts-example'], await testDefaults({saveDev: true}))
const generatedByPreinstall = project.requireModule('pre-and-postinstall-scripts-example/generated-by-preinstall')
t.ok(typeof generatedByPreinstall === 'function', 'generatedByPreinstall() is available')
@@ -36,7 +36,7 @@ test('run pre/postinstall scripts', async function (t: tape.Test) {
// testing that the packages are not installed even though they are in shrinkwrap
// and that their scripts are not tried to be executed
await install(testDefaults({production: true}))
await install(await testDefaults({production: true}))
{
const generatedByPreinstall = project.requireModule('pre-and-postinstall-scripts-example/generated-by-preinstall')
@@ -50,8 +50,8 @@ test('run pre/postinstall scripts', async function (t: tape.Test) {
test('testing that the bins are linked when the package with the bins was already in node_modules', async function (t: tape.Test) {
const project = prepare(t)
await installPkgs(['hello-world-js-bin'], testDefaults())
await installPkgs(['pre-and-postinstall-scripts-example'], testDefaults({saveDev: true}))
await installPkgs(['hello-world-js-bin'], await testDefaults())
await installPkgs(['pre-and-postinstall-scripts-example'], await testDefaults({saveDev: true}))
const generatedByPreinstall = project.requireModule('pre-and-postinstall-scripts-example/generated-by-preinstall')
t.ok(typeof generatedByPreinstall === 'function', 'generatedByPreinstall() is available')
@@ -62,7 +62,7 @@ test('testing that the bins are linked when the package with the bins was alread
test('run install scripts', async function (t) {
const project = prepare(t)
await installPkgs(['install-script-example'], testDefaults())
await installPkgs(['install-script-example'], await testDefaults())
const generatedByInstall = project.requireModule('install-script-example/generated-by-install')
t.ok(typeof generatedByInstall === 'function', 'generatedByInstall() is available')
@@ -76,8 +76,8 @@ test('run install scripts in the current project', async (t: tape.Test) => {
postinstall: `node -e "process.stdout.write('postinstall')" | json-append output.json`,
}
})
await installPkgs(['json-append@1.1.1'], testDefaults())
await install(testDefaults())
await installPkgs(['json-append@1.1.1'], await testDefaults())
await install(await testDefaults())
const output = await loadJsonFile('output.json')
@@ -93,8 +93,8 @@ test('run install scripts in the current project when its name is different than
postinstall: `node -e "process.stdout.write('postinstall')" | json-append output.json`,
}
})
await installPkgs(['json-append@1.1.1'], testDefaults())
await install(testDefaults())
await installPkgs(['json-append@1.1.1'], await testDefaults())
await install(await testDefaults())
const output = await loadJsonFile('output.json')
@@ -110,7 +110,7 @@ test('do not run install scripts if unsafePerm is false', async (t: tape.Test) =
postinstall: `node -e "process.stdout.write('postinstall')" | json-append output.json`,
}
})
const opts = testDefaults({ unsafePerm: false })
const opts = await testDefaults({ unsafePerm: false })
await installPkgs(['json-append@1.1.1'], opts)
await install(opts)
@@ -127,7 +127,7 @@ test('installation fails if lifecycle script fails', async (t: tape.Test) => {
})
try {
await install(testDefaults())
await install(await testDefaults())
t.fail('should have failed')
} catch (err) {
t.equal(err['code'], 'ELIFECYCLE', 'failed with correct error code')
@@ -142,8 +142,8 @@ test['skip']('creates env for scripts', async (t: tape.Test) => {
install: `node -e "process.stdout.write(process.env.INIT_CWD)" | json-append output.json`,
}
})
await installPkgs(['json-append@1.1.1'], testDefaults())
await install(testDefaults())
await installPkgs(['json-append@1.1.1'], await testDefaults())
await install(await testDefaults())
const output = await loadJsonFile('output.json')
@@ -152,7 +152,7 @@ test['skip']('creates env for scripts', async (t: tape.Test) => {
test('INIT_CWD is set correctly', async (t: tape.Test) => {
const project = prepare(t)
await installPkgs(['write-lifecycle-env'], testDefaults())
await installPkgs(['write-lifecycle-env'], await testDefaults())
const childEnv = await loadJsonFile(path.resolve('node_modules', 'write-lifecycle-env', 'env.json'))
@@ -164,7 +164,7 @@ test("reports child's output", async (t: tape.Test) => {
const reporter = sinon.spy()
await installPkgs(['count-to-10'], testDefaults({reporter}))
await installPkgs(['count-to-10'], await testDefaults({reporter}))
t.ok(reporter.calledWithMatch(<LifecycleLog>{
name: 'pnpm:lifecycle',
@@ -199,7 +199,7 @@ test("reports child's close event", async (t: tape.Test) => {
const reporter = sinon.spy()
try {
await installPkgs(['failing-postinstall'], testDefaults({reporter}))
await installPkgs(['failing-postinstall'], await testDefaults({reporter}))
t.fail()
} catch (err) {
t.ok(reporter.calledWithMatch(<LifecycleLog>{
@@ -226,7 +226,7 @@ test('lifecycle scripts have access to node-gyp', async (t: tape.Test) => {
.filter((p: string) => !p.includes('node-gyp-bin') && !p.includes('npm'))
.join(path.delimiter)
await installPkgs(['drivelist@5.1.8'], testDefaults())
await installPkgs(['drivelist@5.1.8'], await testDefaults())
process.env[PATH] = initialPath

View File

@@ -18,7 +18,7 @@ const test = promisifyTape(tape)
test('scoped modules from a directory', async function (t: tape.Test) {
const project = prepare(t)
await installPkgs([local('local-scoped-pkg')], testDefaults())
await installPkgs([local('local-scoped-pkg')], await testDefaults())
const m = project.requireModule('@scope/local-scoped-pkg')
@@ -29,7 +29,7 @@ test('local file', async function (t: tape.Test) {
const project = prepare(t)
await ncp(pathToLocalPkg('local-pkg'), path.resolve('..', 'local-pkg'))
await installPkgs(['file:../local-pkg'], testDefaults())
await installPkgs(['file:../local-pkg'], await testDefaults())
const pkgJson = await readPkg()
const expectedSpecs = {'local-pkg': `file:..${path.sep}local-pkg`}
@@ -54,7 +54,7 @@ test('local file', async function (t: tape.Test) {
test('package with a broken symlink', async function (t) {
const project = prepare(t)
await installPkgs([pathToLocalPkg('has-broken-symlink/has-broken-symlink.tar.gz')], testDefaults())
await installPkgs([pathToLocalPkg('has-broken-symlink/has-broken-symlink.tar.gz')], await testDefaults())
const m = project.requireModule('has-broken-symlink')
@@ -63,7 +63,7 @@ test('package with a broken symlink', async function (t) {
test('tarball local package', async function (t) {
const project = prepare(t)
await installPkgs([pathToLocalPkg('tar-pkg/tar-pkg-1.0.0.tgz')], testDefaults())
await installPkgs([pathToLocalPkg('tar-pkg/tar-pkg-1.0.0.tgz')], await testDefaults())
const m = project.requireModule('tar-pkg')

View File

@@ -40,7 +40,7 @@ if (!caw() && !IS_WINDOWS) {
test('small with dependencies (rimraf)', async (t: tape.Test) => {
const project = prepare(t)
await installPkgs(['rimraf@2.5.1'], testDefaults())
await installPkgs(['rimraf@2.5.1'], await testDefaults())
const m = project.requireModule('rimraf')
t.ok(typeof m === 'function', 'rimraf() is available')
@@ -51,7 +51,7 @@ test('ignoring some files in the dependency', async (t: tape.Test) => {
const project = prepare(t)
const ignoreFile = (filename: string) => filename === 'readme.md'
await installPkgs(['is-positive@1.0.0'], testDefaults({ignoreFile}))
await installPkgs(['is-positive@1.0.0'], await testDefaults({}, {}, {ignoreFile}))
t.ok(await exists(path.resolve('node_modules', 'is-positive', 'package.json')), 'package.json was not ignored')
t.notOk(await exists(path.resolve('node_modules', 'is-positive', 'readme.md')), 'readme.md was ignored')
@@ -63,7 +63,7 @@ test('no dependencies (lodash)', async (t: tape.Test) => {
await addDistTag('lodash', '4.1.0', 'latest')
await installPkgs(['lodash@4.0.0'], testDefaults({reporter}))
await installPkgs(['lodash@4.0.0'], await testDefaults({reporter}))
t.ok(reporter.calledWithMatch(<PackageJsonLog>{
name: 'pnpm:package-json',
@@ -120,7 +120,7 @@ test('no dependencies (lodash)', async (t: tape.Test) => {
test('scoped modules without version spec (@rstacruz/tap-spec)', async function (t) {
const project = prepare(t)
await installPkgs(['@rstacruz/tap-spec'], testDefaults())
await installPkgs(['@rstacruz/tap-spec'], await testDefaults())
const m = project.requireModule('@rstacruz/tap-spec')
t.ok(typeof m === 'function', 'tap-spec is available')
@@ -129,7 +129,7 @@ test('scoped modules without version spec (@rstacruz/tap-spec)', async function
test('scoped package with custom registry', async function (t) {
const project = prepare(t)
await installPkgs(['@scoped/peer'], testDefaults({
await installPkgs(['@scoped/peer'], await testDefaults({
// setting an incorrect default registry URL
registry: 'http://localhost:9999/',
rawNpmConfig: {
@@ -149,7 +149,7 @@ test('modules without version spec, with custom tag config', async function (t)
await addDistTag('dep-of-pkg-with-1-dep', '100.1.0', 'latest')
await addDistTag('dep-of-pkg-with-1-dep', '100.0.0', tag)
await installPkgs(['dep-of-pkg-with-1-dep'], testDefaults({tag}))
await installPkgs(['dep-of-pkg-with-1-dep'], await testDefaults({tag}))
await project.storeHas('dep-of-pkg-with-1-dep', '100.0.0')
})
@@ -160,7 +160,7 @@ test('installing a package by specifying a specific dist-tag', async function (t
await addDistTag('dep-of-pkg-with-1-dep', '100.1.0', 'latest')
await addDistTag('dep-of-pkg-with-1-dep', '100.0.0', 'beta')
await installPkgs(['dep-of-pkg-with-1-dep@beta'], testDefaults())
await installPkgs(['dep-of-pkg-with-1-dep@beta'], await testDefaults())
await project.storeHas('dep-of-pkg-with-1-dep', '100.0.0')
})
@@ -171,11 +171,11 @@ test('update a package when installing with a dist-tag', async function (t: tape
await addDistTag('dep-of-pkg-with-1-dep', '100.0.0', 'latest')
await addDistTag('dep-of-pkg-with-1-dep', '100.1.0', 'beta')
await installPkgs(['dep-of-pkg-with-1-dep'], testDefaults({saveDev: true}))
await installPkgs(['dep-of-pkg-with-1-dep'], await testDefaults({saveDev: true}))
const reporter = sinon.spy()
await installPkgs(['dep-of-pkg-with-1-dep@beta'], testDefaults({saveDev: true, reporter}))
await installPkgs(['dep-of-pkg-with-1-dep@beta'], await testDefaults({saveDev: true, reporter}))
t.ok(reporter.calledWithMatch(<RootLog>{
name: 'pnpm:root',
@@ -206,7 +206,7 @@ test('update a package when installing with a dist-tag', async function (t: tape
test('scoped modules with versions (@rstacruz/tap-spec@4.1.1)', async function (t) {
const project = prepare(t)
await installPkgs(['@rstacruz/tap-spec@4.1.1'], testDefaults())
await installPkgs(['@rstacruz/tap-spec@4.1.1'], await testDefaults())
const m = project.requireModule('@rstacruz/tap-spec')
t.ok(typeof m === 'function', 'tap-spec is available')
@@ -214,7 +214,7 @@ test('scoped modules with versions (@rstacruz/tap-spec@4.1.1)', async function (
test('scoped modules (@rstacruz/tap-spec@*)', async function (t) {
const project = prepare(t)
await installPkgs(['@rstacruz/tap-spec@*'], testDefaults())
await installPkgs(['@rstacruz/tap-spec@*'], await testDefaults())
const m = project.requireModule('@rstacruz/tap-spec')
t.ok(typeof m === 'function', 'tap-spec is available')
@@ -222,7 +222,7 @@ test('scoped modules (@rstacruz/tap-spec@*)', async function (t) {
test('multiple scoped modules (@rstacruz/...)', async function (t) {
const project = prepare(t)
await installPkgs(['@rstacruz/tap-spec@*', '@rstacruz/travis-encrypt@*'], testDefaults())
await installPkgs(['@rstacruz/tap-spec@*', '@rstacruz/travis-encrypt@*'], await testDefaults())
t.equal(typeof project.requireModule('@rstacruz/tap-spec'), 'function', 'tap-spec is available')
t.equal(typeof project.requireModule('@rstacruz/travis-encrypt'), 'function', 'travis-encrypt is available')
@@ -230,7 +230,7 @@ test('multiple scoped modules (@rstacruz/...)', async function (t) {
test('nested scoped modules (test-pnpm-issue219 -> @zkochan/test-pnpm-issue219)', async function (t) {
const project = prepare(t)
await installPkgs(['test-pnpm-issue219@1.0.2'], testDefaults())
await installPkgs(['test-pnpm-issue219@1.0.2'], await testDefaults())
const m = project.requireModule('test-pnpm-issue219')
t.ok(m === 'test-pnpm-issue219,@zkochan/test-pnpm-issue219', 'nested scoped package is available')
@@ -239,7 +239,7 @@ test('nested scoped modules (test-pnpm-issue219 -> @zkochan/test-pnpm-issue219)'
test('idempotency (rimraf)', async (t: tape.Test) => {
const project = prepare(t)
const reporter = sinon.spy()
const opts = testDefaults({reporter})
const opts = await testDefaults({reporter})
await installPkgs(['rimraf@2.5.1'], opts)
@@ -273,13 +273,13 @@ test('idempotency (rimraf)', async (t: tape.Test) => {
test('reporting adding root package', async (t: tape.Test) => {
const project = prepare(t)
await installPkgs(['magic-hook@2.0.0'], testDefaults())
await installPkgs(['magic-hook@2.0.0'], await testDefaults())
await project.storeHas('flatten', '1.0.2')
const reporter = sinon.spy()
await installPkgs(['flatten@1.0.2'], testDefaults({reporter}))
await installPkgs(['flatten@1.0.2'], await testDefaults({reporter}))
t.ok(reporter.calledWithMatch(<RootLog>{
name: 'pnpm:root',
@@ -294,11 +294,11 @@ test('reporting adding root package', async (t: tape.Test) => {
test('overwriting (magic-hook@2.0.0 and @0.1.0)', async (t: tape.Test) => {
const project = prepare(t)
await installPkgs(['magic-hook@2.0.0'], testDefaults())
await installPkgs(['magic-hook@2.0.0'], await testDefaults())
await project.storeHas('flatten', '1.0.2')
await installPkgs(['magic-hook@0.1.0'], testDefaults())
await installPkgs(['magic-hook@0.1.0'], await testDefaults())
// flatten is not removed from store even though it is unreferenced
// store should be pruned to have this removed
@@ -310,23 +310,23 @@ test('overwriting (magic-hook@2.0.0 and @0.1.0)', async (t: tape.Test) => {
test('overwriting (is-positive@3.0.0 with is-positive@latest)', async function (t) {
const project = prepare(t)
await installPkgs(['is-positive@3.0.0'], testDefaults({save: true}))
await installPkgs(['is-positive@3.0.0'], await testDefaults({save: true}))
await project.storeHas('is-positive', '3.0.0')
await installPkgs(['is-positive@latest'], testDefaults({save: true}))
await installPkgs(['is-positive@latest'], await testDefaults({save: true}))
await project.storeHas('is-positive', '3.1.0')
})
test('forcing', async function (t) {
const project = prepare(t)
await installPkgs(['magic-hook@2.0.0'], testDefaults())
await installPkgs(['magic-hook@2.0.0'], await testDefaults())
const distPath = path.resolve('node_modules', 'magic-hook', 'dist')
await rimraf(distPath)
await installPkgs(['magic-hook@2.0.0'], testDefaults({force: true}))
await installPkgs(['magic-hook@2.0.0'], await testDefaults({force: true}))
const distPathExists = await exists(distPath)
t.ok(distPathExists, 'magic-hook@2.0.0 dist folder reinstalled')
@@ -334,12 +334,12 @@ test('forcing', async function (t) {
test('argumentless forcing', async function (t: tape.Test) {
const project = prepare(t)
await installPkgs(['magic-hook@2.0.0'], testDefaults())
await installPkgs(['magic-hook@2.0.0'], await testDefaults())
const distPath = path.resolve('node_modules', 'magic-hook', 'dist')
await rimraf(distPath)
await install(testDefaults({force: true}))
await install(await testDefaults({force: true}))
const distPathExists = await exists(distPath)
t.ok(distPathExists, 'magic-hook@2.0.0 dist folder reinstalled')
@@ -347,12 +347,12 @@ test('argumentless forcing', async function (t: tape.Test) {
test('no forcing', async function (t) {
const project = prepare(t)
await installPkgs(['magic-hook@2.0.0'], testDefaults())
await installPkgs(['magic-hook@2.0.0'], await testDefaults())
const distPath = path.resolve('node_modules', 'magic-hook', 'dist')
await rimraf(distPath)
await installPkgs(['magic-hook@2.0.0'], testDefaults())
await installPkgs(['magic-hook@2.0.0'], await testDefaults())
const distPathExists = await exists(distPath)
t.notOk(distPathExists, 'magic-hook@2.0.0 dist folder not reinstalled')
@@ -360,14 +360,14 @@ test('no forcing', async function (t) {
test('refetch package to store if it has been modified', async function (t) {
const project = prepare(t)
await installPkgs(['magic-hook@2.0.0'], testDefaults())
await installPkgs(['magic-hook@2.0.0'], await testDefaults())
const distPathInStore = await project.resolve('magic-hook', '2.0.0', 'dist')
await rimraf(distPathInStore)
await rimraf('node_modules')
const distPath = path.resolve('node_modules', 'magic-hook', 'dist')
await installPkgs(['magic-hook@2.0.0'], testDefaults())
await installPkgs(['magic-hook@2.0.0'], await testDefaults())
const distPathExists = await exists(distPath)
t.ok(distPathExists, 'magic-hook@2.0.0 dist folder reinstalled')
@@ -375,7 +375,7 @@ test('refetch package to store if it has been modified', async function (t) {
test("don't refetch package to store if it has been modified and verify-store-integrity = false", async (t: tape.Test) => {
const project = prepare(t)
const opts = testDefaults({verifyStoreIntegrity: false})
const opts = await testDefaults({verifyStoreIntegrity: false})
await installPkgs(['magic-hook@2.0.0'], opts)
await writeJsonFile(path.join(await project.getStorePath(), 'localhost+4873', 'magic-hook', '2.0.0', 'node_modules', 'magic-hook', 'package.json'), {})
@@ -390,7 +390,7 @@ test("don't refetch package to store if it has been modified and verify-store-in
// TODO: decide what to do with this case
test['skip']('relink package to project if the dependency is not linked from store', async function (t: tape.Test) {
const project = prepare(t)
await installPkgs(['magic-hook@2.0.0'], testDefaults({save: true, saveExact: true}))
await installPkgs(['magic-hook@2.0.0'], await testDefaults({save: true, saveExact: true}))
const pkgJsonPath = path.resolve('node_modules', 'magic-hook', 'package.json')
@@ -407,14 +407,14 @@ test['skip']('relink package to project if the dependency is not linked from sto
t.ok(storeInode !== await getInode(), 'package.json inode changed')
await install(testDefaults({repeatInstallDepth: 0}))
await install(await testDefaults({repeatInstallDepth: 0}))
t.ok(storeInode === await getInode(), 'package.json inode matches the one that is in store')
})
test('circular deps', async function (t: tape.Test) {
const project = prepare(t)
await installPkgs(['circular-deps-1-of-2'], testDefaults())
await installPkgs(['circular-deps-1-of-2'], await testDefaults())
const m = project.requireModule('circular-deps-1-of-2/mirror')
@@ -430,7 +430,7 @@ test('concurrent circular deps', async (t: tape.Test) => {
await addDistTag('es6-iterator', '2.0.1', 'latest')
const project = prepare(t)
await installPkgs(['es6-iterator@2.0.0'], testDefaults())
await installPkgs(['es6-iterator@2.0.0'], await testDefaults())
const m = project.requireModule('es6-iterator')
@@ -446,7 +446,7 @@ test('concurrent installation of the same packages', async function (t) {
// the same version of core-js is required by two different dependencies
// of babek-core
await installPkgs(['babel-core@6.21.0'], testDefaults())
await installPkgs(['babel-core@6.21.0'], await testDefaults())
const m = project.requireModule('babel-core')
@@ -455,7 +455,7 @@ test('concurrent installation of the same packages', async function (t) {
test('big with dependencies and circular deps (babel-preset-2015)', async function (t) {
const project = prepare(t)
await installPkgs(['babel-preset-es2015@6.3.13'], testDefaults())
await installPkgs(['babel-preset-es2015@6.3.13'], await testDefaults())
const m = project.requireModule('babel-preset-es2015')
t.ok(typeof m === 'object', 'babel-preset-es2015 is available')
@@ -464,7 +464,7 @@ test('big with dependencies and circular deps (babel-preset-2015)', async functi
test('bundledDependencies (pkg-with-bundled-dependencies@1.0.0)', async function (t: tape.Test) {
const project = prepare(t)
await installPkgs(['pkg-with-bundled-dependencies@1.0.0'], testDefaults())
await installPkgs(['pkg-with-bundled-dependencies@1.0.0'], await testDefaults())
await project.isExecutable('pkg-with-bundled-dependencies/node_modules/.bin/hello-world-js-bin')
@@ -479,7 +479,7 @@ test('bundledDependencies (pkg-with-bundled-dependencies@1.0.0)', async function
test('bundleDependencies (pkg-with-bundle-dependencies@1.0.0)', async function (t: tape.Test) {
const project = prepare(t)
await installPkgs(['pkg-with-bundle-dependencies@1.0.0'], testDefaults())
await installPkgs(['pkg-with-bundle-dependencies@1.0.0'], await testDefaults())
await project.isExecutable('pkg-with-bundle-dependencies/node_modules/.bin/hello-world-js-bin')
@@ -499,7 +499,7 @@ test('compiled modules (ursa@0.9.1)', async function (t) {
}
const project = prepare(t)
await installPkgs(['ursa@0.9.1'], testDefaults())
await installPkgs(['ursa@0.9.1'], await testDefaults())
const m = project.requireModule('ursa')
t.ok(typeof m === 'object', 'ursa() is available')
@@ -512,7 +512,7 @@ test('shrinkwrap compatibility', async function (t) {
}
const project = prepare(t, { dependencies: { rimraf: '*' } })
await installPkgs(['rimraf@2.5.1'], testDefaults())
await installPkgs(['rimraf@2.5.1'], await testDefaults())
return new Promise((resolve, reject) => {
const proc = crossSpawn.spawn('npm', ['shrinkwrap'])
@@ -534,11 +534,11 @@ const wait = (ms: number) => new Promise(resolve => setTimeout(resolve, ms))
test('support installing into the same store simultaneously', async t => {
const project = prepare(t)
await Promise.all([
installPkgs(['pkg-that-installs-slowly'], testDefaults()),
installPkgs(['pkg-that-installs-slowly'], await testDefaults()),
wait(500) // to be sure that lock was created
.then(async () => {
await project.storeHasNot('pkg-that-installs-slowly')
await installPkgs(['rimraf@2.5.1'], testDefaults())
await installPkgs(['rimraf@2.5.1'], await testDefaults())
})
.then(async () => {
await project.has('pkg-that-installs-slowly')
@@ -551,11 +551,11 @@ test('support installing into the same store simultaneously', async t => {
test('support installing and uninstalling from the same store simultaneously', async t => {
const project = prepare(t)
await Promise.all([
installPkgs(['pkg-that-installs-slowly'], testDefaults()),
installPkgs(['pkg-that-installs-slowly'], await testDefaults()),
wait(500) // to be sure that lock was created
.then(async () => {
await project.storeHasNot('pkg-that-installs-slowly')
await uninstall(['rimraf@2.5.1'], testDefaults())
await uninstall(['rimraf@2.5.1'], await testDefaults())
})
.then(async () => {
await project.has('pkg-that-installs-slowly')
@@ -571,7 +571,7 @@ test('top-level packages should find the plugins they use', async function (t) {
test: 'pkg-that-uses-plugins'
}
})
await installPkgs(['pkg-that-uses-plugins', 'plugin-example'], testDefaults({ save: true }))
await installPkgs(['pkg-that-uses-plugins', 'plugin-example'], await testDefaults({ save: true }))
const result = spawnSync('npm', ['test'])
t.ok(result.stdout.toString().indexOf('My plugin is plugin-example') !== -1, 'package executable have found its plugin')
t.equal(result.status, 0, 'executable exited with success')
@@ -584,7 +584,7 @@ test('not top-level packages should find the plugins they use', async function (
test: 'standard'
}
})
await installPkgs(['standard@8.6.0'], testDefaults({ save: true }))
await installPkgs(['standard@8.6.0'], await testDefaults({ save: true }))
const result = spawnSync('npm', ['test'])
t.equal(result.status, 0, 'standard exited with success')
})
@@ -592,7 +592,7 @@ test('not top-level packages should find the plugins they use', async function (
test('bin specified in the directories property linked to .bin folder', async function (t) {
const project = prepare(t)
await installPkgs(['pkg-with-directories-bin'], testDefaults())
await installPkgs(['pkg-with-directories-bin'], await testDefaults())
await project.isExecutable('.bin/pkg-with-directories-bin')
})
@@ -603,7 +603,7 @@ test('run js bin file', async function (t) {
test: 'hello-world-js-bin'
}
})
await installPkgs(['hello-world-js-bin'], testDefaults({ save: true }))
await installPkgs(['hello-world-js-bin'], await testDefaults({ save: true }))
const result = spawnSync('npm', ['test'])
t.ok(result.stdout.toString().indexOf('Hello world!') !== -1, 'package executable printed its message')
@@ -613,7 +613,7 @@ test('run js bin file', async function (t) {
test('building native addons', async function (t) {
const project = prepare(t)
await installPkgs(['runas@3.1.1'], testDefaults())
await installPkgs(['runas@3.1.1'], await testDefaults())
t.ok(await exists(path.join('node_modules', 'runas', 'build')), 'build folder created')
})
@@ -623,7 +623,7 @@ test('should update subdep on second install', async (t: tape.Test) => {
await addDistTag('dep-of-pkg-with-1-dep', '100.0.0', 'latest')
await installPkgs(['pkg-with-1-dep'], testDefaults({save: true}))
await installPkgs(['pkg-with-1-dep'], await testDefaults({save: true}))
await project.storeHas('dep-of-pkg-with-1-dep', '100.0.0')
@@ -635,7 +635,7 @@ test('should update subdep on second install', async (t: tape.Test) => {
const reporter = sinon.spy()
await install(testDefaults({depth: 1, update: true, reporter}))
await install(await testDefaults({depth: 1, update: true, reporter}))
t.ok(reporter.calledWithMatch(<StatsLog>{
name: 'pnpm:stats',
@@ -658,7 +658,7 @@ test('should not update subdep when depth is smaller than depth of package', asy
await addDistTag('dep-of-pkg-with-1-dep', '100.0.0', 'latest')
await installPkgs(['pkg-with-1-dep'], testDefaults({save: true}))
await installPkgs(['pkg-with-1-dep'], await testDefaults({save: true}))
await project.storeHas('dep-of-pkg-with-1-dep', '100.0.0')
@@ -668,7 +668,7 @@ test('should not update subdep when depth is smaller than depth of package', asy
await addDistTag('dep-of-pkg-with-1-dep', '100.1.0', 'latest')
await install(testDefaults({depth: 0, update: true}))
await install(await testDefaults({depth: 0, update: true}))
await project.storeHas('dep-of-pkg-with-1-dep', '100.0.0')
@@ -683,12 +683,12 @@ test('should not update subdep when depth is smaller than depth of package', asy
test('should install dependency in second project', async function (t) {
const project1 = prepare(t)
await installPkgs(['pkg-with-1-dep'], testDefaults({save: true, store: '../store'}))
await installPkgs(['pkg-with-1-dep'], await testDefaults({save: true, store: '../store'}))
t.equal(project1.requireModule('pkg-with-1-dep')().name, 'dep-of-pkg-with-1-dep', 'can require in 1st pkg')
const project2 = prepare(t)
await installPkgs(['pkg-with-1-dep'], testDefaults({save: true, store: '../store'}))
await installPkgs(['pkg-with-1-dep'], await testDefaults({save: true, store: '../store'}))
t.equal(project2.requireModule('pkg-with-1-dep')().name, 'dep-of-pkg-with-1-dep', 'can require in 2nd pkg')
})
@@ -696,10 +696,10 @@ test('should install dependency in second project', async function (t) {
test('should throw error when trying to install using a different store then the previous one', async function(t) {
const project = prepare(t)
await installPkgs(['rimraf@2.5.1'], testDefaults({store: 'node_modules/.store1'}))
await installPkgs(['rimraf@2.5.1'], await testDefaults({store: 'node_modules/.store1'}))
try {
await installPkgs(['is-negative'], testDefaults({store: 'node_modules/.store2'}))
await installPkgs(['is-negative'], await testDefaults({store: 'node_modules/.store2'}))
t.fail('installation should have failed')
} catch (err) {
t.equal(err.code, 'UNEXPECTED_STORE', 'failed with correct error code')
@@ -716,7 +716,7 @@ test('shrinkwrap locks npm dependencies', async function (t: tape.Test) {
await addDistTag('dep-of-pkg-with-1-dep', '100.0.0', 'latest')
await installPkgs(['pkg-with-1-dep'], testDefaults({save: true, reporter}))
await installPkgs(['pkg-with-1-dep'], await testDefaults({save: true, reporter}))
t.ok(reporter.calledWithMatch(<ProgressLog>{
name: 'pnpm:progress',
@@ -737,7 +737,7 @@ test('shrinkwrap locks npm dependencies', async function (t: tape.Test) {
await rimraf('node_modules')
reporter.reset()
await install(testDefaults({reporter}))
await install(await testDefaults({reporter}))
t.ok(reporter.calledWithMatch(<ProgressLog>{
level: 'debug',
@@ -758,7 +758,7 @@ test('shrinkwrap locks npm dependencies', async function (t: tape.Test) {
test('self-require should work', async function (t) {
const project = prepare(t)
await installPkgs(['uses-pkg-with-self-usage'], testDefaults())
await installPkgs(['uses-pkg-with-self-usage'], await testDefaults())
t.ok(project.requireModule('uses-pkg-with-self-usage'))
})
@@ -766,11 +766,11 @@ test('self-require should work', async function (t) {
test('install on project with lockfile and no node_modules', async (t: tape.Test) => {
const project = prepare(t)
await installPkgs(['is-negative'], testDefaults())
await installPkgs(['is-negative'], await testDefaults())
await rimraf('node_modules')
await installPkgs(['is-positive'], testDefaults())
await installPkgs(['is-positive'], await testDefaults())
t.ok(project.requireModule('is-positive'), 'installed new dependency')
@@ -785,7 +785,7 @@ test('install a dependency with * range', async (t: tape.Test) => {
})
const reporter = sinon.spy()
await install(testDefaults({reporter}))
await install(await testDefaults({reporter}))
await project.has('has-beta-only')

View File

@@ -21,7 +21,7 @@ test('production install (with --production flag)', async (t: tape.Test) => {
},
})
await install(testDefaults({ development: false }))
await install(await testDefaults({ development: false }))
const rimraf = project.requireModule('rimraf')
@@ -47,7 +47,7 @@ test('install dev dependencies only', async (t: tape.Test) => {
},
})
await install(testDefaults({ production: false }))
await install(await testDefaults({ production: false }))
const inflight = project.requireModule('inflight')
t.equal(typeof inflight, 'function', 'dev dependency is available')
@@ -65,7 +65,7 @@ test('install dev dependencies only', async (t: tape.Test) => {
}
// Repeat normal installation adds missing deps to node_modules
await install(testDefaults())
await install(await testDefaults())
await project.has('once')

View File

@@ -19,12 +19,12 @@ const test = promisifyTape(tape)
test('successfully install optional dependency with subdependencies', async function (t) {
const project = prepare(t)
await installPkgs(['fsevents@1.0.14'], testDefaults({saveOptional: true}))
await installPkgs(['fsevents@1.0.14'], await testDefaults({saveOptional: true}))
})
test('skip failing optional dependencies', async (t: tape.Test) => {
const project = prepare(t)
await installPkgs(['pkg-with-failing-optional-dependency@1.0.1'], testDefaults())
await installPkgs(['pkg-with-failing-optional-dependency@1.0.1'], await testDefaults())
const m = project.requireModule('pkg-with-failing-optional-dependency')
t.ok(m(-1), 'package with failed optional dependency has the dependencies installed correctly')
@@ -38,7 +38,7 @@ test('skip optional dependency that does not support the current OS', async (t:
})
const reporter = sinon.spy()
await install(testDefaults({reporter}))
await install(await testDefaults({reporter}))
await project.hasNot('not-compatible-with-any-os')
await project.storeHas('not-compatible-with-any-os', '1.0.0')
@@ -70,7 +70,7 @@ test('skip optional dependency that does not support the current Node version',
})
const reporter = sinon.spy()
await install(testDefaults({reporter}))
await install(await testDefaults({reporter}))
await project.hasNot('for-legacy-node')
await project.storeHas('for-legacy-node', '1.0.0')
@@ -91,7 +91,7 @@ test('skip optional dependency that does not support the current pnpm version',
})
const reporter = sinon.spy()
await install(testDefaults({reporter}))
await install(await testDefaults({reporter}))
await project.hasNot('for-legacy-pnpm')
await project.storeHas('for-legacy-pnpm', '1.0.0')
@@ -111,7 +111,7 @@ test('don\'t skip optional dependency that does not support the current OS when
}
})
await install(testDefaults({
await install(await testDefaults({
force: true
}))
@@ -123,7 +123,7 @@ test('optional subdependency is skipped', async (t: tape.Test) => {
const project = prepare(t)
const reporter = sinon.spy()
await installPkgs(['pkg-with-optional', 'dep-of-optional-pkg'], testDefaults({reporter}))
await installPkgs(['pkg-with-optional', 'dep-of-optional-pkg'], await testDefaults({reporter}))
const modulesInfo = await loadYamlFile<{skipped: string[]}>(path.join('node_modules', '.modules.yaml'))
@@ -147,7 +147,7 @@ test('not installing optional dependencies when optional is false', async (t: ta
},
})
await install(testDefaults({optional: false}))
await install(await testDefaults({optional: false}))
await project.hasNot('is-positive')
await project.has('pkg-with-good-optional')
@@ -166,7 +166,7 @@ test('optional dependency has bigger priority than regular dependency', async (t
},
})
await install(testDefaults())
await install(await testDefaults())
t.ok(deepRequireCwd(['is-positive', './package.json']).version, '3.1.0')
})

View File

@@ -15,27 +15,27 @@ import loadJsonFile = require('load-json-file')
const test = promisifyTape(tape)
const NM = 'node_modules'
test("don't fail when peer dependency is fetched from GitHub", t => {
test("don't fail when peer dependency is fetched from GitHub", async t => {
const project = prepare(t)
return installPkgs(['test-pnpm-peer-deps'], testDefaults())
await installPkgs(['test-pnpm-peer-deps'], await testDefaults())
})
test('peer dependency is grouped with dependency when peer is resolved not from a top dependency', async (t: tape.Test) => {
const project = prepare(t)
const opts = testDefaults()
const opts = await testDefaults()
await installPkgs(['using-ajv'], opts)
t.ok(await exists(path.join(NM, '.localhost+4873', 'ajv-keywords', '1.5.0', 'ajv@4.10.4', NM, 'ajv')), 'peer dependency is linked')
t.equal(deepRequireCwd(['using-ajv', 'ajv-keywords', 'ajv', './package.json']).version, '4.10.4')
const storeIndex = await loadJsonFile(path.join(opts.store, '2', 'store.json'))
const storeIndex = await loadJsonFile(path.join(opts.store, 'store.json'))
t.ok(storeIndex['localhost+4873/ajv-keywords/1.5.0'], 'localhost+4873/ajv-keywords/1.5.0 added to store index')
t.ok(storeIndex['localhost+4873/using-ajv/1.0.0'], 'localhost+4873/using-ajv/1.0.0 added to store index')
// testing that peers are reinstalled correctly using info from the shrinkwrap file
await rimraf('node_modules')
await rimraf(path.resolve('..', '.store'))
await install(opts)
await install(await testDefaults())
t.ok(await exists(path.join(NM, '.localhost+4873', 'ajv-keywords', '1.5.0', 'ajv@4.10.4', NM, 'ajv')), 'peer dependency is linked')
t.equal(deepRequireCwd(['using-ajv', 'ajv-keywords', 'ajv', './package.json']).version, '4.10.4')
@@ -46,7 +46,7 @@ test('peer dependency is not grouped with dependent when the peer is a top depen
const reporter = sinon.spy()
await installPkgs(['ajv@4.10.4', 'ajv-keywords@1.5.0'], testDefaults({reporter}))
await installPkgs(['ajv@4.10.4', 'ajv-keywords@1.5.0'], await testDefaults({reporter}))
t.notOk(reporter.calledWithMatch({
message: 'localhost+4873/ajv-keywords/1.5.0 requires a peer of ajv@>=4.10.0 but none was installed.',
@@ -60,7 +60,7 @@ test('warning is reported when cannot resolve peer dependency for top-level depe
const reporter = sinon.spy()
await installPkgs(['ajv-keywords@1.5.0'], testDefaults({reporter}))
await installPkgs(['ajv-keywords@1.5.0'], await testDefaults({reporter}))
const logMatcher = sinon.match({
message: 'ajv-keywords@1.5.0 requires a peer of ajv@>=4.10.0 but none was installed.',
@@ -75,7 +75,7 @@ test('warning is reported when cannot resolve peer dependency for non-top-level
const reporter = sinon.spy()
await installPkgs(['abc-grand-parent-without-c'], testDefaults({reporter}))
await installPkgs(['abc-grand-parent-without-c'], await testDefaults({reporter}))
const logMatcher = sinon.match({
message: 'abc-grand-parent-without-c > abc-parent-with-ab: abc@1.0.0 requires a peer of peer-c@^1.0.0 but none was installed.',
@@ -90,7 +90,7 @@ test('warning is reported when bad version of resolved peer dependency for non-t
const reporter = sinon.spy()
await installPkgs(['abc-grand-parent-without-c', 'peer-c@2'], testDefaults({reporter}))
await installPkgs(['abc-grand-parent-without-c', 'peer-c@2'], await testDefaults({reporter}))
const logMatcher = sinon.match({
message: 'abc-grand-parent-without-c > abc-parent-with-ab: abc@1.0.0 requires a peer of peer-c@^1.0.0 but version 2.0.0 was installed.',
@@ -103,9 +103,9 @@ test('warning is reported when bad version of resolved peer dependency for non-t
test('top peer dependency is not linked on subsequent install', async (t: tape.Test) => {
const project = prepare(t)
await installPkgs(['ajv@4.10.4'], testDefaults())
await installPkgs(['ajv@4.10.4'], await testDefaults())
await installPkgs(['ajv-keywords@1.5.0'], testDefaults())
await installPkgs(['ajv-keywords@1.5.0'], await testDefaults())
t.ok(await exists(path.join(NM, '.localhost+4873', 'ajv-keywords', '1.5.0', NM, 'ajv-keywords')), 'dependent is at the normal location')
t.notOk(await exists(path.join(NM, '.localhost+4873', 'ajv-keywords', '1.5.0', 'ajv@4.10.4', NM, 'ajv')), 'peer dependency is not linked')
@@ -119,7 +119,7 @@ async function okFile (t: tape.Test, filename: string) {
test('peer dependencies are linked when running one named installation', async (t: tape.Test) => {
const project = prepare(t)
await installPkgs(['abc-grand-parent-with-c', 'abc-parent-with-ab', 'peer-c@2.0.0'], testDefaults())
await installPkgs(['abc-grand-parent-with-c', 'abc-parent-with-ab', 'peer-c@2.0.0'], await testDefaults())
const pkgVariationsDir = path.join(NM, '.localhost+4873', 'abc', '1.0.0')
@@ -142,8 +142,8 @@ test('peer dependencies are linked when running one named installation', async (
test('peer dependencies are linked when running two separate named installations', async (t: tape.Test) => {
const project = prepare(t)
await installPkgs(['abc-grand-parent-with-c', 'peer-c@2.0.0'], testDefaults())
await installPkgs(['abc-parent-with-ab'], testDefaults())
await installPkgs(['abc-grand-parent-with-c', 'peer-c@2.0.0'], await testDefaults())
await installPkgs(['abc-parent-with-ab'], await testDefaults())
const pkgVariationsDir = path.join(NM, '.localhost+4873', 'abc', '1.0.0')
@@ -174,7 +174,7 @@ test['skip']('peer dependencies are linked', async (t: tape.Test) => {
'abc-parent-with-ab': '*',
},
})
await install(testDefaults())
await install(await testDefaults())
const pkgVariationsDir = path.join(NM, '.localhost+4873', 'abc', '1.0.0')
@@ -200,7 +200,7 @@ test['skip']('peer dependencies are linked', async (t: tape.Test) => {
test('scoped peer dependency is linked', async (t: tape.Test) => {
const project = prepare(t)
await installPkgs(['for-testing-scoped-peers'], testDefaults())
await installPkgs(['for-testing-scoped-peers'], await testDefaults())
const pkgVariation = path.join(NM, '.localhost+4873', '@having', 'scoped-peer', '1.0.0', '@scoped!peer@1.0.0', NM)
await okFile(t, path.join(pkgVariation, '@having', 'scoped-peer'))
@@ -210,7 +210,7 @@ test('scoped peer dependency is linked', async (t: tape.Test) => {
test('peer bins are linked', async (t: tape.Test) => {
const project = prepare(t)
await installPkgs(['for-testing-peers-having-bins'], testDefaults())
await installPkgs(['for-testing-peers-having-bins'], await testDefaults())
const pkgVariation = path.join('.localhost+4873', 'pkg-with-peer-having-bin', '1.0.0', 'peer-with-bin@1.0.0', NM)
@@ -221,7 +221,7 @@ test('peer bins are linked', async (t: tape.Test) => {
test('run pre/postinstall scripts of each variations of packages with peer dependencies', async (t: tape.Test) => {
const project = prepare(t)
await installPkgs(['parent-of-pkg-with-events-and-peers', 'pkg-with-events-and-peers', 'peer-c@2.0.0'], testDefaults())
await installPkgs(['parent-of-pkg-with-events-and-peers', 'pkg-with-events-and-peers', 'peer-c@2.0.0'], await testDefaults())
const pkgVariation1 = path.join(NM, '.localhost+4873', 'pkg-with-events-and-peers', '1.0.0', 'peer-c@1.0.0', NM)
await okFile(t, path.join(pkgVariation1, 'pkg-with-events-and-peers', 'generated-by-preinstall.js'))
@@ -238,7 +238,7 @@ test('package that resolves its own peer dependency', async (t: tape.Test) => {
// does it currently print a warning that peer dependency is not resolved?
const project = prepare(t)
await installPkgs(['pkg-with-resolved-peer', 'peer-c@2.0.0'], testDefaults())
await installPkgs(['pkg-with-resolved-peer', 'peer-c@2.0.0'], await testDefaults())
t.equal(deepRequireCwd(['pkg-with-resolved-peer', 'peer-c', './package.json']).version, '1.0.0')
@@ -254,7 +254,7 @@ test('package that resolves its own peer dependency', async (t: tape.Test) => {
test('own peer installed in root as well is linked to root', async function (t: tape.Test) {
const project = prepare(t)
await installPkgs(['is-negative@kevva/is-negative#2.1.0', 'peer-deps-in-child-pkg'], testDefaults())
await installPkgs(['is-negative@kevva/is-negative#2.1.0', 'peer-deps-in-child-pkg'], await testDefaults())
t.ok(deepRequireCwd.silent(['is-negative', './package.json']), 'is-negative is linked to root')
})

View File

@@ -15,7 +15,7 @@ test('reports warning when installing deprecated packages', async (t: tape.Test)
const reporter = sinon.spy()
await installPkgs(['jade@1.11.0'], testDefaults({reporter}))
await installPkgs(['jade@1.11.0'], await testDefaults({reporter}))
t.ok(reporter.calledWithMatch(<DeprecationLog>{
name: 'pnpm:deprecation',

View File

@@ -16,7 +16,7 @@ const test = promisifyTape(tape)
test('install with shrinkwrapOnly = true', async (t: tape.Test) => {
const project = prepare(t)
await installPkgs(['rimraf@2.5.1'], testDefaults({shrinkwrapOnly: true}))
await installPkgs(['rimraf@2.5.1'], await testDefaults({shrinkwrapOnly: true}))
await project.storeHasNot('rimraf', '2.5.1')
await project.hasNot('rimraf')
@@ -37,8 +37,8 @@ test('warn when installing with shrinkwrapOnly = true and node_modules exists',
const project = prepare(t)
const reporter = sinon.spy()
await installPkgs(['is-positive'], testDefaults())
await installPkgs(['rimraf@2.5.1'], testDefaults({
await installPkgs(['is-positive'], await testDefaults())
await installPkgs(['rimraf@2.5.1'], await testDefaults({
shrinkwrapOnly: true,
reporter,
}))

View File

@@ -11,7 +11,7 @@ const test = promisifyTape(tape)
test('repeat install with corrupted `store.json` should work', async (t: tape.Test) => {
const project = prepare(t)
const opts = testDefaults()
const opts = await testDefaults()
await installPkgs(['is-negative@1.0.0'], opts)
await rimraf('node_modules')

View File

@@ -18,7 +18,7 @@ test('preserve subdeps on update', async (t: tape.Test) => {
addDistTag('bar', '100.0.0', 'latest'),
])
await installPkgs(['foobarqar'], testDefaults())
await installPkgs(['foobarqar'], await testDefaults())
await Promise.all([
addDistTag('foobarqar', '1.0.1', 'latest'),
@@ -26,7 +26,7 @@ test('preserve subdeps on update', async (t: tape.Test) => {
addDistTag('bar', '100.1.0', 'latest'),
])
await install(testDefaults({update: true, depth: 0}))
await install(await testDefaults({update: true, depth: 0}))
const shr = await project.loadShrinkwrap()
@@ -42,9 +42,9 @@ test('preserve subdeps on update', async (t: tape.Test) => {
test('update does not fail when package has only peer dependencies', async (t: tape.Test) => {
prepare(t)
await installPkgs(['has-pkg-with-peer-only'], testDefaults())
await installPkgs(['has-pkg-with-peer-only'], await testDefaults())
await install(testDefaults({update: true, depth: Infinity}))
await install(await testDefaults({update: true, depth: Infinity}))
t.pass('did not fail')
})

View File

@@ -12,7 +12,7 @@ const test = promisifyTape(tape)
test('save to package.json (rimraf@2.5.1)', async function (t) {
const project = prepare(t)
await installPkgs(['rimraf@2.5.1'], testDefaults({ save: true }))
await installPkgs(['rimraf@2.5.1'], await testDefaults({ save: true }))
const m = project.requireModule('rimraf')
t.ok(typeof m === 'function', 'rimraf() is available')
@@ -30,9 +30,9 @@ test("don't override existing spec in package.json on named installation", async
sec: 'sindresorhus/sec',
}
})
await installPkgs(['is-positive'], testDefaults())
await installPkgs(['is-negative'], testDefaults())
await installPkgs(['sec'], testDefaults())
await installPkgs(['is-positive'], await testDefaults())
await installPkgs(['is-negative'], await testDefaults())
await installPkgs(['sec'], await testDefaults())
t.equal(project.requireModule('is-positive/package.json').version, '2.0.0')
t.equal(project.requireModule('is-negative/package.json').version, '1.0.1')
@@ -47,7 +47,7 @@ test("don't override existing spec in package.json on named installation", async
test('saveDev scoped module to package.json (@rstacruz/tap-spec)', async function (t) {
const project = prepare(t)
await installPkgs(['@rstacruz/tap-spec'], testDefaults({ saveDev: true }))
await installPkgs(['@rstacruz/tap-spec'], await testDefaults({ saveDev: true }))
const m = project.requireModule('@rstacruz/tap-spec')
t.ok(typeof m === 'function', 'tapSpec() is available')
@@ -68,7 +68,7 @@ test('dependency should not be added to package.json if it is already there', as
bar: '^100.0.0',
},
})
await installPkgs(['foo', 'bar'], testDefaults())
await installPkgs(['foo', 'bar'], await testDefaults())
const pkgJson = await readPkg({normalize: false})
t.deepEqual(pkgJson, {
@@ -103,7 +103,7 @@ test('dependencies should be updated in the fields where they already are', asyn
bar: '^100.0.0',
},
})
await installPkgs(['foo@latest', 'bar@latest'], testDefaults())
await installPkgs(['foo@latest', 'bar@latest'], await testDefaults())
const pkgJson = await readPkg({normalize: false})
t.deepEqual(pkgJson, {
@@ -134,9 +134,9 @@ test('dependency should be removed from the old field when installing it as a di
qar: '^100.0.0',
},
})
await installPkgs(['foo'], testDefaults({saveOptional: true}))
await installPkgs(['bar'], testDefaults({saveProd: true}))
await installPkgs(['qar'], testDefaults({saveDev: true}))
await installPkgs(['foo'], await testDefaults({saveOptional: true}))
await installPkgs(['bar'], await testDefaults({saveProd: true}))
await installPkgs(['qar'], await testDefaults({saveDev: true}))
const pkgJson = await readPkg({normalize: false})
t.deepEqual(pkgJson, {
@@ -156,7 +156,7 @@ test('dependency should be removed from the old field when installing it as a di
test('multiple save to package.json with `exact` versions (@rstacruz/tap-spec & rimraf@2.5.1) (in sorted order)', async function (t: tape.Test) {
const project = prepare(t)
await installPkgs(['rimraf@2.5.1', '@rstacruz/tap-spec@latest'], testDefaults({ save: true, saveExact: true }))
await installPkgs(['rimraf@2.5.1', '@rstacruz/tap-spec@latest'], await testDefaults({ save: true, saveExact: true }))
const m1 = project.requireModule('@rstacruz/tap-spec')
t.ok(typeof m1 === 'function', 'tapSpec() is available')
@@ -175,7 +175,7 @@ test('multiple save to package.json with `exact` versions (@rstacruz/tap-spec &
test('save to package.json with save-prefix=~', async (t: tape.Test) => {
const project = prepare(t)
await installPkgs(['rimraf@2.5.1'], testDefaults({ savePrefix: '~' }))
await installPkgs(['rimraf@2.5.1'], await testDefaults({ savePrefix: '~' }))
const pkgJson = await readPkg()
t.deepEqual(pkgJson.dependencies, {rimraf: '~2.5.1'}, 'rimraf have been added to dependencies')

View File

@@ -29,7 +29,7 @@ test('relative link', async (t: tape.Test) => {
const linkedPkgPath = path.resolve('..', linkedPkgName)
await ncp(pathToLocalPkg(linkedPkgName), linkedPkgPath)
await link(`../${linkedPkgName}`, process.cwd(), testDefaults())
await link(`../${linkedPkgName}`, process.cwd(), await testDefaults())
isExecutable(t, path.resolve('node_modules', '.bin', 'hello-world-js-bin'))
@@ -45,11 +45,11 @@ test('relative link is not rewritten by install', async (t: tape.Test) => {
const linkedPkgPath = path.resolve('..', linkedPkgName)
await ncp(pathToLocalPkg(linkedPkgName), linkedPkgPath)
await link(`../${linkedPkgName}`, process.cwd(), testDefaults())
await link(`../${linkedPkgName}`, process.cwd(), await testDefaults())
const reporter = sinon.spy()
await installPkgs(['hello-world-js-bin'], testDefaults({reporter}))
await installPkgs(['hello-world-js-bin'], await testDefaults({reporter}))
t.ok(project.requireModule('hello-world-js-bin/package.json').isLocal)
@@ -77,7 +77,7 @@ test('global link', async function (t: tape.Test) {
process.chdir(linkedPkgPath)
const globalPrefix = path.resolve('..', 'global')
const globalBin = path.resolve('..', 'global', 'bin')
await linkToGlobal(process.cwd(), Object.assign(testDefaults(), {globalPrefix, globalBin}))
await linkToGlobal(process.cwd(), await testDefaults({globalPrefix, globalBin}))
isExecutable(t, path.join(globalBin, 'hello-world-js-bin'))
@@ -87,7 +87,7 @@ test('global link', async function (t: tape.Test) {
process.chdir(projectPath)
await linkFromGlobal(linkedPkgName, process.cwd(), Object.assign(testDefaults(), {globalPrefix}))
await linkFromGlobal(linkedPkgName, process.cwd(), await testDefaults({globalPrefix}))
isExecutable(t, path.resolve('node_modules', '.bin', 'hello-world-js-bin'))
})
@@ -98,7 +98,7 @@ test('failed linking should not create empty folder', async (t: tape.Test) => {
const globalPrefix = path.resolve('..', 'global')
try {
await linkFromGlobal('does-not-exist', process.cwd(), Object.assign(testDefaults(), {globalPrefix}))
await linkFromGlobal('does-not-exist', process.cwd(), await testDefaults({globalPrefix}))
t.fail('should have failed')
} catch (err) {
t.notOk(await exists(path.join(globalPrefix, 'node_modules', 'does-not-exist')))

View File

@@ -13,7 +13,7 @@ test('offline installation fails when package meta not found in local registry m
const project = prepare(t)
try {
await installPkgs(['is-positive@3.0.0'], testDefaults({offline: true}))
await installPkgs(['is-positive@3.0.0'], await testDefaults({}, {offline: true}, {offline: true}))
t.fail('installation should have failed')
} catch (err) {
t.equal(err.code, 'NO_OFFLINE_META', 'failed with correct error code')
@@ -23,12 +23,12 @@ test('offline installation fails when package meta not found in local registry m
test('offline installation fails when package tarball not found in local registry mirror', async function (t) {
const project = prepare(t)
await installPkgs(['is-positive@3.0.0'], testDefaults())
await installPkgs(['is-positive@3.0.0'], await testDefaults())
await rimraf('node_modules')
try {
await installPkgs(['is-positive@3.1.0'], testDefaults({offline: true}))
await installPkgs(['is-positive@3.1.0'], await testDefaults({}, {offline: true}, {offline: true}))
t.fail('installation should have failed')
} catch (err) {
t.equal(err.code, 'NO_OFFLINE_TARBALL', 'failed with correct error code')
@@ -38,11 +38,11 @@ test('offline installation fails when package tarball not found in local registr
test('successful offline installation', async function (t) {
const project = prepare(t)
await installPkgs(['is-positive@3.0.0'], testDefaults({save: true}))
await installPkgs(['is-positive@3.0.0'], await testDefaults({save: true}))
await rimraf('node_modules')
await install(testDefaults({offline: true}))
await install(await testDefaults({}, {offline: true}, {offline: true}))
const m = project.requireModule('is-positive')
t.ok(typeof m === 'function', 'module is available')

View File

@@ -3,7 +3,11 @@ import tape = require('tape')
import promisifyTape from 'tape-promise'
import writeYamlFile = require('write-yaml-file')
import exists = require('path-exists')
import {prepare, testDefaults, addDistTag} from './utils'
import {
prepare,
testDefaults,
addDistTag,
} from './utils'
import {
installPkgs,
install,
@@ -21,7 +25,7 @@ const test = promisifyTape(tape)
test('packageImportMethod can be set to copy', async (t: tape.Test) => {
const project = prepare(t)
await installPkgs(['is-negative'], testDefaults({packageImportMethod: 'copy'}))
await installPkgs(['is-negative'], await testDefaults({packageImportMethod: 'copy'}))
const m = project.requireModule('is-negative')
t.ok(m, 'is-negative is available with packageImportMethod = copy')

View File

@@ -12,10 +12,10 @@ import writePkg = require('write-pkg')
test('prune removes extraneous packages', async (t: tape.Test) => {
const project = prepare(t)
await installPkgs(['is-negative@2.1.0'], testDefaults({save: true}))
await installPkgs(['applyq@0.2.1'], testDefaults({saveDev: true}))
await installPkgs(['fnumber@0.1.0'], testDefaults({saveOptional: true}))
await installPkgs(['is-positive@2.0.0', '@zkochan/logger@0.1.0'], testDefaults())
await installPkgs(['is-negative@2.1.0'], await testDefaults({save: true}))
await installPkgs(['applyq@0.2.1'], await testDefaults({saveDev: true}))
await installPkgs(['fnumber@0.1.0'], await testDefaults({saveOptional: true}))
await installPkgs(['is-positive@2.0.0', '@zkochan/logger@0.1.0'], await testDefaults())
const pkg = await readPkg()
@@ -24,7 +24,7 @@ test('prune removes extraneous packages', async (t: tape.Test) => {
await writePkg(pkg)
await prune(testDefaults())
await prune(await testDefaults())
await project.storeHasNot('is-positive', '2.0.0')
await project.hasNot('is-positive')
@@ -45,10 +45,10 @@ test('prune removes extraneous packages', async (t: tape.Test) => {
test('prune removes dev dependencies in production', async (t: tape.Test) => {
const project = prepare(t)
await installPkgs(['is-positive@2.0.0'], testDefaults({saveDev: true}))
await installPkgs(['is-negative@2.1.0'], testDefaults({save: true}))
await installPkgs(['fnumber@0.1.0'], testDefaults({saveOptional: true}))
await prune(testDefaults({
await installPkgs(['is-positive@2.0.0'], await testDefaults({saveDev: true}))
await installPkgs(['is-negative@2.1.0'], await testDefaults({save: true}))
await installPkgs(['fnumber@0.1.0'], await testDefaults({saveOptional: true}))
await prune(await testDefaults({
production: true,
development: false,
}))

View File

@@ -16,9 +16,9 @@ const test = promisifyTape(tape)
test('rebuilds dependencies', async function (t: tape.Test) {
const project = prepare(t)
await installPkgs(['pre-and-postinstall-scripts-example', 'zkochan/install-scripts-example'], testDefaults({saveDev: true, ignoreScripts: true}))
await installPkgs(['pre-and-postinstall-scripts-example', 'zkochan/install-scripts-example'], await testDefaults({saveDev: true, ignoreScripts: true}))
await rebuild(testDefaults())
await rebuild(await testDefaults())
{
const generatedByPreinstall = project.requireModule('pre-and-postinstall-scripts-example/generated-by-preinstall')
@@ -39,9 +39,9 @@ test('rebuilds dependencies', async function (t: tape.Test) {
test('rebuilds specific dependencies', async function (t: tape.Test) {
const project = prepare(t)
await installPkgs(['pre-and-postinstall-scripts-example', 'zkochan/install-scripts-example'], testDefaults({saveDev: true, ignoreScripts: true}))
await installPkgs(['pre-and-postinstall-scripts-example', 'zkochan/install-scripts-example'], await testDefaults({saveDev: true, ignoreScripts: true}))
await rebuildPkgs(['install-scripts-example-for-pnpm'], testDefaults())
await rebuildPkgs(['install-scripts-example-for-pnpm'], await testDefaults())
await project.hasNot('pre-and-postinstall-scripts-example/generated-by-preinstall')
await project.hasNot('pre-and-postinstall-scripts-example/generated-by-postinstall')
@@ -55,8 +55,8 @@ test('rebuilds specific dependencies', async function (t: tape.Test) {
test('rebuild with pending option', async function (t: tape.Test) {
const project = prepare(t)
await installPkgs(['pre-and-postinstall-scripts-example'], testDefaults({ignoreScripts: true}))
await installPkgs(['zkochan/install-scripts-example'], testDefaults({ignoreScripts: true}))
await installPkgs(['pre-and-postinstall-scripts-example'], await testDefaults({ignoreScripts: true}))
await installPkgs(['zkochan/install-scripts-example'], await testDefaults({ignoreScripts: true}))
let modules = await project.loadModules()
t.doesNotEqual(modules['pendingBuilds'].length, 0)
@@ -67,7 +67,7 @@ test('rebuild with pending option', async function (t: tape.Test) {
await project.hasNot('install-scripts-example-for-pnpm/generated-by-preinstall')
await project.hasNot('install-scripts-example-for-pnpm/generated-by-postinstall')
await rebuild(testDefaults({rawNpmConfig: {'pending': true}}))
await rebuild(await testDefaults({rawNpmConfig: {'pending': true}}))
modules = await project.loadModules()
t.equal(modules['pendingBuilds'].length, 0)

View File

@@ -3,7 +3,11 @@ import tape = require('tape')
import promisifyTape from 'tape-promise'
import writeYamlFile = require('write-yaml-file')
import exists = require('path-exists')
import {prepare, testDefaults, addDistTag} from './utils'
import {
prepare,
testDefaults,
addDistTag,
} from './utils'
import {
installPkgs,
install,
@@ -21,7 +25,7 @@ const test = promisifyTape(tape)
test('shrinkwrap file has correct format', async (t: tape.Test) => {
const project = prepare(t)
await installPkgs(['pkg-with-1-dep', '@rstacruz/tap-spec@4.1.1', 'kevva/is-negative#1d7e288222b53a0cab90a331f1865220ec29560c'], testDefaults({save: true}))
await installPkgs(['pkg-with-1-dep', '@rstacruz/tap-spec@4.1.1', 'kevva/is-negative#1d7e288222b53a0cab90a331f1865220ec29560c'], await testDefaults({save: true}))
const modules = await project.loadModules()
t.equal(modules['pendingBuilds'].length, 0)
@@ -59,7 +63,7 @@ test('shrinkwrap file has dev deps even when installing for prod only', async (t
},
})
await install(testDefaults({production: true}))
await install(await testDefaults({production: true}))
const shr = await project.loadShrinkwrap()
const id = '/is-negative/2.1.0'
@@ -93,7 +97,7 @@ test('shrinkwrap with scoped package', async t => {
version: 3,
})
await install(testDefaults())
await install(await testDefaults())
})
test('fail when shasum from shrinkwrap does not match with the actual one', async (t: tape.Test) => {
@@ -120,7 +124,7 @@ test('fail when shasum from shrinkwrap does not match with the actual one', asyn
})
try {
await install(testDefaults())
await install(await testDefaults())
t.fail('installation should have failed')
} catch (err) {
t.equal(err.code, 'EINTEGRITY')
@@ -131,10 +135,10 @@ test("shrinkwrap doesn't lock subdependencies that don't satisfy the new specs",
const project = prepare(t)
// dependends on react-onclickoutside@5.9.0
await installPkgs(['react-datetime@2.8.8'], testDefaults({save: true}))
await installPkgs(['react-datetime@2.8.8'], await testDefaults({save: true}))
// dependends on react-onclickoutside@0.3.4
await installPkgs(['react-datetime@1.3.0'], testDefaults({save: true}))
await installPkgs(['react-datetime@1.3.0'], await testDefaults({save: true}))
t.equal(
project.requireModule('.localhost+4873/react-datetime/1.3.0/node_modules/react-onclickoutside/package.json').version,
@@ -149,7 +153,7 @@ test("shrinkwrap doesn't lock subdependencies that don't satisfy the new specs",
test('shrinkwrap not created when no deps in package.json', async (t: tape.Test) => {
const project = prepare(t)
await install(testDefaults())
await install(await testDefaults())
t.notOk(await project.loadShrinkwrap(), 'shrinkwrap file not created')
t.notOk(await exists('node_modules'), 'empty node_modules not created')
@@ -173,7 +177,7 @@ test('shrinkwrap removed when no deps in package.json', async t => {
},
})
await install(testDefaults())
await install(await testDefaults())
t.notOk(await project.loadShrinkwrap(), 'shrinkwrap file removed')
})
@@ -221,7 +225,7 @@ test('shrinkwrap is fixed when it does not match package.json', async (t: tape.T
})
const reporter = sinon.spy()
await install(testDefaults({reporter}))
await install(await testDefaults({reporter}))
const progress = sinon.match({
name: 'pnpm:progress',
@@ -278,8 +282,8 @@ test('doing named installation when shrinkwrap.yaml exists already', async (t: t
}
})
await installPkgs(['is-positive'], testDefaults())
await install(testDefaults())
await installPkgs(['is-positive'], await testDefaults())
await install(await testDefaults())
await project.has('is-negative')
})
@@ -298,11 +302,11 @@ test('respects shrinkwrap.yaml for top dependencies', async (t: tape.Test) => {
const pkgs = ['foo', 'bar', 'qar']
await Promise.all(pkgs.map(pkgName => addDistTag(pkgName, '100.0.0', 'latest')))
await installPkgs(['foo'], testDefaults({save: true, reporter}))
await installPkgs(['foo'], await testDefaults({save: true, reporter}))
// t.equal(reporter.withArgs(fooProgress).callCount, 1, 'reported foo once')
await installPkgs(['bar'], testDefaults({saveOptional: true}))
await installPkgs(['qar'], testDefaults({saveDev: true}))
await installPkgs(['foobar'], testDefaults({save: true}))
await installPkgs(['bar'], await testDefaults({saveOptional: true}))
await installPkgs(['qar'], await testDefaults({saveDev: true}))
await installPkgs(['foobar'], await testDefaults({save: true}))
t.equal((await loadJsonFile(path.resolve('node_modules', 'foo', 'package.json'))).version, '100.0.0')
t.equal((await loadJsonFile(path.resolve('node_modules', 'bar', 'package.json'))).version, '100.0.0')
@@ -319,7 +323,7 @@ test('respects shrinkwrap.yaml for top dependencies', async (t: tape.Test) => {
// shouldn't care about what the registry in npmrc is
// the one in shrinkwrap should be used
await install(testDefaults({
await install(await testDefaults({
registry: 'https://registry.npmjs.org',
rawNpmConfig: {
registry: 'https://registry.npmjs.org',
@@ -342,7 +346,7 @@ test('subdeps are updated on repeat install if outer shrinkwrap.yaml does not ma
await addDistTag('dep-of-pkg-with-1-dep', '100.0.0', 'latest')
await installPkgs(['pkg-with-1-dep'], testDefaults())
await installPkgs(['pkg-with-1-dep'], await testDefaults())
await project.storeHas('dep-of-pkg-with-1-dep', '100.0.0')
@@ -362,7 +366,7 @@ test('subdeps are updated on repeat install if outer shrinkwrap.yaml does not ma
await writeYamlFile('shrinkwrap.yaml', shr)
await install(testDefaults())
await install(await testDefaults())
await project.storeHas('dep-of-pkg-with-1-dep', '100.1.0')
})
@@ -370,9 +374,9 @@ test('subdeps are updated on repeat install if outer shrinkwrap.yaml does not ma
test("recreates shrinkwrap file if it doesn't match the dependencies in package.json", async (t: tape.Test) => {
const project = prepare(t)
await installPkgs(['is-negative@1.0.0'], testDefaults({saveExact: true, saveProd: true}))
await installPkgs(['is-positive@1.0.0'], testDefaults({saveExact: true, saveDev: true}))
await installPkgs(['map-obj@1.0.0'], testDefaults({saveExact: true, saveOptional: true}))
await installPkgs(['is-negative@1.0.0'], await testDefaults({saveExact: true, saveProd: true}))
await installPkgs(['is-positive@1.0.0'], await testDefaults({saveExact: true, saveDev: true}))
await installPkgs(['map-obj@1.0.0'], await testDefaults({saveExact: true, saveOptional: true}))
const shr1 = await project.loadShrinkwrap()
t.equal(shr1.dependencies['is-negative'], '1.0.0')
@@ -386,7 +390,7 @@ test("recreates shrinkwrap file if it doesn't match the dependencies in package.
await writePkg(pkg)
await install(testDefaults())
await install(await testDefaults())
const shr = await project.loadShrinkwrap()
@@ -403,7 +407,7 @@ test("recreates shrinkwrap file if it doesn't match the dependencies in package.
test('repeat install with shrinkwrap should not mutate shrinkwrap when dependency has version specified with v prefix', async (t: tape.Test) => {
const project = prepare(t)
await installPkgs(['highmaps-release@5.0.11'], testDefaults())
await installPkgs(['highmaps-release@5.0.11'], await testDefaults())
const shr1 = await project.loadShrinkwrap()
@@ -411,7 +415,7 @@ test('repeat install with shrinkwrap should not mutate shrinkwrap when dependenc
await rimraf('node_modules')
await install(testDefaults())
await install(await testDefaults())
const shr2 = await project.loadShrinkwrap()
@@ -423,11 +427,11 @@ test('package is not marked dev if it is also a subdep of a regular dependency',
await addDistTag('dep-of-pkg-with-1-dep', '100.0.0', 'latest')
await installPkgs(['pkg-with-1-dep'], testDefaults())
await installPkgs(['pkg-with-1-dep'], await testDefaults())
t.pass('installed pkg-with-1-dep')
await installPkgs(['dep-of-pkg-with-1-dep'], testDefaults({saveDev: true}))
await installPkgs(['dep-of-pkg-with-1-dep'], await testDefaults({saveDev: true}))
t.pass('installed optional dependency which is also a dependency of pkg-with-1-dep')
@@ -441,8 +445,8 @@ test('package is not marked optional if it is also a subdep of a regular depende
await addDistTag('dep-of-pkg-with-1-dep', '100.0.0', 'latest')
await installPkgs(['pkg-with-1-dep'], testDefaults())
await installPkgs(['dep-of-pkg-with-1-dep'], testDefaults({saveOptional: true}))
await installPkgs(['pkg-with-1-dep'], await testDefaults())
await installPkgs(['dep-of-pkg-with-1-dep'], await testDefaults({saveOptional: true}))
const shr = await project.loadShrinkwrap()
@@ -451,7 +455,7 @@ test('package is not marked optional if it is also a subdep of a regular depende
test('scoped module from different registry', async function (t: tape.Test) {
const project = prepare(t)
await installPkgs(['@zkochan/foo', 'is-positive'], testDefaults({
await installPkgs(['@zkochan/foo', 'is-positive'], await testDefaults({
rawNpmConfig: {
'@zkochan:registry': 'https://registry.npmjs.org/'
}
@@ -501,11 +505,11 @@ test('scoped module from different registry', async function (t: tape.Test) {
test('repeat install with no inner shrinkwrap should not rewrite packages in node_modules', async (t: tape.Test) => {
const project = prepare(t)
await installPkgs(['is-negative@1.0.0'], testDefaults())
await installPkgs(['is-negative@1.0.0'], await testDefaults())
await rimraf('node_modules/.shrinkwrap.yaml')
await install(testDefaults())
await install(await testDefaults())
const m = project.requireModule('is-negative')
t.ok(m)
@@ -516,7 +520,7 @@ test('repeat install with no inner shrinkwrap should not rewrite packages in nod
test['skip']('installing from shrinkwrap when using npm enterprise', async (t: tape.Test) => {
const project = prepare(t)
const opts = testDefaults({registry: 'https://npm-registry.compass.com/'})
const opts = await testDefaults({registry: 'https://npm-registry.compass.com/'})
await installPkgs(['is-positive@3.1.0'], opts)
@@ -565,7 +569,7 @@ test('packages are placed in devDependencies even if they are present as non-dev
await addDistTag('dep-of-pkg-with-1-dep', '1.1.0', 'latest')
const reporter = sinon.spy()
await install(testDefaults({reporter}))
await install(await testDefaults({reporter}))
const shr = await project.loadShrinkwrap()
@@ -597,8 +601,8 @@ test('packages are placed in devDependencies even if they are present as non-dev
test('updating package that has a github-hosted dependency', async (t: tape.Test) => {
const project = prepare(t)
await installPkgs(['has-github-dep@1'], testDefaults())
await installPkgs(['has-github-dep@latest'], testDefaults())
await installPkgs(['has-github-dep@1'], await testDefaults())
await installPkgs(['has-github-dep@latest'], await testDefaults())
t.pass('installation of latest did not fail')
})
@@ -606,8 +610,8 @@ test('updating package that has a github-hosted dependency', async (t: tape.Test
test('updating package that has deps with peers', async (t: tape.Test) => {
const project = prepare(t)
await installPkgs(['abc-grand-parent-with-c@0'], testDefaults())
await installPkgs(['abc-grand-parent-with-c@1'], testDefaults())
await installPkgs(['abc-grand-parent-with-c@0'], await testDefaults())
await installPkgs(['abc-grand-parent-with-c@1'], await testDefaults())
t.pass('installation of latest did not fail')
})
@@ -666,7 +670,7 @@ test('updating shrinkwrap version 3 to 3.1', async (t: tape.Test) => {
await fs.writeFile('shrinkwrap.yaml', shrV3Content, 'utf8')
await install(testDefaults())
await install(await testDefaults())
const shr = await project.loadShrinkwrap()
@@ -682,14 +686,14 @@ test('pendingBuilds gets updated if install removes packages', async (t: tape.Te
},
})
await install(testDefaults({ ignoreScripts: true }))
await install(await testDefaults({ ignoreScripts: true }))
const modules1 = await project.loadModules()
await project.rewriteDependencies({
'is-negative': '2.1.0',
})
await install(testDefaults({ ignoreScripts: true }))
await install(await testDefaults({ ignoreScripts: true }))
const modules2 = await project.loadModules()
t.ok(modules1['pendingBuilds'].length > modules2['pendingBuilds'].length, 'pendingBuilds gets updated when install removes packages')

View File

@@ -17,13 +17,13 @@ const test = promisifyTape(tape)
test('remove unreferenced packages', async (t: tape.Test) => {
const project = prepare(t)
await installPkgs(['is-negative@2.1.0'], testDefaults({ save: true }))
await uninstall(['is-negative'], testDefaults({ save: true }))
await installPkgs(['is-negative@2.1.0'], await testDefaults({ save: true }))
await uninstall(['is-negative'], await testDefaults({ save: true }))
await project.storeHas('is-negative', '2.1.0')
const reporter = sinon.spy()
await storePrune(testDefaults({reporter}))
await storePrune(await testDefaults({reporter}))
t.ok(reporter.calledWithMatch({
level: 'info',
@@ -33,7 +33,7 @@ test('remove unreferenced packages', async (t: tape.Test) => {
await project.storeHasNot('is-negative', '2.1.0')
reporter.reset()
await storePrune(testDefaults({reporter}))
await storePrune(await testDefaults({reporter}))
t.notOk(reporter.calledWithMatch({
level: 'info',
@@ -44,7 +44,7 @@ test('remove unreferenced packages', async (t: tape.Test) => {
test('remove packages that are used by project that no longer exist', async (t: tape.Test) => {
const project = prepare(t)
await installPkgs(['is-negative@2.1.0'], testDefaults({ save: true }))
await installPkgs(['is-negative@2.1.0'], await testDefaults({ save: true }))
const pkgInStore = await project.resolve('is-negative', '2.1.0')
@@ -53,7 +53,7 @@ test('remove packages that are used by project that no longer exist', async (t:
t.ok(await exists(pkgInStore))
const reporter = sinon.spy()
await storePrune(testDefaults({reporter}))
await storePrune(await testDefaults({reporter}))
t.ok(reporter.calledWithMatch({
level: 'info',
@@ -65,9 +65,9 @@ test('remove packages that are used by project that no longer exist', async (t:
test('keep dependencies used by others', async function (t: tape.Test) {
const project = prepare(t)
await installPkgs(['camelcase-keys@3.0.0'], testDefaults({ save: true }))
await installPkgs(['hastscript@3.0.0'], testDefaults({ saveDev: true }))
await uninstall(['camelcase-keys'], testDefaults({ save: true }))
await installPkgs(['camelcase-keys@3.0.0'], await testDefaults({ save: true }))
await installPkgs(['hastscript@3.0.0'], await testDefaults({ saveDev: true }))
await uninstall(['camelcase-keys'], await testDefaults({ save: true }))
await project.storeHas('camelcase-keys', '3.0.0')
await project.hasNot('camelcase-keys')
@@ -86,7 +86,7 @@ test('keep dependencies used by others', async function (t: tape.Test) {
R.toPairs(shr.packages).forEach(pair => t.ok(pair[1]['dev'], `${pair[0]} is dev`))
await storePrune(testDefaults())
await storePrune(await testDefaults())
await project.storeHasNot('camelcase-keys', '3.0.0')
await project.storeHasNot('map-obj', '1.0.1')
@@ -95,10 +95,10 @@ test('keep dependencies used by others', async function (t: tape.Test) {
test('keep dependency used by package', async (t: tape.Test) => {
const project = prepare(t)
await installPkgs(['is-not-positive@1.0.0', 'is-positive@3.1.0'], testDefaults({ save: true }))
await uninstall(['is-not-positive'], testDefaults({ save: true }))
await installPkgs(['is-not-positive@1.0.0', 'is-positive@3.1.0'], await testDefaults({ save: true }))
await uninstall(['is-not-positive'], await testDefaults({ save: true }))
await storePrune(testDefaults())
await storePrune(await testDefaults())
await project.storeHas('is-positive', '3.1.0')
})

View File

@@ -9,7 +9,7 @@ const test = promisifyTape(tape)
test('store status returns empty array when store was not modified', async function (t: tape.Test) {
const project = prepare(t)
const opts = testDefaults()
const opts = await testDefaults()
await installPkgs(['is-positive@3.1.0'], opts)
const mutatedPkgs = await storeStatus(opts)
@@ -20,7 +20,7 @@ test('store status returns empty array when store was not modified', async funct
test('store status does not fail on not installed optional dependencies', async function (t: tape.Test) {
const project = prepare(t)
const opts = testDefaults({saveOptional: true})
const opts = await testDefaults({saveOptional: true})
await installPkgs(['not-compatible-with-any-os'], opts)
const mutatedPkgs = await storeStatus(opts)
@@ -31,7 +31,7 @@ test('store status does not fail on not installed optional dependencies', async
test('store status returns path to the modified package', async function (t: tape.Test) {
const project = prepare(t)
const opts = testDefaults()
const opts = await testDefaults()
await installPkgs(['is-positive@3.1.0'], opts)
const isPositive = await project.resolve('is-positive', '3.1.0', 'index.js')

View File

@@ -30,8 +30,8 @@ test('uninstall package with no dependencies', async (t: tape.Test) => {
const project = prepare(t)
const reporter = sinon.spy()
await installPkgs(['is-negative@2.1.0'], testDefaults({ save: true }))
await uninstall(['is-negative'], testDefaults({ save: true, reporter }))
await installPkgs(['is-negative@2.1.0'], await testDefaults({ save: true }))
await uninstall(['is-negative'], await testDefaults({ save: true, reporter }))
t.ok(reporter.calledWithMatch(<StatsLog>{
name: 'pnpm:stats',
@@ -60,8 +60,8 @@ test('uninstall package with no dependencies', async (t: tape.Test) => {
test('uninstall scoped package', async function (t) {
const project = prepare(t)
await installPkgs(['@zkochan/logger@0.1.0'], testDefaults({ save: true }))
await uninstall(['@zkochan/logger'], testDefaults({ save: true }))
await installPkgs(['@zkochan/logger@0.1.0'], await testDefaults({ save: true }))
await uninstall(['@zkochan/logger'], await testDefaults({ save: true }))
await project.storeHas('@zkochan/logger', '0.1.0')
@@ -73,8 +73,8 @@ test('uninstall scoped package', async function (t) {
test('uninstall tarball dependency', async (t: tape.Test) => {
const project = prepare(t)
await installPkgs(['http://registry.npmjs.org/is-array/-/is-array-1.0.1.tgz'], testDefaults({ save: true }))
await uninstall(['is-array'], testDefaults({ save: true }))
await installPkgs(['http://registry.npmjs.org/is-array/-/is-array-1.0.1.tgz'], await testDefaults({ save: true }))
await uninstall(['is-array'], await testDefaults({ save: true }))
t.ok(await exists(path.join(await project.getStorePath(), 'registry.npmjs.org', 'is-array', '1.0.1')))
@@ -86,10 +86,10 @@ test('uninstall tarball dependency', async (t: tape.Test) => {
test('uninstall package with dependencies and do not touch other deps', async function (t) {
const project = prepare(t)
await installPkgs(['is-negative@2.1.0', 'camelcase-keys@3.0.0'], testDefaults({ save: true }))
await uninstall(['camelcase-keys'], testDefaults({ save: true }))
await installPkgs(['is-negative@2.1.0', 'camelcase-keys@3.0.0'], await testDefaults({ save: true }))
await uninstall(['camelcase-keys'], await testDefaults({ save: true }))
await storePrune(testDefaults())
await storePrune(await testDefaults())
await project.storeHasNot('camelcase-keys', '3.0.0')
await project.hasNot('camelcase-keys')
@@ -117,8 +117,8 @@ test('uninstall package with dependencies and do not touch other deps', async fu
test('uninstall package with its bin files', async function (t) {
prepare(t)
await installPkgs(['sh-hello-world@1.0.1'], testDefaults({ save: true }))
await uninstall(['sh-hello-world'], testDefaults({ save: true }))
await installPkgs(['sh-hello-world@1.0.1'], await testDefaults({ save: true }))
await uninstall(['sh-hello-world'], await testDefaults({ save: true }))
// check for both a symlink and a file because in some cases the file will be a proxied not symlinked
let stat = await existsSymlink(path.resolve('node_modules', '.bin', 'sh-hello-world'))
@@ -135,8 +135,8 @@ test('relative link is uninstalled', async (t: tape.Test) => {
const linkedPkgPath = path.resolve('..', linkedPkgName)
await ncp(pathToLocalPkg(linkedPkgName), linkedPkgPath)
await link(`../${linkedPkgName}`, process.cwd(), testDefaults())
await uninstall([linkedPkgName], testDefaults())
await link(`../${linkedPkgName}`, process.cwd(), await testDefaults())
await uninstall([linkedPkgName], await testDefaults())
await project.hasNot(linkedPkgName)
})
@@ -144,12 +144,12 @@ test('relative link is uninstalled', async (t: tape.Test) => {
test('pendingBuilds gets updated after uninstall', async (t: tape.Test) => {
const project = prepare(t)
await installPkgs(['is-negative@2.1.0', 'sh-hello-world@1.0.1'], testDefaults({save: true, ignoreScripts: true}))
await installPkgs(['is-negative@2.1.0', 'sh-hello-world@1.0.1'], await testDefaults({save: true, ignoreScripts: true}))
const modules1 = await project.loadModules()
t.doesNotEqual(modules1['pendingBuilds'].length, 0, 'installPkgs should update pendingBuilds')
await uninstall(['sh-hello-world'], testDefaults({save: true}))
await uninstall(['sh-hello-world'], await testDefaults({save: true}))
const modules2 = await project.loadModules()
t.doesNotEqual(modules2['pendingBuilds'].length, 0, 'uninstall should not remove all the pendingBuilds')

View File

@@ -43,11 +43,11 @@ test('unlink 1 package that exists in package.json', async (t: tape.Test) => {
}),
])
await link('is-subdir', 'project')
await link('is-positive', 'project')
await link('is-subdir', 'project', await testDefaults())
await link('is-positive', 'project', await testDefaults())
process.chdir('project')
await unlinkPkgs(['is-subdir'], testDefaults())
await unlinkPkgs(['is-subdir'], await testDefaults())
t.equal(typeof project.requireModule('is-subdir'), 'function', 'is-subdir installed after unlinked')
t.notOk((await isInnerLink('node_modules', 'is-positive')).isInner, 'is-positive left linked')
@@ -57,7 +57,7 @@ test("don't update package when unlinking", async (t: tape.Test) => {
const project = prepare(t)
await addDistTag('foo', '100.0.0', 'latest')
await installPkgs(['foo'], testDefaults())
await installPkgs(['foo'], await testDefaults())
process.chdir('..')
@@ -66,11 +66,11 @@ test("don't update package when unlinking", async (t: tape.Test) => {
version: '100.0.0',
})
await link('foo', 'project')
await link('foo', 'project', await testDefaults())
await addDistTag('foo', '100.1.0', 'latest')
process.chdir('project')
await unlinkPkgs(['foo'], testDefaults())
await unlinkPkgs(['foo'], await testDefaults())
t.equal(project.requireModule('foo/package.json').version, '100.0.0', 'foo not updated after unlink')
})
@@ -97,11 +97,11 @@ test('unlink 2 packages. One of them exists in package.json', async (t: tape.Tes
}),
])
await link('is-subdir', 'project')
await link('is-positive', 'project')
await link('is-subdir', 'project', await testDefaults())
await link('is-positive', 'project', await testDefaults())
process.chdir('project')
await unlinkPkgs(['is-subdir', 'is-positive'], testDefaults())
await unlinkPkgs(['is-subdir', 'is-positive'], await testDefaults())
t.equal(typeof project.requireModule('is-subdir'), 'function', 'is-subdir installed after unlinked')
t.notOk(await exists(path.join('node_modules', 'is-positive')), 'is-positive removed as it is not in package.json')
@@ -130,11 +130,11 @@ test('unlink all packages', async (t: tape.Test) => {
}),
])
await link('is-subdir', 'project')
await link('logger', 'project')
await link('is-subdir', 'project', await testDefaults())
await link('logger', 'project', await testDefaults())
process.chdir('project')
await unlink(testDefaults())
await unlink(await testDefaults())
t.equal(typeof project.requireModule('is-subdir'), 'function', 'is-subdir installed after unlinked')
t.equal(typeof project.requireModule('@zkochan/logger'), 'object', '@zkochan/logger installed after unlinked')
@@ -143,10 +143,10 @@ test('unlink all packages', async (t: tape.Test) => {
test("don't warn about scoped packages when running unlink w/o params", async (t: tape.Test) => {
const project = prepare(t)
await installPkgs(['@zkochan/logger'], testDefaults())
await installPkgs(['@zkochan/logger'], await testDefaults())
const reporter = sinon.spy()
await unlink(testDefaults({reporter}))
await unlink(await testDefaults({reporter}))
t.notOk(reporter.calledWithMatch({
level: 'warn',
@@ -159,9 +159,9 @@ test("don't unlink package that is not a link", async (t: tape.Test) => {
const reporter = sinon.spy()
await installPkgs(['is-positive'], testDefaults())
await installPkgs(['is-positive'], await testDefaults())
await unlinkPkgs(['is-positive'], testDefaults({reporter}))
await unlinkPkgs(['is-positive'], await testDefaults({reporter}))
t.ok(reporter.calledWithMatch({
level: 'warn',
@@ -174,9 +174,9 @@ test("don't unlink package that is not a link when independent-leaves = true", a
const reporter = sinon.spy()
await installPkgs(['is-positive'], testDefaults({independentLeaves: true}))
await installPkgs(['is-positive'], await testDefaults({independentLeaves: true}))
await unlinkPkgs(['is-positive'], testDefaults({independentLeaves: true, reporter}))
await unlinkPkgs(['is-positive'], await testDefaults({independentLeaves: true, reporter}))
t.ok(reporter.calledWithMatch({
level: 'warn',

View File

@@ -59,11 +59,13 @@ export default function prepare (t: Test, pkg?: Object) {
return path.join(await project.getStorePath(), pkgFolder, 'package')
},
storeHas: async function (pkgName: string, version?: string) {
t.ok(await exists(await project.resolve(pkgName, version)), `${pkgName}@${version} is in store`)
const pathToCheck = await project.resolve(pkgName, version)
t.ok(await exists(pathToCheck), `${pkgName}@${version} is in store (at ${pathToCheck})`)
},
storeHasNot: async function (pkgName: string, version?: string) {
try {
t.notOk(await exists(await project.resolve(pkgName, version)), `${pkgName}@${version} is not in store`)
const pathToCheck = await project.resolve(pkgName, version)
t.notOk(await exists(pathToCheck), `${pkgName}@${version} is not in store (at ${pathToCheck})`)
} catch (err) {
if (err.message === 'Cannot find module store') {
t.pass(`${pkgName}@${version} is not in store`)

View File

@@ -1,9 +1,41 @@
import {PnpmOptions} from 'supi'
import {InstallOptions} from 'supi'
import path = require('path')
import createStore, {resolveStore} from 'package-store'
import createFetcher from '@pnpm/default-fetcher'
import createResolver from '@pnpm/default-resolver'
export default function testDefaults (opts?: PnpmOptions): PnpmOptions & {store: string} {
const registry = 'http://localhost:4873/'
export default async function testDefaults (
opts?: any,
resolveOpts?: any,
fetchOpts?: any,
): Promise<InstallOptions> {
let store = opts && opts.store || path.resolve('..', '.store')
store = await resolveStore(store, opts && opts.prefix || process.cwd())
const rawNpmConfig = {registry}
const storeController = await createStore(
createResolver({
metaCache: new Map(),
rawNpmConfig,
store,
strictSsl: true,
...resolveOpts,
}),
createFetcher({
alwaysAuth: true,
registry,
rawNpmConfig,
...fetchOpts,
}) as {},
{
store,
locks: path.join(store, '_locks'),
}
)
return Object.assign({
store: path.resolve('..', '.store'),
registry: 'http://localhost:4873/',
store,
storeController,
registry,
}, opts)
}