Skip to content

Instantly share code, notes, and snippets.

@zealot128
Created September 22, 2020 09:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zealot128/ee46327404f94d0aa58ec01ffaed9c68 to your computer and use it in GitHub Desktop.
Save zealot128/ee46327404f94d0aa58ec01ffaed9c68 to your computer and use it in GitHub Desktop.
Bootstrap-vue import statement migration
# 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