I have package.json
and yarn.lock
files.
yarn.lock has versions locked in, I would like to sync, and lock(without the ^) all the versions in yarn.lock, back into package.json.
is there any easy way to do that?
in the end I would like to not have "^" in my package.json at all as it leads to too many troubles, and I would like to upgrade packages specificly and not unknowingly when I run a fresh yarn install.
is there any tool or way to quickly replace the versions in package.json with those exsisting inside yarn.lock?
I ended up making something myself:
sync-yarnlock-into-packagejson
its a tiny utility that can sync existing package.json with yarn.lock.
Syncs yarn.lock
versions into an exsisting package.json
file, removing dynamic numbers such as with ^, keeping static versions intact.
yarn global add syncyarnlock
npm install -g syncyarnlock
Usage: syncyarnlock [options]
Sync `yarn.lock` package versions, into package.json
Options:
-V, --version output the version number
-d, --dir <path> directory path where the yarn.lock file is located (default to current directory)
-p, --dirPackageJson <path> directory of project with target package.json, if not set, -d will be used
-s, --save By default don't override the package.json file, make a new one instead package.json.yarn
-k, --keepUpArrow By default the ^ or any other dynamic numbers are removed and replaced with static ones.
-g, --keepGit By default direct git repositories are also replaced by the version written in yarn.
-l, --keepLink By default direct link: repositories are also replaced by the version written in yarn.
-a, --keepVariable <variable>By default everything is converted to yarn version, write a part of the type you wish not to convert, seperate by comma if more than one, to not replace git and link you would use +,link:
-h, --help output usage information
Transforms yarn.lock files to JSON
Examples:
//perform inside a directory with yarn.lock and package.json, will output package.json.yarn in the same directory.
syncyarnlock
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With