diff --git a/samples/app.sh b/samples/app.sh index 0b3c84f9..63202486 100644 --- a/samples/app.sh +++ b/samples/app.sh @@ -1,11 +1,8 @@ #!/bin/bash -# Copy/generate files for Cloud Shell. - -# TODO: Test in the context of tsconfig. - -# Disable history expansion so '!' doesn't trigger the command. (do we need this?) -#set +H +# Copy/generate files for: +# - Cloud Shell +# - Vite build output for hosting # Generate JSFiddle output as part of the build process. NAME=$1 # The name of the folder, taken from package.json "build" line. @@ -14,24 +11,28 @@ NAME=$1 # The name of the folder, taken from package.json "build" line. #OUTPUT_DIR=/Users/[USERNAME]/git/js-api-samples/samples OUTPUT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" -DIST_DIR="../../dist/samples/${NAME}/app" +APP_DIR="../../dist/samples/${NAME}/app" +MAIN_DIR="../../dist/samples/${NAME}" -# Create a new folder. -mkdir -p ${DIST_DIR} +# Create the new folders. +mkdir -p ${APP_DIR} +mkdir -p ${MAIN_DIR} # Copy files -cp "${OUTPUT_DIR}/${NAME}/index.html" "${DIST_DIR}/index.html" -cp "${OUTPUT_DIR}/${NAME}/index.ts" "${DIST_DIR}/index.ts" -cp "${OUTPUT_DIR}/${NAME}/style.css" "${DIST_DIR}/style.css" -cp "${OUTPUT_DIR}/${NAME}/package.json" "${DIST_DIR}/package.json" -cp "${OUTPUT_DIR}/${NAME}/tsconfig.json" "${DIST_DIR}/tsconfig.json" -cp "${OUTPUT_DIR}/${NAME}/README.md" "${DIST_DIR}/README.md" -cp "${OUTPUT_DIR}/.env" "${DIST_DIR}/.env" -cp -r "${OUTPUT_DIR}/${NAME}/dist" "${DIST_DIR}/dist" +cp "${OUTPUT_DIR}/${NAME}/index.html" "${APP_DIR}/index.html" +cp "${OUTPUT_DIR}/${NAME}/index.ts" "${APP_DIR}/index.ts" +cp "${OUTPUT_DIR}/${NAME}/style.css" "${APP_DIR}/style.css" +cp "${OUTPUT_DIR}/${NAME}/package.json" "${APP_DIR}/package.json" +cp "${OUTPUT_DIR}/${NAME}/tsconfig.json" "${APP_DIR}/tsconfig.json" +cp "${OUTPUT_DIR}/${NAME}/README.md" "${APP_DIR}/README.md" +cp "${OUTPUT_DIR}/.env" "${APP_DIR}/.env" # TODO: Update the .env with the new API key. +cp -r "${OUTPUT_DIR}/${NAME}/dist/." "${MAIN_DIR}/" +echo "OUTPUT_DIR ${OUTPUT_DIR}" +echo "MAIN_DIR ${MAIN_DIR}" # Generate .eslintsrc.json -touch "${DIST_DIR}/.eslintsrc.json" -cat > "${DIST_DIR}/.eslintsrc.json" << EOF +touch "${APP_DIR}/.eslintsrc.json" +cat > "${APP_DIR}/.eslintsrc.json" << EOF { "extends": [ "plugin:@typescript-eslint/recommended"