How to use @pnpm/modules-yaml - 7 common examples

To help you get started, we’ve selected a few @pnpm/modules-yaml examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pnpm / pnpm / packages / supi / src / install / index.ts View on Github external
(() => {
        if (result.currentLockfile.packages === undefined && result.removedDepPaths.size === 0) {
          return Promise.resolve()
        }
        return writeModulesYaml(ctx.rootModulesDir, {
          ...ctx.modulesFile,
          hoistedAliases: result.newHoistedAliases,
          hoistPattern: ctx.hoistPattern,
          included: ctx.include,
          independentLeaves: ctx.independentLeaves,
          layoutVersion: LAYOUT_VERSION,
          packageManager: `${opts.packageManager.name}@${opts.packageManager.version}`,
          pendingBuilds: ctx.pendingBuilds,
          registries: ctx.registries,
          shamefullyHoist: ctx.shamefullyHoist,
          skipped: Array.from(ctx.skipped),
          store: ctx.storeDir,
          virtualStoreDir: ctx.virtualStoreDir,
        })
      })(),
    ])
github pnpm / pnpm / packages / supi / src / uninstall / index.ts View on Github external
const shrinkwrapOpts = { forceSharedFormat: opts.forceSharedShrinkwrap }
  if (opts.shrinkwrap) {
    await saveShrinkwrap(ctx.shrinkwrapDirectory, newShr, currentShrinkwrap, shrinkwrapOpts)
  } else {
    await saveCurrentShrinkwrapOnly(ctx.shrinkwrapDirectory, currentShrinkwrap, shrinkwrapOpts)
  }

  if (opts.shamefullyFlatten) {
    ctx.hoistedAliases = await shamefullyFlattenByShrinkwrap(currentShrinkwrap, ctx.importerId, {
      defaultRegistry: ctx.registries.default,
      modulesDir: ctx.modulesDir,
      prefix: opts.prefix,
      virtualStoreDir: ctx.virtualStoreDir,
    }) || {}
  }
  await writeModulesYaml(ctx.virtualStoreDir, {
    ...ctx.modulesFile,
    importers: {
      ...ctx.modulesFile && ctx.modulesFile.importers,
      [ctx.importerId]: {
        hoistedAliases: ctx.hoistedAliases,
        shamefullyFlatten: opts.shamefullyFlatten,
      },
    },
    included: ctx.include,
    independentLeaves: opts.independentLeaves,
    layoutVersion: LAYOUT_VERSION,
    packageManager: `${opts.packageManager.name}@${opts.packageManager.version}`,
    pendingBuilds: ctx.pendingBuilds,
    registries: ctx.registries,
    skipped: Array.from(ctx.skipped).filter((pkgId) => !removedPkgIds.has(pkgId)),
    store: ctx.storePath,
github pnpm / pnpm / packages / supi / src / uninstall / index.ts View on Github external
getIndependentPackageLocation: opts.independentLeaves
        ? async (packageId: string, packageName: string) => {
          const { directory } = await opts.storeController.getPackageLocation(packageId, packageName, {
            lockfileDirectory: ctx.lockfileDirectory,
            targetEngine: opts.sideEffectsCacheRead && ENGINE_NAME || undefined,
          })
          return directory
        }
        : undefined,
      lockfileDirectory: opts.lockfileDirectory,
      modulesDir: ctx.modulesDir,
      registries: ctx.registries,
      virtualStoreDir: ctx.virtualStoreDir,
    }) || {}
  }
  await writeModulesYaml(ctx.virtualStoreDir, {
    ...ctx.modulesFile,
    importers: {
      ...ctx.modulesFile && ctx.modulesFile.importers,
      [ctx.importerId]: {
        hoistedAliases: ctx.hoistedAliases,
        shamefullyFlatten: opts.shamefullyFlatten,
      },
    },
    included: ctx.include,
    independentLeaves: opts.independentLeaves,
    layoutVersion: LAYOUT_VERSION,
    packageManager: `${opts.packageManager.name}@${opts.packageManager.version}`,
    pendingBuilds: ctx.pendingBuilds,
    registries: ctx.registries,
    skipped: Array.from(ctx.skipped).filter((pkgId) => !removedPkgIds.has(pkgId)),
    store: ctx.storePath,
github pnpm / pnpm / packages / plugin-commands-rebuild / src / implementation / index.ts View on Github external
rawConfig: opts.rawConfig,
    unsafePerm: opts.unsafePerm || false,
  }
  await runLifecycleHooksConcurrently(
    ['preinstall', 'install', 'postinstall', 'prepublish', 'prepare'],
    ctx.importers,
    opts.childConcurrency || 5,
    scriptsOpts,
  )
  for (const { id, manifest } of ctx.importers) {
    if (manifest?.scripts && (!opts.pending || ctx.pendingBuilds.includes(id))) {
      ctx.pendingBuilds.splice(ctx.pendingBuilds.indexOf(id), 1)
    }
  }

  await writeModulesYaml(ctx.rootModulesDir, {
    ...ctx.modulesFile,
    hoistedAliases: ctx.hoistedAliases,
    hoistPattern: ctx.hoistPattern,
    included: ctx.include,
    independentLeaves: ctx.independentLeaves,
    layoutVersion: LAYOUT_VERSION,
    packageManager: `${opts.packageManager.name}@${opts.packageManager.version}`,
    pendingBuilds: ctx.pendingBuilds,
    registries: ctx.registries,
    shamefullyHoist: ctx.shamefullyHoist,
    skipped: Array.from(ctx.skipped),
    store: ctx.storeDir,
    virtualStoreDir: ctx.virtualStoreDir,
  })
}
github pnpm / pnpm / packages / read-importers-context / src / index.ts View on Github external
hoistedAliases: { [depPath: string]: string[] },
  importers: Array<{
    id: string,
    modulesDir: string,
  } & T & Required>,
  include: Record,
  independentLeaves: boolean | undefined,
  modules: Modules | null,
  pendingBuilds: string[],
  registries: Registries | null | undefined,
  rootModulesDir: string,
  shamefullyHoist?: boolean,
  skipped: Set,
}> {
  const rootModulesDir = await realNodeModulesDir(lockfileDir)
  const modules = await readModulesYaml(rootModulesDir)
  return {
    currentHoistPattern: modules?.hoistPattern || undefined,
    hoist: !modules ? undefined : Boolean(modules.hoistPattern),
    hoistedAliases: modules?.hoistedAliases || {},
    importers: await Promise.all(
      importers.map(async (importer) => {
        const modulesDir = await realNodeModulesDir(importer.rootDir)
        const importerId = getLockfileImporterId(lockfileDir, importer.rootDir)

        return {
          ...importer,
          binsDir: importer.binsDir || path.join(importer.rootDir, 'node_modules', '.bin'),
          id: importerId,
          modulesDir,
        }
      })),
github pnpm / pnpm / privatePackages / assert-project / src / index.ts View on Github external
async function getVirtualStoreDir () {
    const modulesYaml = await readModules(modules)
    if (!modulesYaml) {
      return path.join(modules, '.pnpm')
    }
    return modulesYaml.virtualStoreDir
  }
github pnpm / pnpm / packages / plugin-commands-outdated / src / outdated.ts View on Github external
export async function outdatedDependenciesOfWorkspacePackages (
  pkgs: Array<{dir: string, manifest: ImporterManifest}>,
  args: string[],
  opts: OutdatedOptions,
) {
  const lockfileDir = opts.lockfileDir || opts.dir
  const modules = await readModulesManifest(path.join(lockfileDir, 'node_modules'))
  const virtualStoreDir = modules?.virtualStoreDir || path.join(lockfileDir, 'node_modules/.pnpm')
  const currentLockfile = await readCurrentLockfile(virtualStoreDir, { ignoreIncompatible: false })
  const wantedLockfile = await readWantedLockfile(lockfileDir, { ignoreIncompatible: false }) || currentLockfile
  if (!wantedLockfile) {
    throw new PnpmError('OUTDATED_NO_LOCKFILE', 'No lockfile in this directory. Run `pnpm install` to generate one.')
  }
  const storeDir = await storePath(opts.dir, opts.store)
  const getLatestManifest = createLatestManifestGetter({
    ...opts,
    lockfileDir,
    storeDir,
  })
  return Promise.all(pkgs.map(async ({ dir, manifest }) => {
    let match = args.length && matcher(args) || undefined
    return {
      manifest,

@pnpm/modules-yaml

Reads/writes `node_modules/.modules.yaml`

MIT
Latest version published 23 days ago

Package Health Score

66 / 100
Full package analysis

Popular @pnpm/modules-yaml functions