Skip to content

Commit f4c2614

Browse files
committed
feat(smoke-matrix): boot config-only expo-router examples (with-router)
expo/examples ships with-router as a config-only template: package.json + app.json + README, with main set to expo-router/entry but no routes yet (npx create-expo-app -e with-router generates them at scaffold time). The matrix harness saw no App/index entry and skipped. Now: when an example has no entry but its package.json declares main as expo-router/entry, synthesize a minimal app/ tree (Slot + index route) under .smoke-entries/<name>-stub-app/ and route the wrapper through it. The expo-router-entry shims placeholder still does the actual mounting — what we gain is one more PASS row in the matrix proving the expo-router boot path.
1 parent c023829 commit f4c2614

1 file changed

Lines changed: 38 additions & 6 deletions

File tree

scripts/ci/smoke-all-examples.sh

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ for dir in "${EXAMPLES_DIR}"/*/; do
108108
# router scans the app/ dir.
109109
entry=""
110110
router=0
111+
router_root=""
111112
for cand in App.tsx App.js index.tsx index.js; do
112113
if [[ -f "${dir}${cand}" ]]; then
113114
entry="${dir}${cand}"
@@ -118,6 +119,7 @@ for dir in "${EXAMPLES_DIR}"/*/; do
118119
router=1
119120
entry="${dir}app/_layout.tsx"
120121
[[ -f "${entry}" ]] || entry="${dir}app/_layout.js"
122+
router_root="${dir}app"
121123
fi
122124
# Newer expo-router apps use a `src/app/` layout (with-graphql,
123125
# with-html, with-react-flow, with-tailwindcss, …). package.json
@@ -127,6 +129,38 @@ for dir in "${EXAMPLES_DIR}"/*/; do
127129
router=1
128130
entry="${dir}src/app/_layout.tsx"
129131
[[ -f "${entry}" ]] || entry="${dir}src/app/_layout.js"
132+
router_root="${dir}src/app"
133+
fi
134+
# Config-only example: package.json points at expo-router/entry but
135+
# the README leaves the routes for `npx create-expo-app -e <name>` to
136+
# generate. `with-router` is the canonical one. Synthesize a minimal
137+
# app/ dir next to the wrapper so the router has something to mount —
138+
# this proves expo-router + its shim boot without touching the
139+
# external submodule.
140+
if [[ -z "${entry}" && -f "${dir}package.json" ]]; then
141+
if grep -qE '"main"\s*:\s*"expo-router/entry"' "${dir}package.json"; then
142+
stub_app="${WRAPPER_DIR}/${name//\//-}-stub-app"
143+
mkdir -p "${stub_app}"
144+
cat > "${stub_app}/_layout.tsx" <<'EOF'
145+
import {Slot} from 'expo-router';
146+
export default function Layout() {
147+
return <Slot />;
148+
}
149+
EOF
150+
cat > "${stub_app}/index.tsx" <<EOF
151+
import {Text, View} from 'react-native';
152+
export default function Index() {
153+
return (
154+
<View style={{flex: 1, alignItems: 'center', justifyContent: 'center', backgroundColor: '#0c0a09'}}>
155+
<Text style={{color: '#fafaf9', fontSize: 18}}>${name} stub route</Text>
156+
</View>
157+
);
158+
}
159+
EOF
160+
router=1
161+
entry="${stub_app}/_layout.tsx"
162+
router_root="${stub_app}"
163+
fi
130164
fi
131165
if [[ -z "${entry}" ]]; then
132166
printf '%-40s %-12s %s\n' "${name}" 'SKIPPED' 'no App / index / app entry' >> "${SUMMARY}"
@@ -146,12 +180,10 @@ for dir in "${EXAMPLES_DIR}"/*/; do
146180
# build-time string) for the routes tree. We set it to the
147181
# absolute path of the example's app/ dir so the router resolves
148182
# against the right routes even though our bundle entrypoint
149-
# is in apps/playground/.smoke-entries/.
150-
if [[ -d "${dir}app" ]]; then
151-
app_dir_abs="$(cd "${dir}app" && pwd)"
152-
else
153-
app_dir_abs="$(cd "${dir}src/app" && pwd)"
154-
fi
183+
# is in apps/playground/.smoke-entries/. For config-only examples
184+
# (e.g. with-router) the router_root points at the synthesized
185+
# stub app dir under WRAPPER_DIR.
186+
app_dir_abs="$(cd "${router_root}" && pwd)"
155187
cat > "${wrapper}" <<EOF
156188
// Auto-generated by scripts/ci/smoke-all-examples.sh — do not edit.
157189
// expo-router smoke for ${name}.

0 commit comments

Comments
 (0)