-
Notifications
You must be signed in to change notification settings - Fork 56
Try to automate some of the translation updates #87
base: master
Are you sure you want to change the base?
Conversation
| head -1 \ | ||
| awk -F: '{ print $2 }' \ | ||
| sed 's/[ ",^]//g') | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is jq
available..? I mean, you've written this now, so maybe it doesn't matter :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively, you could use npx project-version
to get the version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, okay - so found out I can do jq '.dependencies."cp-translations"'
and .dependencies."cp-translations" = "$TRANSLATIONS_VERSION"
- will check that out, but means adding package.json here.
|
||
function log() { | ||
if [[ -n $1 ]];then | ||
printf "\033[0;36m\n$1\n\033[0m" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might be able to use tput
to set the colours:
# Text color variables
txtund=$(tput sgr 0 1) # Underline
txtbld=$(tput bold) # Bold
txtred=$(tput setaf 1) # Red
txtgrn=$(tput setaf 2) # Green
txtylw=$(tput setaf 3) # Yellow
txtblu=$(tput setaf 4) # Blue
txtpur=$(tput setaf 5) # Purple
txtcyn=$(tput setaf 6) # Cyan
txtwht=$(tput setaf 7) # White
txtrst=$(tput sgr0) # Text reset
(from SO)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting...
@@ -0,0 +1,81 @@ | |||
#! /usr/bin/env bash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like to use -eu
to catch commands exiting non-zero, and undefined variables.
escaped_lhs=$(printf '%s\n' "\"cp-translations\": \"^$PACKAGE_VERSION\"" | sed 's:[][\\/.^$*]:\\&:g') | ||
escaped_rhs=$(printf '%s\n' "\"cp-translations\": \"^$TRANSLATIONS_VERSION\"" | sed 's:[\\/&]:\\&:g;$!s/$/\\/') | ||
|
||
sed -i '' -e "s/$escaped_lhs/$escaped_rhs/g" package.json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yarn.lock
also needs to be updated. I think this will result in either failures when running yarn install
or it will just install the old version. I don't think there's any reason why you couldn't just run yarn add cp-translations@$TRANSLATIONS_VERSION
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there's a possibility of running the update inside the Docker container, but outside would result in potential mismatches in yarn.lock to do with the platform right? Maybe will check / investigate, ta.
git commit -m "Update cp-translations to $TRANSLATIONS_VERSION" | ||
git push -u origin $BRANCH | ||
git checkout master | ||
# git push origin --delete $BRANCH |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should probably remove these commented out lines
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Yeah, was in there for testing :) ]
Daniel B mentioned some other possible automations that may help - this can sit and wait maybe as it's not urgent. |
Quick and dirty bash script to update the translations package for the dependent repos (not zen-platform).
Can probably be improved, so here as a draft PR
Context in here: https://github.com/CoderDojo/cp-translations/blob/master/README.md