From c63e2faac7ec6bf387bf8df3b9ceb2578cecf1c9 Mon Sep 17 00:00:00 2001 From: Kevin Schaaf Date: Mon, 7 May 2018 13:34:01 -0700 Subject: [PATCH] Add publish-demos script --- scripts/publish-demos.sh | 63 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100755 scripts/publish-demos.sh diff --git a/scripts/publish-demos.sh b/scripts/publish-demos.sh new file mode 100755 index 000000000..1745746d6 --- /dev/null +++ b/scripts/publish-demos.sh @@ -0,0 +1,63 @@ +#!/bin/sh + +## +# Copyright 2016 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +set -e + +# Remove previous build +rm -rf build +# Get list of demos +demos=`ls demos/*.html` +# Transform demo list into list of --fragment flags +fragments=`echo $demos | sed -E 's/([^ ]*)/--fragment \1/g'` +# Run polymer build to do node module resolution on the demos, output to build/default +polymer build --module-resolution=node $fragments +# Clone gh-pages branch +git clone git@github.com:material-components/material-components-web-components.git -b gh-pages build/gh-pages +# Copy built source to gh-pages +cp -rf build/default/* build/gh-pages + +# Push to gh-pages +read -p "Test build/gh-pages/demos/index.html, then press 'y' to publish to gh-pages: " -n 1 -r +echo # (optional) move to a new line +if [[ $REPLY =~ ^[Yy]$ ]] +then + (cd build/gh-pages && git add -A && git commit -m 'Update gh-pages' && git push origin gh-pages) +fi + +# Bundled/compiled build currently not working well.... + +# # Run polymer build to do node module resolution on the demos, output to build/default +# polymer build --js-compile --module-resolution=node $fragments +# # Make a build/interim copy of build/default +# cp -rf build/default build/interim +# # Add babel-polyfill to the babel helpers injected build-entrypoint +# echo '' >> build/default/build-entrypoint.html +# # Inject the babel helpers from the original entrypoint into each demo in interim +# for f in $demos; do sed '// r build/default/build-entrypoint.html' build/default/$f > build/interim/$f; done; +# # Install babel-polyfill +# (cd build/interim && npm install babel-polyfill) +# # Move webcomponents into the interim copy (for some reason --extra-dependencies on polymer build above was failing) +# cp -rf node_modules/@webcomponents/webcomponentsjs build/interim/node_modules/@webcomponents +# # Clear the build entrypoint file in the interim copy +# echo '' > build/interim/build-entrypoint.html +# # Bundle the interim demos +# (cd build/interim && polymer build --module-resolution=node --bundle $fragments --entrypoint build-entrypoint.html) +# # Blow away interim +# # rm -rf build/default +# # mv build/interim/build/default build/default +# # rm -rf build/interim \ No newline at end of file