Skip to content

Commit 31ec0d8

Browse files
authored
chore: Fix build pipeline and routing for React samples. (#1623)
* chore: Fix build pipeline and routing for React samples. Change-Id: I75a1735bea837351371a345feceab13e42f00f81 * chore: Update dist.sh to delete dist prior to copying. Change-Id: I7223e4daf8ba2874ebc23470773eed94e5adcf95 * fix: Removes duplicate 'set +e' line. Change-Id: I2c9137792e7f817c9fbf711345f933169a9dbcff
1 parent 7be6d5f commit 31ec0d8

11 files changed

Lines changed: 47 additions & 20 deletions

File tree

‎samples/build-single.sh‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ npx eslint
167167

168168
# clean comments for empty lines, and then clean up, to preserve newlines
169169
sed -i.sed-back 's#^$#// TMP EMPTY LINE#g' *.ts && rm *.sed-back
170+
rm -rf dist
170171
set +e
171172
npx tsc
172173
status=$?
@@ -207,6 +208,10 @@ set -e
207208

208209
bash ../jsfiddle.sh "$NAME"
209210
bash ../app.sh "$NAME"
210-
bash ../docs.sh "$NAME"
211+
if [ -f "src/app.tsx" ] || [ -f "src/app.jsx" ] || [ -f "src/app.js" ]; then
212+
bash ../react-docs.sh "$NAME"
213+
else
214+
bash ../docs.sh "$NAME"
215+
fi
211216
npm run build:vite --workspace=.
212217
bash ../dist.sh "$NAME"

‎samples/dist.sh‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@ SAMPLE_DIR="${PROJECT_ROOT}/dist/samples/${NAME}"
2020
echo "PROJECT_ROOT: ${PROJECT_ROOT}"
2121

2222
# Copy Vite output files to /dist/samples/${NAME}/dist
23+
rm -rf "${SAMPLE_DIR}/dist"
2324
cp -r "${SCRIPT_DIR}/${NAME}/dist" "${SAMPLE_DIR}"

‎samples/react-docs.sh‎

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,29 @@ echo "PROJECT_ROOT: ${PROJECT_ROOT}"
1616

1717
DOCS_DIR="${PROJECT_ROOT}/dist/samples/${NAME}/docs"
1818

19-
# Create two new folders.
20-
mkdir -p ${DOCS_DIR}/src
19+
# Create new folders.
20+
mkdir -p "${DOCS_DIR}/src"
2121

2222
# Copy files
23-
cp "${SCRIPT_DIR}/${NAME}/src/app.js" "${DOCS_DIR}/src/app.js"
24-
cp "${SCRIPT_DIR}/${NAME}/src/app.tsx" "${DOCS_DIR}/src/app.tsx"
25-
cp "${SCRIPT_DIR}/${NAME}/src/styles.css" "${DOCS_DIR}/src/styles.css"
26-
cp "${SCRIPT_DIR}/${NAME}/index.html" "${DOCS_DIR}/index.html"
27-
28-
# Copy the data folder if one is found.
29-
if [ -d "public" ] && [ "$(ls -A public)" ]; then
30-
cp -r public/* "${DOCS_DIR}/"
31-
fi
23+
if [ -f "${SCRIPT_DIR}/${NAME}/dist/app.js" ]; then
24+
cp "${SCRIPT_DIR}/${NAME}/dist/app.js" "${DOCS_DIR}/app.js"
25+
fi
26+
27+
if [ -f "${SCRIPT_DIR}/${NAME}/src/app.tsx" ]; then
28+
cp "${SCRIPT_DIR}/${NAME}/src/app.tsx" "${DOCS_DIR}/src/app.tsx"
29+
fi
30+
31+
if [ -f "${SCRIPT_DIR}/${NAME}/style.css" ]; then
32+
cp "${SCRIPT_DIR}/${NAME}/style.css" "${DOCS_DIR}/style.css"
33+
elif [ -f "${SCRIPT_DIR}/${NAME}/src/styles.css" ]; then
34+
cp "${SCRIPT_DIR}/${NAME}/src/styles.css" "${DOCS_DIR}/style.css"
35+
fi
36+
37+
if [ -f "${SCRIPT_DIR}/${NAME}/index.html" ]; then
38+
cp "${SCRIPT_DIR}/${NAME}/index.html" "${DOCS_DIR}/index.html"
39+
fi
40+
41+
# Copy the public folder if one is found (graphics, other static files).
42+
if [ -d "${SCRIPT_DIR}/${NAME}/public" ] && [ "$(ls -A ${SCRIPT_DIR}/${NAME}/public)" ]; then
43+
cp -r "${SCRIPT_DIR}/${NAME}/public/"* "${DOCS_DIR}/"
44+
fi

‎samples/react-ui-kit-place-details-compact/package.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99
"build:vite": "vite build --config ../../vite.config.js --base './'",
1010
"preview": "vite preview --config ../../vite.config.js"
1111
},
12-
"author": "Google LLC"
12+
"author": "Google LLC",
13+
"buildRevision": 1
1314
}

‎samples/react-ui-kit-place-details-latlng-compact/package.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99
"build:vite": "vite build --config ../../vite.config.js --base './'",
1010
"preview": "vite preview --config ../../vite.config.js"
1111
},
12-
"author": "Google LLC"
12+
"author": "Google LLC",
13+
"buildRevision": 1
1314
}

‎samples/react-ui-kit-place-details-latlng/package.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@
1212
"devDependencies": {
1313
"@vitejs/plugin-react": "^6.0.2"
1414
},
15-
"author": "Google LLC"
15+
"author": "Google LLC",
16+
"buildRevision": 1
1617
}

‎samples/react-ui-kit-place-details/package.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99
"build:vite": "vite build --config ../../vite.config.js --base './'",
1010
"preview": "vite preview --config ../../vite.config.js"
1111
},
12-
"author": "Google LLC"
12+
"author": "Google LLC",
13+
"buildRevision": 1
1314
}

‎samples/react-ui-kit-search-nearby/package.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@
1212
"devDependencies": {
1313
"@vitejs/plugin-react": "^6.0.2"
1414
},
15-
"author": "Google LLC"
15+
"author": "Google LLC",
16+
"buildRevision": 1
1617
}

‎samples/react-ui-kit-search-text/package.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@
1212
"devDependencies": {
1313
"@vitejs/plugin-react": "^6.0.2"
1414
},
15-
"author": "Google LLC"
15+
"author": "Google LLC",
16+
"buildRevision": 1
1617
}

‎samples/rgm-autocomplete/package.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99
"build:vite": "vite build --config ../../vite.config.js --base './'",
1010
"preview": "vite preview --config ../../vite.config.js"
1111
},
12-
"author": "Google LLC"
12+
"author": "Google LLC",
13+
"buildRevision": 1
1314
}

0 commit comments

Comments
 (0)