Created
September 22, 2020 09:34
-
-
Save zealot128/ee46327404f94d0aa58ec01ffaed9c68 to your computer and use it in GitHub Desktop.
Bootstrap-vue import statement migration
This file contains 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
# I am using sd, which has a more standard Regexp syntax than find/sed and works great | |
# This script changes all occurences from: | |
# import bFormGroup from 'bootstrap-vue/es/.... | |
# import bModal from .... | |
# | |
# to -> | |
# | |
# import { BFormGroup, BModal } from 'bootstrap-vue' | |
# | |
# adjust the paths, this is a rails app, so everything is in app/javascript | |
# 1. replace all "import bForm..." -> "import { BForm } from 'bootstrap-vue'" | |
sd -f i "import [bB](.*) from .bootstrap-vue/(es|src)/.*" "import { B\$1 } from 'bootstrap-vue';" app/javascript/**/*.vue app/javascript/**/*.js | |
# 2. capitalize all usages of "bForm" (e.g. in components: {}) | |
sd " b([A-Z][a-z])" " B\$1" app/javascript/**/*.vue app/javascript/**/*.js | |
# 3. use eslint to combine all duplicate imports into one single | |
./node_modules/.bin/eslint --fix --rule 'import/no-duplicates: error' `git diff --name-only -- app` | |
# 4. Manual | |
# - check for directives import | |
# - check for "<b[A-Z]a-z]" un-capitalized html views |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment