Repository navigation
fix: disable expo router sitemap in production builds #164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
f8aafdc
fix: disable expo router sitemap in production builds
devs-rootstrap f27caf7
docs: document sitemap route availability per environment
devs-rootstrap e42b2ac
test: cover expo router sitemap option per environment
devs-rootstrap d4045f2
docs: add sitemap screen screenshot to navigation guide
devs-rootstrap 0ded3f2
chore: add eas update scripts that set APP_ENV
devs-rootstrap b0a6b07
test: cover unset APP_ENV and fail on bare expo-router entry
devs-rootstrap 7d1eff9
docs: clarify sitemap route behavior in production
devs-rootstrap aea1e8a
chore: align expo patch versions and skip edge-to-edge directory check
fernandatoledo 742a415
fix: resolve sonarqube issues in tab layout, cli and i18n validator
fernandatoledo a6a7f50
fix: remove regex backtracking and nested template literal in cli
fernandatoledo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| import type { ConfigContext, ExpoConfig } from '@expo/config'; | ||
|
|
||
| type AppConfigFn = (context: ConfigContext) => ExpoConfig; | ||
|
|
||
| const loadConfigFor = (appEnv: string | undefined): ExpoConfig => { | ||
| if (appEnv === undefined) { | ||
| delete process.env.APP_ENV; | ||
| } else { | ||
| process.env.APP_ENV = appEnv; | ||
| } | ||
| let appConfig: AppConfigFn | undefined; | ||
| jest.isolateModules(() => { | ||
| appConfig = require('../app.config').default; | ||
| }); | ||
| if (!appConfig) { | ||
| throw new Error('app.config.ts could not be loaded'); | ||
| } | ||
| return appConfig({ config: {} } as ConfigContext); | ||
| }; | ||
|
|
||
| const getExpoRouterOptions = (config: ExpoConfig) => { | ||
| const entry = config.plugins?.find((plugin) => | ||
| Array.isArray(plugin) | ||
| ? plugin[0] === 'expo-router' | ||
| : plugin === 'expo-router', | ||
| ); | ||
| if (!Array.isArray(entry)) { | ||
| throw new Error( | ||
| `Expected the expo-router plugin to be configured as ['expo-router', options], received ${JSON.stringify(entry)}`, | ||
| ); | ||
| } | ||
| return entry[1]; | ||
| }; | ||
|
|
||
| describe('app.config expo-router sitemap', () => { | ||
| const originalAppEnv = process.env.APP_ENV; | ||
|
|
||
| afterEach(() => { | ||
| if (originalAppEnv === undefined) { | ||
| delete process.env.APP_ENV; | ||
| } else { | ||
| process.env.APP_ENV = originalAppEnv; | ||
| } | ||
| }); | ||
|
|
||
| it('disables the sitemap route in production', () => { | ||
| const config = loadConfigFor('production'); | ||
|
|
||
| expect(getExpoRouterOptions(config)).toEqual({ sitemap: false }); | ||
| }); | ||
|
|
||
| it.each(['development', 'qa', 'staging'])( | ||
| 'keeps the sitemap route in %s', | ||
| (appEnv) => { | ||
| const config = loadConfigFor(appEnv); | ||
|
|
||
| expect(getExpoRouterOptions(config)).toEqual({ sitemap: true }); | ||
| }, | ||
| ); | ||
|
|
||
| it('keeps the sitemap route when APP_ENV is unset (defaults to development)', () => { | ||
| const config = loadConfigFor(undefined); | ||
|
|
||
| expect(getExpoRouterOptions(config)).toEqual({ sitemap: true }); | ||
| }); | ||
|
|
||
| it('fails loudly when the expo-router entry has no options', () => { | ||
| const config = { plugins: ['expo-router'] } as ExpoConfig; | ||
|
|
||
| expect(() => getExpoRouterOptions(config)).toThrow( | ||
| /Expected the expo-router plugin/, | ||
| ); | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.