提问者:小点点

同步yarn.lockpackage.json并锁定


我有软件包。json纱线。锁定文件。纱线lock已经锁定了版本,我想同步,并锁定(没有^)所有的纱线版本。锁上,回到包裹里。json。有什么简单的方法吗?

最后,我希望我的包中没有“^”。json会导致太多的麻烦,我希望在运行新的安装程序时,能够具体地升级包,而不是不知不觉地升级包。

是否有任何工具或方法可以快速替换软件包中的版本。与那些存在于纱线内部的纤维结合。锁


共1个答案

匿名用户

最后我自己做了一些东西:

同步锁到包

这是一个可以同步现有软件包的小型实用程序。用纱线编织。锁

同步纱线。将版本锁定到现有的包中。json文件,删除动态数字,如^,保持静态版本不变。

纱线全局添加syncyarnlock

npm安装-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