Skip to content

Commit 6685aa7

Browse files
committed
feat: create @pnpm/better-defaults config dependency
0 parents  commit 6685aa7

File tree

4 files changed

+105
-0
lines changed

4 files changed

+105
-0
lines changed

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2025 Zoltan Kochan and other contributors
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# @pnpm/better-defaults
2+
3+
> Improved defaults for pnpm
4+
5+
## What it changes
6+
7+
- Sets [enablePrePostScripts](https://pnpm.io/cli/run#enableprepostscripts) to `false`.
8+
- Sets [optimisticRepeatInstall](https://pnpm.io/settings#optimisticrepeatinstall) to `true`.
9+
- Sets [resolutionMode](https://pnpm.io/settings#resolutionmode) to `lowest-direct`.
10+
- Sets [verifyDepsBeforeRun](https://pnpm.io/settings#verifydepsbeforerun) to `install`.
11+
12+
You can extend or override these settings in your own `.pnpmfile.cjs`.
13+
14+
## Installation
15+
16+
```
17+
pnpm add --config @pnpm/better-defaults
18+
```
19+
20+
This will add `@pnpm/better-defaults` to the [configDependencies](https://pnpm.io/config-dependencies) field in your `pnpm-workspace.yaml`.
21+
22+
## Usage
23+
24+
If you don't have a [pnpmfile](https://pnpm.io/pnpmfile) in your project, then add this to `pnpm-workspace.yaml`:
25+
26+
```yaml
27+
pnpmfile: node_modules/.pnpm-config/@pnpm/better-defaults/pnpmfile.cjs
28+
```
29+
30+
If you have a `.pnpmfile.cjs` already in your project, then you can reexport the `updateConfig` hooks from `@pnpm/better-defaults`. This should be your `.pnpmfile.cjs`:
31+
32+
```js
33+
module.exports = {
34+
hooks: {
35+
...require('.pnpm-config/@pnpm/better-defaults/pnpmfile.cjs').hooks,
36+
// Other hooks in your project
37+
}
38+
}
39+
```
40+
41+
Alternatively, you may have other changes in your `updateConfig` hook:
42+
43+
```js
44+
const { updateConfig: makeBetterDefaults } = require('.pnpm-config/@pnpm/better-defaults/pnpmfile.cjs').hooks
45+
46+
module.exports = {
47+
hooks: {
48+
updateConfig (config) {
49+
return {
50+
...makeBetterDefaults(config),
51+
hoistPattern: ['*'],
52+
}
53+
}
54+
}
55+
}
56+
```
57+
58+
## License
59+
60+
MIT

package.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "@pnpm/better-defaults",
3+
"version": "0.1.0",
4+
"description": "Improved defaults for pnpm",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"keywords": [],
10+
"license": "MIT",
11+
"packageManager": "[email protected]"
12+
}

pnpmfile.cjs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module.exports = {
2+
hooks: {
3+
updateConfig (config) {
4+
return Object.assign(config, {
5+
enablePrePostScripts: false,
6+
optimisticRepeatInstall: true,
7+
resolutionMode: 'lowest-direct',
8+
verifyDepsBeforeRun: 'install',
9+
})
10+
}
11+
}
12+
}

0 commit comments

Comments
 (0)