Files
pnpm/pkg-manager/core
Khải 086b69cf60 feat: pnpmfileChecksum (#7662)
* Squashed commit of the following:

commit 912ee1af4d954d192d42cf4a2e6dae56d5bef21d
Author: Zoltan Kochan <z@kochan.io>
Date:   Thu Feb 22 02:22:22 2024 +0100

    revert: moving tarballs to lfs

commit f8943bdfd422c77e27febda9d962e9937c83dd55
Author: khai96_ <hvksmr1996@gmail.com>
Date:   Wed Feb 21 20:35:38 2024 +0700

    refactor: move pnpmfileChecksum to requireHooks

commit 33c90e030f49aa9edf815708f846047d7dec25ca
Merge: d6e74263d 5f4b535be
Author: khai96_ <hvksmr1996@gmail.com>
Date:   Wed Feb 21 12:06:26 2024 +0700

    chore(git): merge

commit d6e74263de8ea474b1c16cd29aac2dbdef40d102
Author: khai96_ <hvksmr1996@gmail.com>
Date:   Wed Feb 21 12:03:13 2024 +0700

    refactor: reuse code

commit 5f4b535bed589bb5eb60ddbbb61534d62e75cfae
Author: Khải <hvksmr1996@gmail.com>
Date:   Wed Feb 21 10:21:35 2024 +0700

    refactor: revert unnecessary bumps

commit ebee6c825d08888413684856c7505d4708c960af
Merge: 82233556d c8e8eca3d
Author: khai96_ <hvksmr1996@gmail.com>
Date:   Wed Feb 21 00:37:50 2024 +0700

    chore(git): merge from main

commit c8e8eca3debb0fb081a614346b9b1a5786b87a5d
Author: Zoltan Kochan <z@kochan.io>
Date:   Tue Feb 20 18:36:11 2024 +0100

    test(mount-modules): use local pnpm in pretest

commit e0488e5ac443b62df3aef9a161c757bc16c1bda3
Author: Zoltan Kochan <z@kochan.io>
Date:   Tue Feb 20 18:28:21 2024 +0100

    fix: unpacking tarballs that appear to be not USTAR or GNU TAR (#7677)

    close #7120

commit 82233556d4162d90a38e11d15136461008169acd
Author: khai96_ <hvksmr1996@gmail.com>
Date:   Tue Feb 20 20:32:47 2024 +0700

    refactor: replace remove with add

commit 30293df6bdc8cc478b9d7b81cb5d09ca48855b89
Merge: 6eb0b3e81 7cb3cfb5b
Author: khai96_ <hvksmr1996@gmail.com>
Date:   Tue Feb 20 20:31:30 2024 +0700

    chore(git): merge from main

commit 6eb0b3e81dea7ced23b4e9683d9500b4a30499a5
Merge: c1fbc11ed e4caa114a
Author: khai96_ <hvksmr1996@gmail.com>
Date:   Tue Feb 20 16:45:23 2024 +0700

    chore(git): merge from main

commit c1fbc11eded093e923644454254b98eb0090292d
Author: khai96_ <hvksmr1996@gmail.com>
Date:   Tue Feb 20 13:59:15 2024 +0700

    fix: pruneLockfile

commit 39a8e75a1cccd8c6f5df838eaf2c07f98c2652dd
Author: khai96_ <hvksmr1996@gmail.com>
Date:   Tue Feb 20 02:46:41 2024 +0700

    lint: fix

commit 839de517487561ddf3d27bb77a1cfd8e373c4274
Author: khai96_ <hvksmr1996@gmail.com>
Date:   Mon Feb 19 20:24:25 2024 +0700

    style: fix

commit 1ec2c1a40fb050221b937878decd9eeef8e9c845
Author: khai96_ <hvksmr1996@gmail.com>
Date:   Mon Feb 19 20:01:00 2024 +0700

    feat: handle absolute path

commit 002edd4484a071638b6e2f43ab9ce76f186aa379
Author: khai96_ <hvksmr1996@gmail.com>
Date:   Mon Feb 19 19:51:33 2024 +0700

    fix: use opts instead of rawConfig

commit d55b687735b598e7a2b235eaed5675eaf1982a40
Author: khai96_ <hvksmr1996@gmail.com>
Date:   Mon Feb 19 19:41:51 2024 +0700

    refactor: remove an unnecessary await

commit bb595f315b8ba422128efc1ff753222c86e93fdf
Author: khai96_ <hvksmr1996@gmail.com>
Date:   Mon Feb 19 14:08:07 2024 +0700

    feat: rawConfig.ignorePnpmfile

commit 0a17c659d303054d770e72279019b9c39e85c95d
Author: khai96_ <hvksmr1996@gmail.com>
Date:   Mon Feb 19 14:04:13 2024 +0700

    feat: read from rawConfig

commit 276379a531163ca6271fa863c27f3c779a6849a4
Author: khai96_ <hvksmr1996@gmail.com>
Date:   Mon Feb 19 13:53:34 2024 +0700

    feat: move pnpmfileChecksum to the option region

commit 3868abdbb25194ef5b279cfea63fab6294d46a8c
Author: Zoltan Kochan <z@kochan.io>
Date:   Sat Feb 17 00:09:19 2024 +0100

    test: fix

commit 95e6554089d30dcee25da144719b28e369d11f10
Author: khai96_ <hvksmr1996@gmail.com>
Date:   Fri Feb 16 23:18:11 2024 +0700

    fix: test

commit 75a131aade4caa322330f6df017abd02aee0ccd9
Author: khai96_ <hvksmr1996@gmail.com>
Date:   Fri Feb 16 23:17:45 2024 +0700

    fix: pnpmfileChecksum not appearing in the lockfile

commit 297f920b0be4671b72481709af43193522b177b3
Merge: 8ac1725a8 c7d056422
Author: khai96_ <hvksmr1996@gmail.com>
Date:   Fri Feb 16 18:12:11 2024 +0700

    chore(git): merge from main

commit 8ac1725a83b3eccfe46b2972a77f7a780aef3564
Author: khai96_ <hvksmr1996@gmail.com>
Date:   Fri Feb 16 18:01:58 2024 +0700

    feat: pnpmfileChecksum

commit 83788d023d478d4e559ebfbaaf2aba6e355358b5
Author: khai96_ <hvksmr1996@gmail.com>
Date:   Fri Feb 16 17:04:02 2024 +0700

    refactor: add explicit type

* fix: update lockfile when new pnpmfile removes deps

* fix: always calculate pnpmfileChecksum

* test: getPnpmfileChecksum

* test(cli): add or change pnpmfile

* refactor: try catch and await

* refactor: pnpmfile hash

* docs: add changesets

---------

Co-authored-by: Zoltan Kochan <z@kochan.io>
2024-02-23 19:17:38 +01:00
..
2024-02-23 19:17:38 +01:00
2024-02-17 12:57:58 +01:00
2024-01-27 16:48:08 +01:00
2024-02-12 22:46:58 +01:00

@pnpm/core

Fast, disk space efficient installation engine. Used by pnpm

Install

Install it via npm.

pnpm add @pnpm/core

It also depends on @pnpm/logger version 1, so install it as well via:

pnpm add @pnpm/logger@1

API

mutateModules(importers, options)

TODO

link(linkFromPkgs, linkToModules, [options])

Create symbolic links from the linked packages to the target package's node_modules (and its node_modules/.bin).

Arguments:

  • linkFromPkgs - String[] - paths to the packages that should be linked.
  • linkToModules - String - path to the dependent package's node_modules directory.
  • options.reporter - Function - A function that listens for logs.

linkToGlobal(linkFrom, options)

Create a symbolic link from the specified package to the global node_modules.

Arguments:

  • linkFrom - String - path to the package that should be linked.
  • globalDir - String - path to the global directory.
  • options.reporter - Function - A function that listens for logs.

linkFromGlobal(pkgNames, linkTo, options)

Create symbolic links from the global pkgNames to the linkTo/node_modules folder.

Arguments:

  • pkgNames - String[] - packages to link.
  • linkTo - String - package to link to.
  • globalDir - String - path to the global directory.
  • options.reporter - Function - A function that listens for logs.

storeStatus([options])

Return the list of modified dependencies.

Arguments:

  • options.reporter - Function - A function that listens for logs.

Returns: Promise<string[]> - the paths to the modified packages of the current project. The paths contain the location of packages in the store, not in the projects node_modules folder.

storePrune([options])

Remove unreferenced packages from the store.

Hooks

Hooks are functions that can step into the installation process.

readPackage(pkg: Manifest): Manifest | Promise<Manifest>

This hook is called with every dependency's manifest information. The modified manifest returned by this hook is then used by @pnpm/core during installation. An async function is supported.

Example:

const { installPkgs } = require('@pnpm/core')

installPkgs({
  hooks: {readPackage}
})

function readPackage (pkg) {
  if (pkg.name === 'foo') {
    pkg.dependencies = {
      bar: '^2.0.0',
    }
  }
  return pkg
}

afterAllResolved(lockfile: Lockfile): Lockfile | Promise<Lockfile>

This hook is called after all dependencies are resolved. It receives and returns the resolved lockfile object. An async function is supported.

License

MIT