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

时间:2017-10-24 07:23:38

标签: node.js npm package.json yarnpkg

我有r.db('test') .table('entity') .concatMap(row => { // your local stuff here that is executed before the query is sent to the server and executed // note that this function must return a ReQL expression return row.getField('listField'); }) .distinct(); package.json个文件。 yarn.lock有版本锁定,我想同步,并锁定(没有^)yarn.lock中的所有版本,回到package.json。 有没有简单的方法呢?

最后我想在我的package.json中没有“^”,因为它会导致太多的麻烦,我想特别升级包装,而不是在我运行新纱线安装时不知不觉。 / p>

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

1 个答案:

答案 0 :(得分:6)

我最终自己制作了一些东西:

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