upkeeper
v0.8.4
Published
Script generator for deps updating
Downloads
4
Readme
upkeeper
Script generator for deps updating
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
sed
optionalnodejs
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 $'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
# ...
| 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
- is-it-possible-to-git-diff-2-strings
- is-it-possible-to-git-diff-a-file-against-standard-input
- is-git-diff-related-to-diff
- cant-pipe-into-diff
- string-difference-in-bash
- git-add-patch-with-word-diff
- git-apply-error-while-searching-for-can-i-use-a-patch-to-delete-a-patch