Skip to content

Instantly share code, notes, and snippets.

@imaizume
Last active May 18, 2020 14:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imaizume/dd6ae5af3015c2a31540a3046171ae05 to your computer and use it in GitHub Desktop.
Save imaizume/dd6ae5af3015c2a31540a3046171ae05 to your computer and use it in GitHub Desktop.
A simple awk script which parse output from "pod outdated" and format into markdown table so that you can easily have a grasp of update availability for libraries you use.

How To Use

Use temporary markdown file...

bundle exec pod outdated | awk -f ./pod_updatable_info.awk > pod_updatable_info.md

and output seems like this.

Library Current Podfile Latest Global Latest pod update Podfile Specification
Alamofire 4.9.1 4.9.1 5.2.0 Need for Major Update
AMPopTip 4.0.1 4.0.1 4.5.0 Need for Minor Update
AWSCore 2.13.0 2.13.0 2.13.3 Need for Patch Update
Realm 4.4.0 4.4.1 10.0.0-alpha.4 Available for Patch Update
SwiftFormat 0.40.12 (unused) 0.44.10
...

Use pbcopy to directly send content to your clipboard...

bundle exec pod outdated | awk -f ./pod_updatable_info.awk | pbcopy
#
# pod_updatable_info.awk
#
# Created by Tomohiro Imaizumi on 5/18/20.
# Copyright © 2017 Tomohiro Imaizumi. Licensed under MIT.
#
BEGIN {
print "| Library | Current | Podfile Latest | Global Latest | `pod update` | Podfile Specification |"
print "|:---:|:---:|:---:|:---:|:---:|:---:|"
}
{
if(NF>=5 && $5!="" && $1=="-") {
gsub(/\)/, "", $8);
name=$2;
current=$3;
podLatest=$5;
latest=$8;
split(current,currentVersion,/\./);
split(podLatest,podLatestVersion,/\./);
split(latest,latestVersion,/\./);
# DON'T update to neither alpha nor beta version.
match(latest, /(alpha|beta)/)
canUpdatePodSpecification="";
canUpdateLocalPod="";
if(podLatest!=latest && podLatest!="(unused)" && RLENGTH<0) {
# Check if Podfile specification update is neccesary.
if(podLatestVersion[1]!=latestVersion[1]) {
canUpdatePodSpecification=canUpdatePodSpecification"Need for Major Update";
} else if(podLatestVersion[2]!=latestVersion[2]) {
canUpdatePodSpecification=canUpdatePodSpecification"Need for Minor Update";
} else if(podLatestVersion[3]!=latestVersion[3]) {
canUpdatePodSpecification=canUpdatePodSpecification"Need for Patch Update";
} else {
# Print nothing.
}
}
if(current!=podLatest && podLatest!="(unused)") {
# Check if running `pod update` is available.
if(currentVersion[1]!=podLatestVersion[1]) {
canUpdateLocalPod=canUpdateLocalPod"Available for Major Update";
} else if(currentVersion[2]!=podLatestVersion[2]) {
canUpdateLocalPod=canUpdateLocalPod"Available for Minor Update";
} else if(currentVersion[3]!=podLatestVersion[3]) {
canUpdateLocalPod=canUpdateLocalPod"Available for Patch Update";
} else {
# Print nothing.
}
}
printf("| %s | %s | %s | %s | %s | %s |\n", name, current, podLatest, latest, canUpdateLocalPod, canUpdatePodSpecification);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment