简体   繁体   English

将yarn.lock同步回package.json并锁定

[英]sync yarn.lock back into package.json and lock

I have package.json and yarn.lock files. 我有package.jsonyarn.lock文件。 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. yarn.lock有版本锁定,我想同步,并锁定(没有^)yarn.lock中的所有版本,回到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. 最后我想在我的package.json中没有“^”,因为它会导致太多麻烦,我想特别升级包装,而不是在我运行新纱线安装时不知不觉。

is there any tool or way to quickly replace the versions in package.json with those exsisting inside yarn.lock? 是否有任何工具或方法可以快速替换package.json中的版本与yarn.lock中存在的那些版本?

I ended up making something myself: 我最终自己做了些什么:

sync-yarnlock-into-packagejson 同步yarnlock -进入- packagejson

its a tiny utility that can sync existing package.json with yarn.lock. 它是一个很小的实用程序,可以将现有的package.json与yarn.lock同步。

syncyarnlock syncyarnlock

Syncs yarn.lock versions into an exsisting package.json file, removing dynamic numbers such as with ^, keeping static versions intact. yarn.lock版本同步到yarn.lockpackage.json文件中,删除动态数字,例如^,保持静态版本不变。

Install 安装

YARN

yarn global add syncyarnlock

or 要么

NPM NPM

npm install -g syncyarnlock

Usage 用法

  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 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM