decaffeinate.sh 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. #!/usr/bin/env zsh
  2. set -ex
  3. echo "----------------------------------------"
  4. echo "-------GIT CLEANING UNUSED FILES--------"
  5. echo "----------------------------------------"
  6. git clean -fd
  7. echo "----------------------------------------"
  8. echo "--------------ENTRY FILE----------------"
  9. echo "----------------------------------------"
  10. npx bulk-decaffeinate convert --file app.coffee
  11. for entryPoint in modules/**/index.coffee; do
  12. npx bulk-decaffeinate convert --file $entryPoint
  13. done
  14. npx bulk-decaffeinate clean
  15. npx prettier-eslint 'app.js' --write
  16. for entryPoint in modules/**/index.js; do
  17. npx prettier-eslint "$entryPoint" --write
  18. done
  19. git add .
  20. git commit -m "Prettier: convert app.js & index.js decaffeinated files to Prettier format"
  21. echo "----------------------------------------"
  22. echo "------------GRUNTFILE FILE--------------"
  23. echo "----------------------------------------"
  24. npx bulk-decaffeinate convert --file Gruntfile.coffee
  25. npx bulk-decaffeinate clean
  26. npx prettier-eslint 'Gruntfile.js' --write
  27. git add .
  28. git commit -m "Prettier: convert Gruntfile.coffee decaffeinated files to Prettier format"
  29. echo "----------------------------------------"
  30. echo "------------------APP-------------------"
  31. echo "----------------------------------------"
  32. npx bulk-decaffeinate convert --dir app/coffee
  33. for module in modules/**/app/coffee; do
  34. npx bulk-decaffeinate convert --dir $module
  35. done
  36. npx bulk-decaffeinate clean
  37. git mv app/coffee app/src
  38. for module in modules/**/app; do
  39. if [ -e $module/coffee ]; then
  40. git mv $module/coffee $module/src
  41. fi
  42. done
  43. git commit -m "Rename app/coffee dir to app/src"
  44. npx prettier-eslint 'app/src/**/*.js' --write
  45. for module in modules/**/app/src; do
  46. npx prettier-eslint "$module/**/*.js" --write
  47. done
  48. git add .
  49. git commit -m "Prettier: convert app/src decaffeinated files to Prettier format"
  50. echo "----------------------------------------"
  51. echo "--------------UNIT TESTS----------------"
  52. echo "----------------------------------------"
  53. npx bulk-decaffeinate convert --dir test/unit/coffee
  54. for module in modules/**/test/unit/coffee; do
  55. npx bulk-decaffeinate convert --dir $module
  56. done
  57. npx bulk-decaffeinate clean
  58. git mv test/unit/coffee test/unit/src
  59. for module in modules/**/test/unit; do
  60. if [ -e $module/coffee ]; then
  61. git mv $module/coffee $module/src
  62. fi
  63. done
  64. git commit -m "Rename test/unit/coffee to test/unit/src"
  65. npx prettier-eslint 'test/unit/src/**/*.js' --write
  66. for module in modules/**/test/unit/src; do
  67. npx prettier-eslint "$module/**/*.js" --write
  68. done
  69. git add .
  70. git commit -m "Prettier: convert test/unit decaffeinated files to Prettier format"
  71. echo "----------------------------------------"
  72. echo "-----------ACCEPTANCE TESTS-------------"
  73. echo "----------------------------------------"
  74. npx bulk-decaffeinate convert --dir test/acceptance/coffee
  75. for module in modules/**/test/acceptance/coffee; do
  76. npx bulk-decaffeinate convert --dir $module
  77. done
  78. npx bulk-decaffeinate clean
  79. git mv test/acceptance/coffee test/acceptance/src
  80. for module in modules/**/test/acceptance; do
  81. if [ -e $module/coffee ]; then
  82. git mv $module/coffee $module/src
  83. fi
  84. done
  85. git commit -m "Rename test/acceptance/coffee to test/acceptance/src"
  86. npx prettier-eslint 'test/acceptance/src/**/*.js' --write
  87. for module in modules/**/test/acceptance/src; do
  88. npx prettier-eslint "$module/**/*.js" --write
  89. done
  90. git add .
  91. git commit -m "Prettier: convert test/acceptance decaffeinated files to Prettier format"
  92. echo "----------------------------------------"
  93. echo "-------------SMOKE TESTS----------------"
  94. echo "----------------------------------------"
  95. npx bulk-decaffeinate convert --dir test/smoke/coffee
  96. npx bulk-decaffeinate clean
  97. git mv test/smoke/coffee test/smoke/src
  98. git commit -m "Rename test/smoke/coffee to test/smoke/src"
  99. npx prettier-eslint 'test/smoke/src/**/*.js' --write
  100. git add .
  101. git commit -m "Prettier: convert test/smoke decaffeinated files to Prettier format"
  102. echo "----------------------------------------"
  103. echo "-----------FIX REQUIRE PATHS------------"
  104. echo "----------------------------------------"
  105. perl -i.bak -pe "s/([\'\"\`].*)\/app\/js(.*[\'\"\`])/\1\/app\/src\2/g" app.js
  106. rm app.js.bak
  107. perl -i.bak -pe "s/([\'\"\`].*)\/app\/js(.*[\'\"\`])/\1\/app\/src\2/g" Gruntfile.js
  108. rm Gruntfile.js.bak
  109. perl -i.bak -pe "s/([\'\"\`].*)\/app\/js(.*[\'\"\`])/\1\/app\/src\2/g" modules/**/index.js
  110. rm modules/**/index.js.bak
  111. perl -i.bak -pe "s/([\'\"\`].*)\/app\/js(.*[\'\"\`])/\1\/app\/src\2/g" **/src/**/*.js
  112. rm **/src/**/*.js.bak
  113. perl -i.bak -pe "s/([\'\"\`].*)\/test\/acceptance\/js(.*[\'\"\`])/\1\/test\/acceptance\/src\2/g" **/src/**/*.js
  114. rm **/src/**/*.js.bak
  115. perl -i.bak -pe "s/([\'\"\`].*)test\/smoke\/js(.*[\'\"\`])/\1test\/smoke\/src\2/g" **/src/**/*.js
  116. rm **/src/**/*.js.bak
  117. # Fix formatting after rewriting paths - extra character can make a difference
  118. make format_fix
  119. git add .
  120. git commit -m "Fix require paths in modules after decaffeination" || true
  121. echo "done"