Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 20 additions & 19 deletions samples/app.sh
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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"
Expand Down