@heroor/tpm
v0.1.0
Published
TPM is a typings package manager for npm, pnpm, yarn and bun projects
Readme
TPM
TPM is a command line tool for installing and removing TypeScript @types/* packages with the package manager used by the current project.
Features
- Supports
npm,pnpm,yarn, andbun - Prefers the
packageManagerfield inpackage.json - Falls back to lockfile detection when
packageManageris not set - Searches upward from the current directory, which works well in monorepo subdirectories
- Prompts for a package manager when multiple lockfiles are found in an interactive terminal
- Converts scoped packages such as
@babel/coreto@types/babel__core - Keeps existing
@types/*package names unchanged
Installation
npm install -g @heroor/tpmYou can also install it globally with your preferred package manager:
pnpm add -g @heroor/tpm
yarn global add @heroor/tpm
bun install --global @heroor/tpmUsage
Install typings:
tpm node react
# npm install --save-dev @types/node @types/react
# pnpm add --save-dev @types/node @types/react
# yarn add --dev @types/node @types/react
# bun add --dev @types/node @types/reactInstall typings for scoped packages:
tpm @babel/core
# @babel/core becomes @types/babel__coreRemove typings:
tpm - node react
tpm remove node reactPreview the command without running it:
tpm --dry-run node reactPackage Manager Detection
TPM starts from the current working directory and walks up parent directories until it finds the nearest package.json or supported lockfile.
Detection priority:
- If
package.jsonhas apackageManagerfield, TPM uses that manager. - If lockfiles point to exactly one package manager, TPM uses that manager.
- If lockfiles point to multiple package managers in an interactive terminal, TPM prompts you to choose one.
- If no project signal is found, TPM defaults to
npm.
Supported lockfiles:
| Package manager | Lockfile |
| --------------- | ------------------------ |
| npm | package-lock.json |
| pnpm | pnpm-lock.yaml |
| yarn | yarn.lock |
| bun | bun.lock, bun.lockb |
For stable CI and script usage, declare the package manager in package.json:
{
"packageManager": "[email protected]"
}Development
pnpm install
pnpm test
pnpm run typecheck
pnpm run buildSource files live in src/, tests live in test/, and build output is written to dist/. The prepack script runs the build before publishing.
License
MIT
