11#! /bin/bash
22
3- # Copy/generate files for Cloud Shell.
4-
5- # TODO: Test in the context of tsconfig.
6-
7- # Disable history expansion so '!' doesn't trigger the command. (do we need this?)
8- # set +H
3+ # Copy/generate files for:
4+ # - Cloud Shell
5+ # - Vite build output for hosting
96
107# Generate JSFiddle output as part of the build process.
118NAME=$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.
1411# OUTPUT_DIR=/Users/[USERNAME]/git/js-api-samples/samples
1512OUTPUT_DIR=" $( cd -- " $( dirname -- " ${BASH_SOURCE[0]} " ) " & > /dev/null && pwd ) "
1613
17- DIST_DIR=" ../../dist/samples/${NAME} /app"
14+ APP_DIR=" ../../dist/samples/${NAME} /app"
15+ MAIN_DIR=" ../../dist/samples/${NAME} "
1816
19- # Create a new folder.
20- mkdir -p ${DIST_DIR}
17+ # Create the new folders.
18+ mkdir -p ${APP_DIR}
19+ mkdir -p ${MAIN_DIR}
2120
2221# Copy files
23- cp " ${OUTPUT_DIR} /${NAME} /index.html" " ${DIST_DIR} /index.html"
24- cp " ${OUTPUT_DIR} /${NAME} /index.ts" " ${DIST_DIR} /index.ts"
25- cp " ${OUTPUT_DIR} /${NAME} /style.css" " ${DIST_DIR} /style.css"
26- cp " ${OUTPUT_DIR} /${NAME} /package.json" " ${DIST_DIR} /package.json"
27- cp " ${OUTPUT_DIR} /${NAME} /tsconfig.json" " ${DIST_DIR} /tsconfig.json"
28- cp " ${OUTPUT_DIR} /${NAME} /README.md" " ${DIST_DIR} /README.md"
29- cp " ${OUTPUT_DIR} /.env" " ${DIST_DIR} /.env"
30- cp -r " ${OUTPUT_DIR} /${NAME} /dist" " ${DIST_DIR} /dist"
22+ cp " ${OUTPUT_DIR} /${NAME} /index.html" " ${APP_DIR} /index.html"
23+ cp " ${OUTPUT_DIR} /${NAME} /index.ts" " ${APP_DIR} /index.ts"
24+ cp " ${OUTPUT_DIR} /${NAME} /style.css" " ${APP_DIR} /style.css"
25+ cp " ${OUTPUT_DIR} /${NAME} /package.json" " ${APP_DIR} /package.json"
26+ cp " ${OUTPUT_DIR} /${NAME} /tsconfig.json" " ${APP_DIR} /tsconfig.json"
27+ cp " ${OUTPUT_DIR} /${NAME} /README.md" " ${APP_DIR} /README.md"
28+ cp " ${OUTPUT_DIR} /.env" " ${APP_DIR} /.env" # TODO: Update the .env with the new API key.
29+ cp -r " ${OUTPUT_DIR} /${NAME} /dist/." " ${MAIN_DIR} /"
30+ echo " OUTPUT_DIR ${OUTPUT_DIR} "
31+ echo " MAIN_DIR ${MAIN_DIR} "
3132
3233# Generate .eslintsrc.json
33- touch " ${DIST_DIR } /.eslintsrc.json"
34- cat > " ${DIST_DIR } /.eslintsrc.json" << EOF
34+ touch " ${APP_DIR } /.eslintsrc.json"
35+ cat > " ${APP_DIR } /.eslintsrc.json" << EOF
3536{
3637 "extends": [
3738 "plugin:@typescript-eslint/recommended"
0 commit comments