Skip to content
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

plugin: GREEN stack #9

Open
wants to merge 69 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
13781a9
feat: Add nativewind
codinsonn Apr 4, 2024
8aee576
fix: Add TextLink to provide styles for Next Link
codinsonn Apr 5, 2024
7fed591
chore: Rewrite HomeScreen & SlugScreen to use Nativewind classNames
codinsonn Apr 5, 2024
ca782e9
chore: Add custom primary color in tailwind.theme.js
codinsonn Apr 5, 2024
9efca2f
feat: Parse NativeWind styles in custom Image & Link
codinsonn Apr 8, 2024
8c19f65
feat: Implement React portability patterns
codinsonn Apr 5, 2024
c299b6a
feat: Add portable Image component
codinsonn Apr 9, 2024
9d7c056
feat: Add Apollo Server at '/api/graphql'
codinsonn Apr 12, 2024
328b192
feat: Add graphql.tada for automagic GraphQL typesafety
codinsonn Apr 12, 2024
df0de06
feat: Add buildSchema() script & isomorphic graphqlQuery() helper
codinsonn Apr 14, 2024
6129c89
feat: Add Turborepo setup
codinsonn Apr 21, 2024
0b8518e
chore: Merge plugins for nativewind & portability patterns
codinsonn Apr 25, 2024
6e64548
chore: Merge plugin branch 'with/turborepo'
codinsonn Apr 25, 2024
b05b183
feat: Merge plugin branch 'with/graphql-server-apollo'
codinsonn Apr 29, 2024
08e3201
feat: Add UniversalRouteScreen data fetching with react-query
codinsonn Apr 18, 2024
5892833
feat: Merge plugin branch 'with/react-query'
codinsonn May 1, 2024
fc16c49
chore: Move core files to '@green-stack/core' package workspace
codinsonn May 8, 2024
5232f9b
feat: Add Zod schemas as Source of Truth basis
codinsonn May 12, 2024
3385aae
switch to strict typing
codinsonn May 18, 2024
a2a6fa5
feat: Update to Expo SDK 51
codinsonn May 18, 2024
ad323e9
feat: Add createDataBridge() util to bridge resolvers
codinsonn May 19, 2024
3db6ac2
feat: Add bridgedFetcher() util to @green-stack/core
codinsonn May 20, 2024
07e620d
feat: Add createResolver() util to build resolver from DataBridge
codinsonn May 22, 2024
85e00a9
feat: Add JSON scalar and request context to GraphQL
codinsonn May 23, 2024
29d82e0
feat: Add plugin tests for createSchemaPlugin()
codinsonn Jun 6, 2024
91dfea9
chore: Rename 'typeName' in introspection meta to 'zodType'
codinsonn Jun 7, 2024
9f91787
feat: Add automagic GraphQL codegen for both executable schema & SDL
codinsonn Jun 12, 2024
5731297
feat: Add scriptUtils to build scripts and generators with
codinsonn Jun 13, 2024
cc32977
feat: Add check-workspaces script to @green-stack/core
codinsonn Jun 14, 2024
bd41905
feat: Add collect-resolvers script
codinsonn Jun 15, 2024
92bfc5a
feat: Add link-routes script
codinsonn Jun 16, 2024
12adef1
feat: Add href & params prop hints to Universal Link
codinsonn Jun 16, 2024
baa318a
feat: Add useLayoutInfo() hook to @green-stack/core
codinsonn Jun 16, 2024
fd9bfea
feat: Add workspace generator
codinsonn Jun 16, 2024
1886cf2
feat: Add collect-generators script
codinsonn Jun 16, 2024
6b831ac
feat: Add aliases for @app/core & @green-stack/core through tsConfig …
codinsonn Jun 19, 2024
e97ee50
feat: Add createSchemaModel() method for mock memory db driver
codinsonn Jun 20, 2024
e574d32
feat: Add mock db driver & collect:drivers scripts
codinsonn Jun 28, 2024
44d1031
feat: Added an "add-dependencies" script / generator
codinsonn Jul 10, 2024
b6b8904
feat: Update HomeScreen design
codinsonn Jul 12, 2024
95b54a0
chore: Merge 'main' into 'with/green-stack'
codinsonn Jul 24, 2024
b08dc8e
chore: Merge 'main' into 'with/green-stack'
codinsonn Jul 24, 2024
d73c679
chore: Rename args & response schemas to input & output
codinsonn Aug 8, 2024
ed0cae4
feat: Add upsertOne() to db model driver
codinsonn Aug 8, 2024
3fb34de
feat: Add useFormState() hook to @green-stack/core
codinsonn Aug 23, 2024
6f1d955
chore: Bump expo SDK 51 dependencies
codinsonn Aug 26, 2024
644905a
feat: Add FormScreen and demo route
codinsonn Aug 26, 2024
cc8b05f
feat: Update to nativewind V4
codinsonn Aug 27, 2024
ce023b7
feat: Add styled example Checkbox
codinsonn Aug 28, 2024
1278c57
feat: Add CheckList form component
codinsonn Sep 2, 2024
22ca317
feat: Add array and object support to universal URL params
codinsonn Sep 2, 2024
b8ae2a9
feat: Add RadioGroup form component
codinsonn Sep 3, 2024
3927d18
fix: Deprecated fields 'editable' & 'nativeID'
codinsonn Sep 4, 2024
357fbf4
feat: Add Select form component
codinsonn Sep 8, 2024
4ada53c
feat: Add NumberStepper form component
codinsonn Sep 9, 2024
4ef4fc1
feat: Add TextArea form Component
codinsonn Sep 10, 2024
1eae120
feat: Add useScrollToFocusedInput() hook
codinsonn Sep 10, 2024
f578af5
feat: Add build-theme-colors script and flesh out color utils
codinsonn Sep 12, 2024
d2321d7
feat: Add nativewind support to SVG through cssInterop
codinsonn Sep 12, 2024
fd15841
feat: Add Switch form component
codinsonn Sep 12, 2024
4a15a50
feat: Add geolocation to headerContext if available
codinsonn Sep 13, 2024
410baba
feat: Add UniversalIcon component
codinsonn Sep 13, 2024
e2940c9
feat: Add Button component
codinsonn Sep 17, 2024
d09deb3
feat: Make Form Input components more narrowable
codinsonn Sep 22, 2024
bf24d80
feat: Add efficiency calculator to forms demo
codinsonn Sep 25, 2024
9c87af9
startup-sin: Finish implementing Dark Mode
codinsonn Oct 4, 2024
289332b
fix: Form input styles
codinsonn Oct 11, 2024
300c69a
feat: Add createKey() util to turn objects into key strings
codinsonn Oct 11, 2024
4722b60
fix: Add proper error and disabled states to Form components
codinsonn Oct 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,5 @@ yarn-error.log*
.pnp.js

# -- @end @expo/next-adapter --

.turbo
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"typescript.tsdk": "node_modules/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": true
}
50 changes: 46 additions & 4 deletions apps/expo/.env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,46 @@
EXPO_PUBLIC_BASE_URL=
EXPO_PUBLIC_BACKEND_URL=
EXPO_PUBLIC_API_URL=
EXPO_PUBLIC_GRAPH_URL=
## --- Notes ----------------------------------------------------------------------------------- */

## -i- The `.env.example` file can be copied into `.env.local` using `npx turbo env:local`
## -i- For more info, development, staging & production environments, check the expo docs:
## -i- https://docs.expo.dev/guides/environment-variables/

## -i- Note that Expo will inline environment variables in your bundle during builds & deployments
## -i- This means dynamically retrieving environment variables from e.g. `process.env[someKey]` will not work
## -i- It also means that you should never include sensitive / private keys

## -i- We suggest that for each environment variable you add here, you also add an entry in `appConfig.ts`
## -i- There, you can add logic like ```envValue: process.env.EXPO_PUBLIC_ENV_KEY || process.env.NEXT_PUBLIC_ENV_KEY```
## -i- Where you would only define the EXPO_PUBLIC_ prefixed versions here in `.env.local` locally and using Expo UI for deployed envs

## --- General --------------------------------------------------------------------------------- */
## -i- Env vars that should always be present & the same locally, independent of the simulated environment
## --------------------------------------------------------------------------------------------- */

EXPO_PUBLIC_BASE_URL= # Keep empty in `.env.local` for maximum local testability, `appConfig.ts` will figure out back-end URL from expo-config
EXPO_PUBLIC_BACKEND_URL= # Keep empty in `.env.local` for maximum local testability, `appConfig.ts` will figure out back-end URL from expo-config
EXPO_PUBLIC_API_URL= # Keep empty in `.env.local` for maximum local testability, `appConfig.ts` will figure out back-end URL from expo-config
EXPO_PUBLIC_GRAPH_URL= # Keep empty in `.env.local` for maximum local testability, `appConfig.ts` will figure out back-end URL from expo-config

## --- LOCAL ----------------------------------------------------------------------------------- */
## -i- Defaults you might want to switch out for local development by commenting / uncommenting
## --------------------------------------------------------------------------------------------- */

# EXAMPLE= # ...

## --- DEV ------------------------------------------------------------------------------------- */
# -i- Uncomment while on development branch to simulate the dev environment
## --------------------------------------------------------------------------------------------- */

# EXAMPLE= # ...

## --- STAGE ----------------------------------------------------------------------------------- */
# -i- Uncomment while on staging branch to simulate the stage environment
## --------------------------------------------------------------------------------------------- */

# EXAMPLE= # ...

## --- PROD ------------------------------------------------------------------------------------ */
# -i- Uncomment while on main branch to simulate the production environment
## --------------------------------------------------------------------------------------------- */

# EXAMPLE= # ...
3 changes: 2 additions & 1 deletion apps/expo/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
],
"web": {
"bundler": "metro"
}
},
"userInterfaceStyle": "light"
}
}
2 changes: 2 additions & 0 deletions apps/expo/app/(generated)/demos/forms/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// -i- Automatically generated by 'npx turbo @green-stack/core#link:routes', do not modify manually, it will get overwritten
export { default } from '@app/core/routes/demos/forms/index'
2 changes: 2 additions & 0 deletions apps/expo/app/(generated)/demos/images/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// -i- Automatically generated by 'npx turbo @green-stack/core#link:routes', do not modify manually, it will get overwritten
export { default } from '@app/core/routes/demos/images/index'
2 changes: 2 additions & 0 deletions apps/expo/app/(generated)/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// -i- Automatically generated by 'npx turbo @green-stack/core#link:routes', do not modify manually, it will get overwritten
export { default } from '@app/core/routes/index'
2 changes: 2 additions & 0 deletions apps/expo/app/(generated)/subpages/[slug]/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// -i- Automatically generated by 'npx turbo @green-stack/core#link:routes', do not modify manually, it will get overwritten
export { default } from '@app/core/routes/subpages/[slug]/index'
3 changes: 0 additions & 3 deletions apps/expo/app/(main)/images/index.tsx

This file was deleted.

3 changes: 0 additions & 3 deletions apps/expo/app/(main)/index.tsx

This file was deleted.

3 changes: 0 additions & 3 deletions apps/expo/app/(main)/subpages/[slug]/index.tsx

This file was deleted.

64 changes: 49 additions & 15 deletions apps/expo/app/ExpoRootLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,58 @@
import { useEffect } from 'react'
import { Stack } from 'expo-router'
import UniversalAppProviders from '@app/core/screens/UniversalAppProviders'
import UniversalRootLayout from '@app/core/screens/UniversalRootLayout'
import { isWeb } from '@app/config'
import UniversalAppProviders from '@app/screens/UniversalAppProviders'
import UniversalRootLayout from '@app/screens/UniversalRootLayout'
import { useColorScheme } from 'nativewind'
import { Image as ExpoContextImage } from '@green-stack/components/Image.expo'
import { Link as ExpoContextLink } from '@green-stack/navigation/Link.expo'
import { useRouter as useExpoContextRouter } from '@green-stack/navigation/useRouter.expo'
import { useRouteParams as useExpoRouteParams } from '@green-stack/navigation/useRouteParams.expo'

// -i- Expo Router's layout setup is much simpler than Next.js's layout setup
// -i- Since Expo doesn't require a custom document setup or server component root layout
// -i- Use this file to apply your Expo specific layout setup:
// -i- like rendering our Universal Layout and App Providers

/* --- <ExpoRootLayout> ------------------------------------------------------------------------ */

export default function ExpoRootLayout() {
return (
<UniversalAppProviders>
<UniversalRootLayout>
<Stack
screenOptions={{
headerShown: false,
contentStyle: { backgroundColor: '#FFFFFF' },
animation: 'slide_from_right',
}}
/>
</UniversalRootLayout>
</UniversalAppProviders>
)
// Navigation
const expoContextRouter = useExpoContextRouter()

// Theme
const scheme = useColorScheme()

// -- Effects --

useEffect(() => {
// -i- Make nativewind dark mode work with Expo for Web
if (isWeb && typeof window !== 'undefined') {
const $html = document.querySelector('html')
const isDarkMode = scheme.colorScheme === 'dark'
$html?.classList.toggle('dark', isDarkMode)
}
}, [scheme.colorScheme])

// -- Render --

return (
<UniversalAppProviders
contextImage={ExpoContextImage}
contextLink={ExpoContextLink}
contextRouter={expoContextRouter}
useContextRouteParams={useExpoRouteParams}
isExpo
>
<UniversalRootLayout>
<Stack
screenOptions={{
headerShown: false,
contentStyle: { backgroundColor: '#FFFFFF' },
animation: 'slide_from_right',
}}
/>
</UniversalRootLayout>
</UniversalAppProviders>
)
}
1 change: 1 addition & 0 deletions apps/expo/app/_layout.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import ExpoRootLayout from './ExpoRootLayout'
import '../../next/global.css'

// -i- Expo Router's layout setup is much simpler than Next.js's layout setup.
// -i- Since Expo doesn't require a custom document setup or server component root layout.
Expand Down
6 changes: 4 additions & 2 deletions apps/expo/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// babel.config.js
module.exports = function (api) {
api.cache(true)
return {
presets: ["babel-preset-expo"],
presets: [
['babel-preset-expo', { jsxImportSource: 'nativewind' }],
'nativewind/babel',
],
}
}
5 changes: 3 additions & 2 deletions apps/expo/metro.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// -i- Copied from https://docs.expo.dev/guides/monorepos/#modify-the-metro-config
const { getDefaultConfig } = require('expo/metro-config')
const { withNativeWind } = require('nativewind/metro')
const path = require('path')

// Find the project and workspace directories
const projectRoot = __dirname
const workspaceRoot = path.resolve(projectRoot, '../..')
const config = getDefaultConfig(projectRoot)
const config = getDefaultConfig(projectRoot, { isCSSEnabled: true })

// 1. Watch all files within the monorepo
config.watchFolders = [workspaceRoot]
Expand All @@ -20,4 +21,4 @@ config.resolver.nodeModulesPaths = [
// config.resolver.disableHierarchicalLookup = true

// Export the modified config
module.exports = config
module.exports = withNativeWind(config, { input: '../next/global.css' })
16 changes: 8 additions & 8 deletions apps/expo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@
"private": true,
"main": "index.js",
"dependencies": {
"@expo/metro-runtime": "^3.2.1",
"expo": "^51.0.8",
"@expo/metro-runtime": "^3.2.3",
"expo": "^51.0.31",
"expo-constants": "~16.0.1",
"expo-image": "~1.12.15",
"expo-linking": "~6.3.1",
"expo-router": "~3.5.14",
"expo-router": "~3.5.23",
"expo-status-bar": "~1.12.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-native": "0.74.1",
"react-native-safe-area-context": "4.10.1",
"react-native": "0.74.5",
"react-native-safe-area-context": "4.10.5",
"react-native-screens": "~3.31.1",
"react-native-web": "~0.19.11",
"expo-image": "~1.12.9"
"react-native-web": "~0.19.11"
},
"devDependencies": {
"@babel/core": "^7.19.3",
"@expo/next-adapter": "^6.0.0",
"@types/react": "18.2.48",
"@types/react": "18.2.79",
"typescript": "5.3.3"
},
"scripts": {
Expand Down
16 changes: 16 additions & 0 deletions apps/expo/tailwind.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const { universalTheme } = require('@app/core/tailwind.theme.js')

/** @type {import('tailwindcss').Config} */
module.exports = {
darkMode: 'class',
content: [
'../../apps/**/*.{js,jsx,ts,tsx,md,mdx}',
'../../features/**/*.{js,jsx,ts,tsx,md,mdx}',
'../../packages/**/*.{js,jsx,ts,tsx,md,mdx}',
],
presets: [require('nativewind/preset')],
theme: {
...universalTheme,
},
plugins: [require('tailwindcss-animate')],
}
4 changes: 4 additions & 0 deletions apps/expo/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
"include": [
"**/*.ts",
"**/*.tsx",
"../../apps/next/next-env.d.ts",
"../../packages/@green-stack-core/global.d.ts",
"../../features/@app-core/nativewind-env.d.ts",
"../../features/@app-core/appConfig.ts",
"../../features/**/*.tsx",
"../../features/**/*.ts",
"../../packages/**/*.tsx",
Expand Down
45 changes: 45 additions & 0 deletions apps/next/.env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,49 @@
## --- Notes ----------------------------------------------------------------------------------- */

## -i- The `.env.example` file can be copied into `.env.local` using `npx turbo env:local`
## -i- For development, staging & production environments, check the next.js docs:
## -i- https://nextjs.org/docs/app/building-your-application/configuring/environment-variables

## -i- Note that you should treat environment variables as if they could be inlined in your bundle during builds & deployments
## -i- This means dynamically retrieving environment variables from e.g. `process.env[someKey]` might not work
## -i- It also means that you should never prefix with `NEXT_PUBLIC_` for sensitive / private keys

## -i- We suggest that for each environment variable you add here, you also add an entry in `appConfig.ts`
## -i- There, you can add logic like ```envValue: process.env.NEXT_PUBLIC_ENV_KEY || process.env.EXPO_PUBLIC_ENV_KEY```
## -i- Where you would only define the NEXT_PUBLIC_ prefixed versions here in `.env.local` locally and using Next.js UI for deployed envs
## -i- For environment variables you only be available server-side, you can omit `NEXT_PUBLIC_`

## --- General --------------------------------------------------------------------------------- */
## -i- Env vars that should always be present & the same locally, independent of the simulated environment
## --------------------------------------------------------------------------------------------- */

APP_SECRET="your-secret-here" # used for signing header context, generate a random string

NEXT_PUBLIC_BASE_URL=http://localhost:3000
NEXT_PUBLIC_BACKEND_URL=http://localhost:3000
NEXT_PUBLIC_API_URL=http://localhost:3000/api
NEXT_PUBLIC_GRAPH_URL=http://localhost:3000/api/graphql

## --- LOCAL ----------------------------------------------------------------------------------- */
## -i- Defaults you might want to switch out for local development by commenting / uncommenting
## --------------------------------------------------------------------------------------------- */

# DB_URL= # TODO: Add DB layer connection for full local dev...

## --- DEV ------------------------------------------------------------------------------------- */
# -i- Uncomment while on development branch to simulate the dev environment
## --------------------------------------------------------------------------------------------- */

# DB_URL= # TODO: Add DB layer connection for the dev environment...

## --- STAGE ----------------------------------------------------------------------------------- */
# -i- Uncomment while on staging branch to simulate the stage environment
## --------------------------------------------------------------------------------------------- */

# DB_URL= # TODO: Add DB layer connection for the stage environment...

## --- PROD ------------------------------------------------------------------------------------ */
# -i- Uncomment while on main branch to simulate the production environment
## --------------------------------------------------------------------------------------------- */

# DB_URL= # TODO: Add DB layer connection for the production environment...
2 changes: 2 additions & 0 deletions apps/next/app/(generated)/api/graphql/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// -i- Automatically generated by 'npx turbo @green-stack/core#link:routes', do not modify manually, it will get overwritten
export { GET, POST } from '@app/core/routes/api/graphql/route'
2 changes: 2 additions & 0 deletions apps/next/app/(generated)/api/health/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// -i- Automatically generated by 'npx turbo @green-stack/core#link:routes', do not modify manually, it will get overwritten
export { GET, POST } from '@app/core/routes/api/health/route'
2 changes: 2 additions & 0 deletions apps/next/app/(generated)/demos/forms/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
'use client'
export { default, dynamic } from '@app/core/routes/demos/forms/index'
2 changes: 2 additions & 0 deletions apps/next/app/(generated)/demos/images/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
'use client'
export { default } from '@app/core/routes/demos/images/index'
2 changes: 2 additions & 0 deletions apps/next/app/(generated)/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
'use client'
export { default } from '@app/core/routes/index'
2 changes: 2 additions & 0 deletions apps/next/app/(generated)/subpages/[slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
'use client'
export { default } from '@app/core/routes/subpages/[slug]/index'
31 changes: 0 additions & 31 deletions apps/next/app/(main)/api/health/route.ts

This file was deleted.

4 changes: 0 additions & 4 deletions apps/next/app/(main)/images/page.tsx

This file was deleted.

4 changes: 0 additions & 4 deletions apps/next/app/(main)/page.tsx

This file was deleted.

4 changes: 0 additions & 4 deletions apps/next/app/(main)/subpages/[slug]/page.tsx

This file was deleted.

Loading