Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
}
opts['preserveWorkspaceProtocol'] = !opts.linkWorkspacePackages
}
// `pnpm install ""` is going to be just `pnpm install`
input = input.filter(Boolean)
const dir = opts.dir || process.cwd()
const workspacePackages = opts.workspaceDir
? arrayOfWorkspacePackagesToMap(
await findWorkspacePackages(opts.workspaceDir, opts),
)
: undefined
const store = await createOrConnectStoreController(opts)
const installOpts = {
...opts,
// In case installation is done in a multi-package repository
// The dependencies should be built first,
// so ignoring scripts for now
ignoreScripts: !!workspacePackages || opts.ignoreScripts,
storeController: store.ctrl,
storeDir: store.dir,
workspacePackages,
forceHoistPattern: typeof opts.rawLocalConfig['hoist-pattern'] !== 'undefined' || typeof opts.rawLocalConfig['hoist'] !== 'undefined',
forceIndependentLeaves: typeof opts.rawLocalConfig['independent-leaves'] !== 'undefined',
forceShamefullyHoist: typeof opts.rawLocalConfig['shamefully-hoist'] !== 'undefined',
}
if (!opts.ignorePnpmfile) {
installOpts['hooks'] = requireHooks(opts.lockfileDir || dir, opts)
export async function handler (
input: string[],
opts: CreateStoreControllerOptions & Omit,
) {
// Removing existing pnpm lockfile
// it should not influence the new one
await rimraf(path.join(opts.dir, WANTED_LOCKFILE))
const npmPackageLock = await readNpmLockfile(opts.dir)
const versionsByPackageNames = {}
getAllVersionsByPackageNames(npmPackageLock, versionsByPackageNames)
const preferredVersions = getPreferredVersions(versionsByPackageNames)
const store = await createOrConnectStoreController(opts)
const installOpts = {
...opts,
lockfileOnly: true,
preferredVersions,
storeController: store.ctrl,
storeDir: store.dir,
}
await install(await readImporterManifestOnly(opts.dir), installOpts)
}
switch (cmdFullName) {
case 'test':
throwOnFail(await run(chunks, opts.selectedWsPkgsGraph, ['test', ...input], cmd, opts as any)) // tslint:disable-line:no-any
return true
case 'run':
throwOnFail(await run(chunks, opts.selectedWsPkgsGraph, input, cmd, { ...opts, allPackagesAreSelected } as any)) // tslint:disable-line:no-any
return true
case 'update':
opts = { ...opts, update: true, allowNew: false } as any // tslint:disable-line:no-any
break
case 'exec':
throwOnFail(await exec(chunks, opts.selectedWsPkgsGraph, input, cmd, opts as any)) // tslint:disable-line:no-any
return true
}
const store = await createOrConnectStoreController(opts)
// It is enough to save the store.json file once,
// once all installations are done.
// That's why saveState that is passed to the install engine
// does nothing.
const saveState = store.ctrl.saveState
const storeController = {
...store.ctrl,
saveState: async () => undefined,
}
const workspacePackages = cmdFullName !== 'unlink'
? arrayOfWorkspacePackagesToMap(allWsPkgs)
: {}
const installOpts = Object.assign(opts, {
ownLifecycleHooksStdio: 'pipe',
manifestsByPath[dir] = { manifest, writeImporterManifest }
}
scopeLogger.debug({
selected: pkgs.length,
total: allWsPkgs.length,
workspacePrefix: opts.workspaceDir,
})
const throwOnFail = throwOnCommandFail.bind(null, `pnpm recursive ${cmdFullName}`)
const chunks = opts.sort !== false
? sortPackages(opts.selectedWsPkgsGraph)
: [Object.keys(opts.selectedWsPkgsGraph).sort()]
const store = await createOrConnectStoreController(opts)
// It is enough to save the store.json file once,
// once all installations are done.
// That's why saveState that is passed to the install engine
// does nothing.
const saveState = store.ctrl.saveState
const storeController = {
...store.ctrl,
saveState: async () => undefined,
}
const workspacePackages = cmdFullName !== 'unlink'
? arrayOfWorkspacePackagesToMap(allWsPkgs)
: {}
const installOpts = Object.assign(opts, {
ownLifecycleHooksStdio: 'pipe',
export async function handler (
input: string[],
opts: CreateStoreControllerOptions & Pick,
) {
const store = await createOrConnectStoreController(opts)
const removeOpts = Object.assign(opts, {
storeController: store.ctrl,
storeDir: store.dir,
})
if (!opts.ignorePnpmfile) {
removeOpts['hooks'] = requireHooks(opts.lockfileDir || opts.dir, opts)
}
removeOpts['workspacePackages'] = opts.workspaceDir
? arrayOfWorkspacePackagesToMap(await findWorkspacePackages(opts.workspaceDir, opts))
: undefined
const currentManifest = await readImporterManifest(opts.dir, opts)
const [mutationResult] = await mutateModules(
[
{
binsDir: opts.bin,
dependencyNames: input,
export async function handler (input: string[], opts: Pick & CreateStoreControllerOptions) {
const store = await createOrConnectStoreController(opts)
return mutateModules([
{
buildIndex: 0,
manifest: await readImporterManifestOnly(process.cwd(), opts),
mutation: 'install',
pruneDirectDependencies: true,
rootDir: process.cwd(),
},
], {
...opts,
pruneStore: true,
storeController: store.ctrl,
storeDir: store.dir,
} as InstallOptions)
}
manifestsByPath[dir] = { manifest, writeImporterManifest }
}
scopeLogger.debug({
selected: pkgs.length,
total: allWsPkgs.length,
workspacePrefix: opts.workspaceDir,
})
const throwOnFail = throwOnCommandFail.bind(null, `pnpm recursive rebuild`)
const chunks = opts.sort !== false
? sortPackages(opts.selectedWsPkgsGraph)
: [Object.keys(opts.selectedWsPkgsGraph).sort()]
const store = await createOrConnectStoreController(opts)
const workspacePackages = arrayOfWorkspacePackagesToMap(allWsPkgs)
const rebuildOpts = Object.assign(opts, {
ownLifecycleHooksStdio: 'pipe',
pruneLockfileImporters: (!opts.ignoredPackages || opts.ignoredPackages.size === 0)
&& pkgs.length === allWsPkgs.length,
storeController: store.ctrl,
storeDir: store.dir,
workspacePackages,
}) as RebuildOptions
const result = {
fails: [],
passes: 0,
} as RecursiveSummary
export async function handler (
args: string[],
opts: Pick &
CreateStoreControllerOptions &
{ reporter?: (logObj: LogBase) => void, pending: boolean },
) {
const store = await createOrConnectStoreController(opts)
const rebuildOpts = Object.assign(opts, {
storeController: store.ctrl,
storeDir: store.dir,
})
if (args.length === 0) {
await rebuild(
[
{
buildIndex: 0,
manifest: await readImporterManifestOnly(rebuildOpts.dir, opts),
rootDir: rebuildOpts.dir,
},
],
rebuildOpts,
)
export async function handler (input: string[], opts: StoreCommandOptions) {
let store
switch (input[0]) {
case 'status':
return statusCmd(opts)
case 'prune':
store = await createOrConnectStoreController(opts)
const storePruneOptions = Object.assign(opts, {
storeController: store.ctrl,
storeDir: store.dir,
})
return storePrune(storePruneOptions)
case 'add':
store = await createOrConnectStoreController(opts)
return storeAdd(input.slice(1), {
prefix: opts.dir,
registries: opts.registries,
reporter: opts.reporter,
storeController: store.ctrl,
tag: opts.tag,
})
case 'usages':
store = await createOrConnectStoreController(opts)
const packageSelectors = input.slice(1)
const packageUsagesBySelectors = await storeUsages(packageSelectors, {
reporter: opts.reporter,
storeController: store.ctrl,
})
return prettyPrintUsages(packageSelectors, packageUsagesBySelectors)
default: