https://github.com/imcuttle/pkgxo
Lets you can update package.json when publish
https://github.com/imcuttle/pkgxo
Last synced: over 1 year ago
JSON representation
Lets you can update package.json when publish
- Host: GitHub
- URL: https://github.com/imcuttle/pkgxo
- Owner: imcuttle
- License: mit
- Created: 2022-01-08T12:17:02.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-01-08T13:01:01.000Z (over 4 years ago)
- Last Synced: 2025-03-18T11:57:57.811Z (over 1 year ago)
- Language: JavaScript
- Size: 61.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: License
Awesome Lists containing this project
README
# pkgxo
[](https://github.com/imcuttle/pkgxo/actions)
[](https://codecov.io/github/imcuttle/pkgxo?branch=master)
[](https://www.npmjs.com/package/pkgxo)
[](https://www.npmjs.com/package/pkgxo)
[](https://prettier.io/)
[](https://conventionalcommits.org)
> lets you can update package.json when publish
## Installation
```bash
pnpm add pkgxo -D
```
## Usage
```json
{
"main": "index.ts",
"publishConfig": {
"main": "index.js"
},
"scripts": {
"prepublishOnly": "pkgxo --submit",
"postpublish": "pkgxo --reset"
}
}
```
`pkgxo --submit` would update package.json, use [pnpm-manifest](https://pnpm.io/package_json#publishconfig) by default.
`package.json` is follow
```json
{
"main": "index.js",
"publishConfig": {
"main": "index.js"
},
"scripts": {
"prepublishOnly": "pkgxo --submit",
"postpublish": "pkgxo --reset"
}
}
```
`pkgxo --reset` would reset the latest package.json when submitted.
`package.json` is follow
```json
{
"main": "index.ts",
"publishConfig": {
"main": "index.js"
},
"scripts": {
"prepublishOnly": "pkgxo --submit",
"postpublish": "pkgxo --reset"
}
}
```
## Advanced
### Custom updater
You could use `pkgxo.js` in CWD for overwriting.
```javascript
// pkgxo.js
const pnpmManifest = require('pkgxo/pnpm-manifest')
module.exports = async function (pkg, filename) {
pkg = await pnpmManifest(pkg, filename)
pkg.description = `[LOGO]: ${pkg.description || ''}`
return pkg
}
```
## Contributing
- Fork it!
- Create your new branch:
`git checkout -b feature-new` or `git checkout -b fix-which-bug`
- Start your magic work now
- Make sure npm test passes
- Commit your changes:
`git commit -am 'feat: some description (close #123)'` or `git commit -am 'fix: some description (fix #123)'`
- Push to the branch: `git push`
- Submit a pull request :)
## Authors
This library is written and maintained by imcuttle, moyuyc95@gmail.com.
## License
MIT - [imcuttle](https://github.com/imcuttle) 🐟