0.8.4 • Published 2 months ago

upkeeper v0.8.4

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

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.

LevelDescription
proposalProduces a patch for each proposal: resource + dep name + dep version
sameGenerates script for each common proposal: dep name + dep version. Useful for monorepos.
resourceJoins changes for each resource entry
all-inA 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 $'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/antongolub/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 $'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
# ...
OptionDescriptionDefault
--cwdWorking directoryprocess.cwd()
--configPath to config file
--combineJoin all patches into one scriptfalse
--diffDiff-patch provider: git or sedgit
--dryrunDo not apply changes.true if --ouput option is set
--granularityGranularity levelproposal
--outputOutput directory

Refs

Updaters

Bots

Patchgen

License

MIT

0.8.4

2 months ago

0.8.3

5 months ago

0.8.1

5 months ago

0.8.0

5 months ago

0.8.2

5 months ago

0.7.1

5 months ago

0.5.0

5 months ago

0.4.1

5 months ago

0.4.0

5 months ago

0.7.0

5 months ago

0.6.0

5 months ago

0.3.0

6 months ago

0.2.0

6 months ago

0.1.1

6 months ago

0.1.0

6 months ago

0.0.1

6 months ago

0.0.0

6 months ago