-
-
Save netmikey/cb29ac391953f2c67aa102b28fd4fe16 to your computer and use it in GitHub Desktop.
# | |
# 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 |
kblestarge
commented
Apr 26, 2017
@kblestarge sorry for not responding in so long, somehow I didn't get notified about the activity in this gist...
Could you try maybe copy/pasting the 3 lines one by one into the terminal? Maybe you'll see more output or some hint that way...
I'm using Angular-CLI 1.3.1. Replacing the first line with:
ng build --prod 2>&1 | grep -E "is .* and only accessible within class" | tee errors.out.tmp
(tee just so I can see when it finishes) worked for me.
Many thanks! This version worked on Windows in git bash, and I added a bit to handle readonly properties.
ng build --prod 2>&1 | grep -E "is .* and only accessible within class" | sed 's/ng:///C://ng:///c//g' | tee 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)( readonly)? \2([:( ])/public\2 \2\3/''' \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
You could use a modern IDE and run the fixes for this inspection.