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

pgky5nke  于 11个月前  发布在  Node.js
关注(0)|答案(1)|浏览(137)

我有package.jsonyarn.lock文件。yarn.lock有锁定的版本,我想同步,并锁定(没有^)yarn.lock中的所有版本,回到package.json。
有什么简单的方法吗?
最后,我不想在我的package.json中有"^",因为它会导致太多的麻烦,我想在运行新的yarn安装时专门升级包,而不是不知不觉地升级。
有没有什么工具或方法可以快速将package.json中的版本替换为yarn.lock中的版本?

ct3nt3jp

ct3nt3jp1#

最后,我自己做了一件事:
sync-yarnlock-into-packagejson
它是一个小工具,可以将现有的package.json与yarn.lock同步。

同步锁

yarn.lock版本同步到现有的package.json文件中,删除动态编号(如^),保持静态版本不变。

安装

Yarn

yarn global add syncyarnlock

NPM

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

字符串

相关问题