@ianwremmel/pkgshift v1.1.1
@ianwremmel/pkgshift
Inspired by jscodeshift to help keep package.json consistent
Install
npm install @ianwremmel/pkgshiftor
npm install @ianwremmel/pkgshiftUsage
For the most up to date docs, run pkgshift --help.
run
`pkgshift run ./package.json -t ./tranform.js
pkgshift's only command, run, applies a transform file to a package.json.
A transform file is of the form
module.exports = function transform(pkg, {api}) {
return Object.assign(pkg);
};where transform implements the transformCallback and api is a reference to the TransformAPI.
API
TransformAPI
Helper methods passed to your transform function
Type: Object
setOrReplaceScript
Sets a script, or, if that script already exists, transforms it into the new script
Parameters
pkgPackageoptionsObjectoptions.from(string | RegExp) The original script definition. Must be an exact match, but if a RegExp is supplied, the substring matches will be available totooptions.namestring The name in pkg.scriptsoptions.tostring The final script definition. Iffromis a RegExp,tomay include substring references.
Package
The Object defined by a package.json
Type: Object
pkgShift
Asynchronously apply the specified transform to the specified package.
Parameters
txtransformCallbackpkgPackage
transformCallback
Type: Function
Parameters
pkgPackageoptionsObjectoptions.apiTransformAPI
Returns (Package | Promise<Package>)
apply
Asynchronously apply the specified transform to the specified package.
Parameters
txtransformCallbackpkgPackage
Meta
- deprecated: Please use pkgShift()
cli
Main command line entry point
Parameters
optionsPkgShiftOptions (optional, default{})
PkgShiftOptions
Type: Object
Properties
pathstring File to transformtransformstring Path to the transform file.verbosenumber Show more information about the transform processdryboolean Dry run (no changes are made to files)printboolean Print output, useful for developmentsilentboolean No output
pkgshift
Parameters
optionsPkgShiftOptions
Meta
- deprecated: please use cli Main command line entry point
Maintainers
Contribute
See CONTRIBUTE
License
© MIT