2.0.0 • Published 2 years ago
packages-update v2.0.0
Why
Allows you to update, customize according to your needs and easily automate mono repositories.
I plan to expand this project into an GitHub Actions project in the future. You can see a prototype here.
Some features
- CLI and API (in-code) usage
- Custom rules per dependency
- Global and custom rules per dependency for mono repositories
- Filter and exclude dependencies
- Zero configurations (unless you want to)
- Custom
package.jsonand configuration files - Dynamic update according to version operator prefixer per dependency
And much more.
Table of Contents
Install
npm i -D packages-updateUsage
CLI
npx puYou can use
latest,minor,patchormajoras the last CLI parameter.
API (in-code)
import { pu } from 'packages-update';
await pu();You can also use all available options:
await pu({
target: 'latest',
});Aliases
npx punpx packages-updateConfigs
You can customize the global settings by creating a .purc.json config file.
- CLI and API (in-code) options will overwrite the global options.
| Option | CLI | Description | Default Value |
|---|---|---|---|
| packageFile | --package-file | Relative path to package.json file | "./package.json" |
| followPrefix | --follow-prefix | Update dependencies respecting version prefixes | false |
| target | --target | Type of update strategy (e.g., latest, major, minor and patch) | "latest" |
| filter | --filter | Filter the specified dependencies to include in the update | [] |
| exclude | --exclude | Exclude the specified dependencies to exclude from the update | [] |
| peer | --peer | Update peer dependencies | false |
| indentation | --indentation | JSON indentation level | 2 |
| registry | --registry | Specify the registry URL | "registry.npmjs.org" |
| quiet | --quiet | Suppress output messages | false |
| checkOnly | --check-only | Perform checks without applying updates | false |
| configFile | --config-file | Custom config path | "./.purc.json" |
| overrides | Override update strategy for specific packages |
packageFile
CLI
npx pu --package-file="./custom/package.json".purc.json and API (in-code)
{
"packageFile": "./custom/package.json"
}followPrefix
CLI
npx pu --follow-prefix.purc.json and API (in-code)
{
"followPrefix": true
}filter
CLI
npx pu --filter=react,vue.purc.json and API (in-code)
{
"filter": ["react", "vue"]
}exclude
CLI
npx pu --exclude=react,vue.purc.json and API (in-code)
{
"exclude": ["react", "vue"]
}peer
CLI
npx pu --peer.purc.json and API (in-code)
{
"peer": true
}indentation
CLI
npx pu --indentation=4.purc.json and API (in-code)
{
"indentation": 4
}registry
httpsonly.
CLI
npx pu --registry="registry.custom.org".purc.json and API (in-code)
{
"registry": "registry.custom.org"
}quiet
CLI
npx pu --quiet.purc.json and API (in-code)
{
"quiet": true
}checkOnly
CLI
npx pu --check-only.purc.json and API (in-code)
{
"checkOnly": true
}configFile
Not available in the configuration file itself.
CLI
npx pu --config-file=./custom/.purc.jsonAPI (in-code)
await pu({
configFile: './custom/.purc.json';
})overrides
Not available for CLI.
.purc.json and API (in-code)
{
"overrides": {
"eslint": {
"target": "minor"
},
"custom-package": {
"registry": "custom.registry.org"
}
}
}Examples
Update to latest version
Get the default latest version for each package.
npx pu
npx pu latest
npx pu --target=latest # alt.# prettier: ^1.4.2 ➜ ^2.8.1 # ...
Update to latest minor version
Get the latest minor version for each package.
npx pu minor
npx pu --target=minor # alt.# prettier: ^1.4.2 ➜ ^1.19.1 # ...
Update to latest patch version
Get the latest patch version for each package.
npx pu patch
npx pu --target=patch # alt.# prettier: ^1.4.2 ➜ ^1.4.4 # ...
Update to greatest version
Get the highest version for each package, even if it is not the default latest.
npx pu major
npx pu --target=major # alt.# prettier: ^1.4.2 ➜ ^2.8.1
# ...Limitations
- After updating package.json, run
npm i,yarn install,pnpm installorbun installto install new versions. - This updater looks the package.json for
devDependencies,dependenciesand (if configured)peerDependencies. - This updater doesn't search or update for tag and local versions (alpha, beta, rc, etc.).