|
| 1 | +import { FileTree } from 'nextra/components' |
| 2 | +import { Image } from '@app/primitives' |
| 3 | +import { TitleWrapper } from '@app/docs/components/Hidden' |
| 4 | + |
| 5 | +<TitleWrapper> |
| 6 | + ## `add-route` - Generator |
| 7 | +</TitleWrapper> |
| 8 | + |
| 9 | +<Image |
| 10 | + src={require('@app/assets/green-stack-logo.png')} |
| 11 | + style={{ marginTop: 20 }} |
| 12 | + width={60} |
| 13 | + height={60} |
| 14 | + unoptimized |
| 15 | +/> |
| 16 | + |
| 17 | +# `add-route` |
| 18 | + |
| 19 | +```md copy |
| 20 | +npm run add:route -- --args <workspacePath> <screenName> <routePath> <initialDataTarget> |
| 21 | +``` |
| 22 | + |
| 23 | +```md copy |
| 24 | +npx turbo gen route --args <workspacePath> <screenName> <routePath> <initialDataTarget> |
| 25 | +``` |
| 26 | + |
| 27 | +<FileTree> |
| 28 | + <FileTree.Folder name="packages" defaultOpen> |
| 29 | + <FileTree.Folder name="@green-stack-core" defaultOpen> |
| 30 | + <FileTree.Folder name="generators" defaultOpen> |
| 31 | + <FileTree.File name="add-route.ts" /> |
| 32 | + </FileTree.Folder> |
| 33 | + </FileTree.Folder> |
| 34 | + </FileTree.Folder> |
| 35 | +</FileTree> |
| 36 | + |
| 37 | +<div className="h-8" /> |
| 38 | + |
| 39 | +### Prompt Arguments |
| 40 | + |
| 41 | +| Argument | Type | Question / Description | |
| 42 | +|------------------|--------------|--------------------------------------------------------------------------------| |
| 43 | +| workspacePath | autocomplete | Where would you like to add this route? <br/>=> e.g. `features/@app-core` | |
| 44 | +| screenName | input | What should the screen component be called? <br/>=> `string` | |
| 45 | +| routePath | input | What url do you want this route on? <br/>=> e.g. `/some/path` | |
| 46 | +| initialDataTarget| autocomplete | Would you like to fetch initial data from a resolver? <br/>=> `string` | |
| 47 | + |
| 48 | +<div className="h-8" /> |
| 49 | + |
| 50 | +### Resulting File Changes |
| 51 | + |
| 52 | +```bash |
| 53 | +/apps/expo/ |
| 54 | + └── app/(generated)/{routePath}/index.tsx ❇️ # <- e.g. '/posts/[slug]/' (expo-router) |
| 55 | +/apps/next/ |
| 56 | + └── app/(generated)/{routePath}/page.tsx ❇️ # <- e.g. '/posts/[slug]/' (Next.js app router) |
| 57 | + |
| 58 | +/{workspacePath}/ # <- e.g. 'features/@app-core/' or 'packages/some-package/' |
| 59 | + └── screens/ |
| 60 | + └── {ScreenName}.tsx ❇️ |
| 61 | + └── routes/ |
| 62 | + └── {routePath}/ ❇️ # <- e.g. '/posts/[slug]/' |
| 63 | + └── index.tsx ❇️ # -> re-exported to `@app/next` and `@app/expo` |
| 64 | +``` |
| 65 | + |
| 66 | +<div className="h-8" /> |
0 commit comments