forked from zuzannast/swagger_ui_engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_assets.sh
executable file
·30 lines (24 loc) · 1.03 KB
/
update_assets.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env bash
# Usage:
# 1. npm install
# 1. ./update_assets.sh
# 1. review any changes manually, ignoring where where the engine adds configurations
DIST_PATH="node_modules/redoc/dist"
ASSETS_PATH="app/assets"
npm install
command -v beautify >/dev/null || npm install -g beautify
strip_trailing_whitespace() {
git ls-files app/assets/**/*{erb,css,html,js} | while read -r file ; do sed -i '' -e's/[[:space:]]*$//' "$file"; done
}
# node_modules/redoc/dist/
# ├── redoc.min.js
# └── redoc.min.map
# javascript
mkdir -p "${ASSETS_PATH}/javascripts/api_doc_server/"
cp "${DIST_PATH}/redoc.min.map" "${ASSETS_PATH}/javascripts/api_doc_server/"
cp "${DIST_PATH}/redoc.min.js" "${ASSETS_PATH}/javascripts/api_doc_server/redoc.min.js"
cp "${DIST_PATH}/redoc.min.js" "${ASSETS_PATH}/javascripts/api_doc_server/redoc.js"
# beautify to more easily see diff
beautify -o "${ASSETS_PATH}/javascripts/api_doc_server/redoc.js" -f js "${ASSETS_PATH}/javascripts/api_doc_server/redoc.js"
# Strip trailing whitespace
strip_trailing_whitespace