Created
March 28, 2017 12:38
-
-
Save netmikey/cb29ac391953f2c67aa102b28fd4fe16 to your computer and use it in GitHub Desktop.
A shell command to make variables used in angular templates public
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# A macOS shell command to patch large code bases and make variables used in | |
# templates public. | |
# To be executed from the project root. It uses the error output of the | |
# angular-cli build command. angular-cli must be installed in version 1.0.0. | |
# | |
# Yes, this is awfully hacky and changes should be reviewed - but as always: | |
# this commes at best effort and without any warranties, you should use git | |
# anyway ;) | |
# | |
# For the discussion, see https://github.com/angular/angular-cli/issues/5620 | |
# | |
npm run build -- -aot 2>&1 | grep "is .* and only accessible within class" > errors.out.tmp | |
cat errors.out.tmp | grep "ng://" | sed 's@^.*ERROR in @@' | sed -E 's@ng://([^ ]+) \([0-9]+,[0-9]+\): Property '\''([^'\'']+)'\''[^'\'']+'\''([^'\'']+).*@\1 \2@' | sed -E '[email protected] @.ts @' | awk '!x[$0]++' | sed -E 's@([^ ]+) ([^ ]+)@sed -i '\'''\'' -E '\''s/(private|protected) \2([:\( ])/public \2\\2/'\'' \1@' | while read -r line; do sh -c "$line"; done | |
cat errors.out.tmp | grep "\$\$_gendir.*.ngfactory.ts " | sed 's@^.*ERROR in @@' | sed 's@\$\$_gendir/\(.*\).ngfactory@\1@' | sed -E 's@([^ ]+) \([0-9]+,[0-9]+\): Property '\''([^'\'']+)'\''[^'\'']+'\''([^'\'']+).*@\1 \2@' | awk '!x[$0]++' | sed -E 's@([^ ]+) ([^ ]+)@sed -i '\'''\'' -E '\''s/private \2([: ])/public \2\\1/'\'' \1@' | while read -r line; do sh -c "$line"; done | |
rm errors.out.tmp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You could use a modern IDE and run the fixes for this inspection.