go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/web/third_party/bootstrap/update.sh (about)

     1  #!/bin/bash
     2  
     3  set -e
     4  
     5  for VERSION in "5.1.3"
     6  do
     7    MAJOR=$(echo ${VERSION} | cut -d "." -f 1)
     8  
     9    curl "https://github.com/twbs/bootstrap/releases/download/v${VERSION}/bootstrap-${VERSION}-dist.zip" -L -o bootstrap.zip
    10    rm -rf _staging
    11    mkdir _staging
    12    unzip bootstrap.zip -d _staging
    13  
    14    SRC_DIR="_staging/bootstrap-${VERSION}-dist"
    15    DST_DIR="v${MAJOR}"
    16  
    17    # Copy only stuff we need.
    18    rm -rf ${DST_DIR}
    19    mkdir -p ${DST_DIR}/css
    20    cp ${SRC_DIR}/css/bootstrap.min.css ${DST_DIR}/css
    21    cp ${SRC_DIR}/css/bootstrap.min.css.map ${DST_DIR}/css
    22    mkdir -p ${DST_DIR}/js
    23    cp ${SRC_DIR}/js/bootstrap.bundle.min.js ${DST_DIR}/js
    24    cp ${SRC_DIR}/js/bootstrap.bundle.min.js.map ${DST_DIR}/js
    25    echo ${VERSION} >> ${DST_DIR}/VERSION
    26  
    27    # Expose fs.FS that contains bootstrap js and css.
    28    cat > ${DST_DIR}/embed.go << EOF
    29  // Copyright 2023 The LUCI Authors.
    30  //
    31  // Licensed under the Apache License, Version 2.0 (the "License");
    32  // you may not use this file except in compliance with the License.
    33  // You may obtain a copy of the License at
    34  //
    35  //      http://www.apache.org/licenses/LICENSE-2.0
    36  //
    37  // Unless required by applicable law or agreed to in writing, software
    38  // distributed under the License is distributed on an "AS IS" BASIS,
    39  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    40  // See the License for the specific language governing permissions and
    41  // limitations under the License.
    42  
    43  // Package bootstrap exposes a fs.FS variable that contains bootstrap js and css
    44  package bootstrap
    45  
    46  import "embed"
    47  
    48  // FS is a file system that contains compiled bundled bootstrap js and css code
    49  //
    50  //go:embed css js
    51  var FS embed.FS
    52  EOF
    53  
    54    # Need a LICENSE.
    55    curl "https://raw.githubusercontent.com/twbs/bootstrap/main/LICENSE" -L -o ${DST_DIR}/LICENSE
    56  
    57    # Cleanup staging files.
    58    rm -rf _staging
    59    rm bootstrap.zip
    60  done