npm.io
0.8.8 • Published 3 weeks agoCLI

upkeeper

Licence
MIT
Version
0.8.8
Deps
4
Size
52 kB
Vulns
0
Weekly
0
Stars
6

upkeeper

Script generator for deps updating

lcov npm

Status

PoC

Idea

To implement deps updating in form of git patches. As a part of Hackathon We Make QIWI 2.0 2023.

Requirements

  • git
  • echo
  • sedoptional
  • nodejs for generation phase only

Install

npm i upkeeper

Usage

import {upkeeper} from 'upkeeper'

const config = {
  granularity:  'proposal', // Granularity level: 'proposal' | 'same' | 'resource' | 'all-in'
  keepers: [
    ['npm', {
      resources:  'package.json', // package.json,packages/*/package.json
      scopes:     ['dependencies', 'devDependencies'],
      exlude:     'react',
    }]
  ],
  dryrun:   true,       // Do not apply changes
  combine:  false,      // Join all patches into one script
  diff:     'sed',      // Diff-patch provider: git or sed
  output:   'patches',  // a directory to store patches
  pre:      '',         // a scripts to run before & after each patch
  post:     'yarn install && git add . && git commit -m "chore(deps): update deps" && git push origin HEAD:refs/heads/up-deps'
}

const {scripts, proposals} = await upkeeper(config)
granularity

Choose a scripts aggregation strategy to produce appropriate patches. Default is proposal.

Level Description
proposal Produces a patch for each proposal: resource + dep name + dep version
same Generates script for each common proposal: dep name + dep version. Useful for monorepos.
resource Joins changes for each resource entry
all-in A single patch for all deps in all resources
dot

dot is used as a template engine for pre and post options, so you can inject proposal metadata into your scripts.

{
   pre: 'echo "updated {{=it.data.name}} to {{=it.data.version}}"'
}
// 'echo "updated @emotion/css to ^11.2.0"

CLI

npx upkeeper --config=config.json --output='patches'
sh patches/upkeeper.sh
Output
#!/usr/bin/env bash
set -e

echo pre
echo 
Option Description Default
--cwd Working directory process.cwd()
--config Path to config file
--combine Join all patches into one script false
--diff Diff-patch provider: git or sed git
--dryrun Do not apply changes. true if --ouput option is set
--granularity Granularity level proposal
--output Output directory

Refs

Updaters
Bots
Patchgen

License

MIT

diff --git a/packages/blank/package.json b/packages/blank/package.json\n--- a/packages/blank/package.json\n+++ b/packages/blank/package.json\n@@ -46,6 +46,6 @@\n "homepage": "https://github.com/idleware/misc#readme",\n "devDependencies": {\n "@antongolub/infra": "workspace:*",\n- "@types/node": "^20.10.3"\n+ "@types/node": "^20.10.4"\n }\n }\n' | git apply --whitespace=fix --inaccurate-eof echo post echo pre echo
Option Description Default
__INLINE_CODE_11__ Working directory __INLINE_CODE_12__
__INLINE_CODE_13__ Path to config file
__INLINE_CODE_14__ Join all patches into one script __INLINE_CODE_15__
__INLINE_CODE_16__ Diff-patch provider: __INLINE_CODE_17__ or __INLINE_CODE_18__ __INLINE_CODE_19__
__INLINE_CODE_20__ Do not apply changes. __INLINE_CODE_21__ if __INLINE_CODE_22__ option is set
__INLINE_CODE_23__ Granularity level __INLINE_CODE_24__
__INLINE_CODE_25__ Output directory

Refs

Updaters
Bots
Patchgen

License

MIT

diff --git a/packages/infra/package.json b/packages/infra/package.json\n--- a/packages/infra/package.json\n+++ b/packages/infra/package.json\n@@ -23,7 +23,7 @@\n "@semrel-extra/topo": "^1.14.0",\n "c8": "^8.0.1",\n "concurrently": "^8.2.2",\n- "esbuild": "^0.19.8",\n+ "esbuild": "^0.19.9",\n "esbuild-node-externals": "^1.11.0",\n "eslint": "^8.55.0",\n "eslint-config-qiwi": "^2.1.3",\n' | git apply --whitespace=fix --inaccurate-eof echo post # ...
Option Description Default
__INLINE_CODE_11__ Working directory __INLINE_CODE_12__
__INLINE_CODE_13__ Path to config file
__INLINE_CODE_14__ Join all patches into one script __INLINE_CODE_15__
__INLINE_CODE_16__ Diff-patch provider: __INLINE_CODE_17__ or __INLINE_CODE_18__ __INLINE_CODE_19__
__INLINE_CODE_20__ Do not apply changes. __INLINE_CODE_21__ if __INLINE_CODE_22__ option is set
__INLINE_CODE_23__ Granularity level __INLINE_CODE_24__
__INLINE_CODE_25__ Output directory

Refs

Updaters
Bots
Patchgen

License

MIT

Keywords