将yarn.lock同步回package.json并锁定 [英] sync yarn.lock back into package.json and lock

查看:719
本文介绍了将yarn.lock同步回package.json并锁定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有package.jsonyarn.lock文件. yarn.lock的版本已锁定,我想进行同步,然后将yarn.lock中的所有版本锁定(不带^),重新打包到package.json中. 有没有简单的方法可以做到这一点?

最后,我不想在我的package.json中完全没有"^",因为这会带来太多麻烦,并且我想专门升级软件包,而不是不知不觉地升级软件包. /p>

是否有任何工具或方法可以用yarn.lock内部存在的版本快速替换package.json中的版本?

解决方案

我最终自己做了一件事情:

sync-yarnlock-into-packagejson

它是一个微型实用程序,可以将现有package.json与yarn.lock同步.

syncyarnlock

yarn.lock版本同步到现有的package.json文件中,删除诸如^之类的动态数字,保持静态版本不变.

安装

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   

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.

syncyarnlock

Syncs yarn.lock versions into an exsisting package.json file, removing dynamic numbers such as with ^, keeping static versions intact.

Install

YARN

yarn global add syncyarnlock

or

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   

这篇关于将yarn.lock同步回package.json并锁定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆