@idealyst/cli 1.0.45 → 1.0.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/generators/fullstack.js +61 -3
- package/dist/generators/fullstack.js.map +1 -1
- package/dist/generators/native.js +12 -0
- package/dist/generators/native.js.map +1 -1
- package/dist/generators/utils.js +64 -31
- package/dist/generators/utils.js.map +1 -1
- package/dist/templates/api/README.md +207 -130
- package/dist/templates/api/package.json +5 -5
- package/dist/templates/api/src/controllers/TestController.ts +0 -0
- package/dist/templates/api/src/index.ts +2 -7
- package/dist/templates/api/src/lib/crud.ts +150 -0
- package/dist/templates/api/src/lib/database.ts +23 -0
- package/dist/templates/api/src/router/index.ts +104 -71
- package/dist/templates/api/src/routers/test.ts +59 -0
- package/dist/templates/api/src/routers/user.example.ts +83 -0
- package/dist/templates/api/src/server.ts +1 -1
- package/dist/templates/api/tsconfig.json +0 -1
- package/dist/templates/database/README.md +115 -1
- package/dist/templates/database/package.json +2 -0
- package/dist/templates/database/prisma/seed.ts +37 -1
- package/dist/templates/database/schema.prisma +11 -1
- package/dist/templates/native/index.js +1 -1
- package/dist/templates/native/metro.config.js +1 -1
- package/dist/templates/native/package.json +4 -0
- package/dist/templates/native/src/App.tsx +16 -0
- package/dist/templates/native/src/utils/trpc.ts +7 -127
- package/dist/templates/native/tsconfig.json +0 -2
- package/dist/templates/shared/README.md +31 -5
- package/dist/templates/shared/__tests__/shared.test.ts +17 -5
- package/dist/templates/shared/package.json +14 -30
- package/dist/templates/shared/src/components/App.tsx +57 -0
- package/dist/templates/shared/src/components/HelloWorld.tsx +307 -0
- package/dist/templates/shared/src/components/index.ts +1 -392
- package/dist/templates/shared/src/index.ts +9 -57
- package/dist/templates/shared/src/trpc/client.ts +39 -0
- package/dist/templates/shared/tsconfig.json +4 -7
- package/dist/templates/web/README.md +65 -8
- package/dist/templates/web/package.json +3 -3
- package/dist/templates/web/src/App-with-trpc-and-shared.tsx +11 -299
- package/dist/templates/web/src/components/TestDemo.tsx +164 -0
- package/dist/templates/web/src/utils/trpc.ts +7 -93
- package/dist/templates/web/tsconfig.json +0 -1
- package/dist/templates/workspace/.devcontainer/devcontainer.json +4 -9
- package/dist/templates/workspace/.devcontainer/docker-compose.yml +1 -2
- package/dist/templates/workspace/.devcontainer/setup.sh +1 -1
- package/dist/templates/workspace/.env.example +1 -1
- package/dist/templates/workspace/Dockerfile +4 -4
- package/dist/templates/workspace/docker/nginx/prod.conf +2 -2
- package/dist/templates/workspace/docker/nginx.conf +1 -1
- package/dist/templates/workspace/docker/prometheus/prometheus.yml +1 -1
- package/dist/templates/workspace/docker-compose.yml +4 -5
- package/dist/templates/workspace/tsconfig.json +0 -1
- package/package.json +1 -1
- package/templates/api/README.md +207 -130
- package/templates/api/package.json +5 -5
- package/templates/api/src/controllers/TestController.ts +0 -0
- package/templates/api/src/index.ts +2 -7
- package/templates/api/src/lib/crud.ts +150 -0
- package/templates/api/src/lib/database.ts +23 -0
- package/templates/api/src/router/index.ts +104 -71
- package/templates/api/src/routers/test.ts +59 -0
- package/templates/api/src/routers/user.example.ts +83 -0
- package/templates/api/src/server.ts +1 -1
- package/templates/api/tsconfig.json +0 -1
- package/templates/database/README.md +115 -1
- package/templates/database/package.json +2 -0
- package/templates/database/prisma/seed.ts +37 -1
- package/templates/database/schema.prisma +11 -1
- package/templates/native/index.js +1 -1
- package/templates/native/metro.config.js +1 -1
- package/templates/native/package.json +4 -0
- package/templates/native/src/App.tsx +16 -0
- package/templates/native/src/utils/trpc.ts +7 -127
- package/templates/native/tsconfig.json +0 -2
- package/templates/shared/README.md +31 -5
- package/templates/shared/__tests__/shared.test.ts +17 -5
- package/templates/shared/package.json +14 -30
- package/templates/shared/src/components/App.tsx +57 -0
- package/templates/shared/src/components/HelloWorld.tsx +307 -0
- package/templates/shared/src/components/index.ts +1 -392
- package/templates/shared/src/index.ts +9 -57
- package/templates/shared/src/trpc/client.ts +39 -0
- package/templates/shared/tsconfig.json +4 -7
- package/templates/web/README.md +65 -8
- package/templates/web/package.json +3 -3
- package/templates/web/src/App-with-trpc-and-shared.tsx +11 -299
- package/templates/web/src/components/TestDemo.tsx +164 -0
- package/templates/web/src/utils/trpc.ts +7 -93
- package/templates/web/tsconfig.json +0 -1
- package/templates/workspace/.devcontainer/devcontainer.json +4 -9
- package/templates/workspace/.devcontainer/docker-compose.yml +1 -2
- package/templates/workspace/.devcontainer/setup.sh +1 -1
- package/templates/workspace/.env.example +1 -1
- package/templates/workspace/Dockerfile +4 -4
- package/templates/workspace/docker/nginx/prod.conf +2 -2
- package/templates/workspace/docker/nginx.conf +1 -1
- package/templates/workspace/docker/prometheus/prometheus.yml +1 -1
- package/templates/workspace/docker-compose.yml +4 -5
- package/templates/workspace/tsconfig.json +0 -1
- package/dist/templates/api/src/controllers/UserController.ts +0 -102
- package/dist/templates/api/src/lib/controller.ts +0 -90
- package/dist/templates/api/src/lib/middleware.ts +0 -170
- package/dist/templates/api/src/middleware/auth.ts +0 -75
- package/dist/templates/api/src/middleware/common.ts +0 -103
- package/dist/templates/database/.env.example +0 -1
- package/dist/templates/native/App.tsx +0 -23
- package/dist/templates/native/src/App-with-trpc-and-shared.tsx +0 -266
- package/dist/templates/shared/rollup.config.js +0 -43
- package/dist/templates/shared/src/types/index.ts +0 -148
- package/dist/templates/shared/src/utils/index.ts +0 -278
- package/templates/api/src/controllers/UserController.ts +0 -102
- package/templates/api/src/lib/controller.ts +0 -90
- package/templates/api/src/lib/middleware.ts +0 -170
- package/templates/api/src/middleware/auth.ts +0 -75
- package/templates/api/src/middleware/common.ts +0 -103
- package/templates/database/.env.example +0 -1
- package/templates/native/App.tsx +0 -23
- package/templates/native/src/App-with-trpc-and-shared.tsx +0 -266
- package/templates/shared/rollup.config.js +0 -43
- package/templates/shared/src/types/index.ts +0 -148
- package/templates/shared/src/utils/index.ts +0 -278
|
@@ -1,127 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
type AppRouter = any;
|
|
9
|
-
|
|
10
|
-
// Create the tRPC React hooks
|
|
11
|
-
export const trpc = createTRPCReact<AppRouter>();
|
|
12
|
-
|
|
13
|
-
// Create a vanilla client (for use outside of React components)
|
|
14
|
-
export const trpcClient = createTRPCProxyClient<AppRouter>({
|
|
15
|
-
links: [
|
|
16
|
-
httpBatchLink({
|
|
17
|
-
url: 'http://localhost:3000/trpc', // Update this to match your API URL
|
|
18
|
-
// Optional: Add headers for authentication
|
|
19
|
-
// headers() {
|
|
20
|
-
// return {
|
|
21
|
-
// authorization: getAuthToken(),
|
|
22
|
-
// };
|
|
23
|
-
// },
|
|
24
|
-
}),
|
|
25
|
-
],
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
/*
|
|
29
|
-
Usage Examples for React Native:
|
|
30
|
-
|
|
31
|
-
1. First, install the required dependencies:
|
|
32
|
-
yarn add @trpc/client @trpc/react-query @tanstack/react-query
|
|
33
|
-
|
|
34
|
-
2. Replace the AppRouter type import above with your actual API router:
|
|
35
|
-
import type { AppRouter } from '@your-workspace/api';
|
|
36
|
-
|
|
37
|
-
3. Set up the tRPC provider in your App component:
|
|
38
|
-
|
|
39
|
-
```tsx
|
|
40
|
-
import React from 'react';
|
|
41
|
-
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
42
|
-
import { httpBatchLink } from '@trpc/client';
|
|
43
|
-
import { trpc } from './src/utils/trpc';
|
|
44
|
-
|
|
45
|
-
const queryClient = new QueryClient();
|
|
46
|
-
|
|
47
|
-
const trpcClient = trpc.createClient({
|
|
48
|
-
links: [
|
|
49
|
-
httpBatchLink({
|
|
50
|
-
url: 'http://localhost:3000/trpc', // Use your computer's IP for device testing
|
|
51
|
-
// For device testing, you might need: 'http://192.168.1.xxx:3000/trpc'
|
|
52
|
-
}),
|
|
53
|
-
],
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
function App() {
|
|
57
|
-
return (
|
|
58
|
-
<trpc.Provider client={trpcClient} queryClient={queryClient}>
|
|
59
|
-
<QueryClientProvider client={queryClient}>
|
|
60
|
-
// Your app components
|
|
61
|
-
</QueryClientProvider>
|
|
62
|
-
</trpc.Provider>
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export default App;
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
4. Use tRPC in your React Native components:
|
|
70
|
-
|
|
71
|
-
```tsx
|
|
72
|
-
import React from 'react';
|
|
73
|
-
import { View, Text, ScrollView, TouchableOpacity } from 'react-native';
|
|
74
|
-
import { trpc } from '../utils/trpc';
|
|
75
|
-
|
|
76
|
-
function UsersList() {
|
|
77
|
-
const { data: users, isLoading, refetch } = trpc.users.getAll.useQuery();
|
|
78
|
-
const createUser = trpc.users.create.useMutation({
|
|
79
|
-
onSuccess: () => {
|
|
80
|
-
refetch(); // Refresh the list after creating
|
|
81
|
-
},
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
if (isLoading) {
|
|
85
|
-
return (
|
|
86
|
-
<View>
|
|
87
|
-
<Text>Loading...</Text>
|
|
88
|
-
</View>
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
return (
|
|
93
|
-
<ScrollView>
|
|
94
|
-
{users?.map(user => (
|
|
95
|
-
<View key={user.id}>
|
|
96
|
-
<Text>{user.name}</Text>
|
|
97
|
-
<Text>{user.email}</Text>
|
|
98
|
-
</View>
|
|
99
|
-
))}
|
|
100
|
-
<TouchableOpacity
|
|
101
|
-
onPress={() => createUser.mutate({
|
|
102
|
-
email: 'test@example.com',
|
|
103
|
-
name: 'Test User'
|
|
104
|
-
})}
|
|
105
|
-
>
|
|
106
|
-
<Text>Create User</Text>
|
|
107
|
-
</TouchableOpacity>
|
|
108
|
-
</ScrollView>
|
|
109
|
-
);
|
|
110
|
-
}
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
5. For device testing, make sure to:
|
|
114
|
-
- Use your computer's IP address instead of localhost
|
|
115
|
-
- Ensure your API server is accessible from the device
|
|
116
|
-
- Consider using ngrok for external testing
|
|
117
|
-
|
|
118
|
-
6. Error handling example:
|
|
119
|
-
|
|
120
|
-
```tsx
|
|
121
|
-
const { data, error, isLoading } = trpc.users.getAll.useQuery();
|
|
122
|
-
|
|
123
|
-
if (error) {
|
|
124
|
-
return <Text>Error: {error.message}</Text>;
|
|
125
|
-
}
|
|
126
|
-
```
|
|
127
|
-
*/
|
|
1
|
+
// Import tRPC client utilities from shared package
|
|
2
|
+
export {
|
|
3
|
+
trpc,
|
|
4
|
+
createTRPCClient,
|
|
5
|
+
createVanillaTRPCClient
|
|
6
|
+
} from '@{{workspaceScope}}/shared';
|
|
7
|
+
export type { TRPCClientConfig, AppRouter } from '@{{workspaceScope}}/shared';
|
|
@@ -7,12 +7,10 @@
|
|
|
7
7
|
"isolatedModules": true,
|
|
8
8
|
"jsx": "react-native",
|
|
9
9
|
"lib": ["es2017"],
|
|
10
|
-
"moduleResolution": "node",
|
|
11
10
|
"noEmit": true,
|
|
12
11
|
"strict": true,
|
|
13
12
|
"target": "esnext",
|
|
14
13
|
"skipLibCheck": true,
|
|
15
|
-
"resolveJsonModule": true,
|
|
16
14
|
"baseUrl": "./",
|
|
17
15
|
"paths": {
|
|
18
16
|
"@/*": ["./src/*"]
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
## Getting Started
|
|
6
6
|
|
|
7
|
-
This is a shared library built with the Idealyst Framework that can be used across React Native and React web applications.
|
|
7
|
+
This is a shared component library built with the Idealyst Framework that can be used across React Native and React web applications. It exports source TypeScript files directly for seamless integration in monorepo setups.
|
|
8
8
|
|
|
9
9
|
### Prerequisites
|
|
10
10
|
|
|
@@ -20,14 +20,40 @@ yarn install
|
|
|
20
20
|
|
|
21
21
|
### Development
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
Run tests:
|
|
24
24
|
```bash
|
|
25
|
-
yarn
|
|
25
|
+
yarn test
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
Type checking:
|
|
29
29
|
```bash
|
|
30
|
-
yarn
|
|
30
|
+
yarn type-check
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Usage
|
|
34
|
+
|
|
35
|
+
Import the HelloWorld component in your React or React Native app:
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
import { HelloWorld } from '@{{workspaceName}}/shared';
|
|
39
|
+
|
|
40
|
+
function App() {
|
|
41
|
+
return <HelloWorld name="Developer" />;
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Component
|
|
46
|
+
|
|
47
|
+
### HelloWorld
|
|
48
|
+
|
|
49
|
+
A simple welcome component that works on both web and mobile platforms.
|
|
50
|
+
|
|
51
|
+
**Props:**
|
|
52
|
+
- `name?: string` - Name to display in the greeting (defaults to "World")
|
|
53
|
+
|
|
54
|
+
**Example:**
|
|
55
|
+
```typescript
|
|
56
|
+
<HelloWorld name="Alice" />
|
|
31
57
|
```
|
|
32
58
|
|
|
33
59
|
### Project Structure
|
|
@@ -1,10 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HelloWorld } from '../src/index';
|
|
2
2
|
|
|
3
3
|
describe('Shared Library', () => {
|
|
4
|
-
it('should export
|
|
5
|
-
expect(
|
|
6
|
-
expect(typeof
|
|
7
|
-
|
|
4
|
+
it('should export HelloWorld component', () => {
|
|
5
|
+
expect(HelloWorld).toBeDefined();
|
|
6
|
+
expect(typeof HelloWorld).toBe('function');
|
|
7
|
+
});
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
describe('HelloWorld Component', () => {
|
|
11
|
+
it('should be a React component', () => {
|
|
12
|
+
expect(HelloWorld).toBeDefined();
|
|
13
|
+
expect(typeof HelloWorld).toBe('function');
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it('should accept props', () => {
|
|
17
|
+
// Test that the component function exists and can be called
|
|
18
|
+
// Note: Full component testing would require a React testing environment
|
|
19
|
+
expect(() => HelloWorld({ name: 'Test' })).not.toThrow();
|
|
8
20
|
});
|
|
9
21
|
});
|
|
10
22
|
|
|
@@ -2,45 +2,29 @@
|
|
|
2
2
|
"name": "{{packageName}}",
|
|
3
3
|
"version": "{{version}}",
|
|
4
4
|
"description": "{{description}}",
|
|
5
|
-
"main": "
|
|
6
|
-
"module": "
|
|
7
|
-
"types": "
|
|
5
|
+
"main": "src/index.ts",
|
|
6
|
+
"module": "src/index.ts",
|
|
7
|
+
"types": "src/index.ts",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
|
-
"import": "./
|
|
11
|
-
"require": "./
|
|
12
|
-
"types": "./
|
|
13
|
-
},
|
|
14
|
-
"./types": {
|
|
15
|
-
"import": "./dist/types/index.js",
|
|
16
|
-
"require": "./dist/types/index.js",
|
|
17
|
-
"types": "./dist/types/index.d.ts"
|
|
18
|
-
},
|
|
19
|
-
"./components": {
|
|
20
|
-
"import": "./dist/components/index.js",
|
|
21
|
-
"require": "./dist/components/index.js",
|
|
22
|
-
"types": "./dist/components/index.d.ts"
|
|
23
|
-
},
|
|
24
|
-
"./utils": {
|
|
25
|
-
"import": "./dist/utils/index.js",
|
|
26
|
-
"require": "./dist/utils/index.js",
|
|
27
|
-
"types": "./dist/utils/index.d.ts"
|
|
10
|
+
"import": "./src/index.ts",
|
|
11
|
+
"require": "./src/index.ts",
|
|
12
|
+
"types": "./src/index.ts"
|
|
28
13
|
}
|
|
29
14
|
},
|
|
30
15
|
"scripts": {
|
|
31
|
-
"build": "tsc",
|
|
32
16
|
"test": "jest",
|
|
33
17
|
"test:watch": "jest --watch",
|
|
34
18
|
"test:coverage": "jest --coverage",
|
|
35
19
|
"type-check": "tsc --noEmit"
|
|
36
20
|
},
|
|
37
|
-
"dependencies": {
|
|
38
|
-
"zod": "^3.22.4"
|
|
39
|
-
},
|
|
40
21
|
"peerDependencies": {
|
|
41
22
|
"@idealyst/components": "^1.0.21",
|
|
42
|
-
"@idealyst/navigation": "^1.0.21",
|
|
43
23
|
"@idealyst/theme": "^1.0.21",
|
|
24
|
+
"@tanstack/react-query": "^5.83.0",
|
|
25
|
+
"@trpc/client": "^11.5.1",
|
|
26
|
+
"@trpc/react-query": "^11.5.1",
|
|
27
|
+
"@trpc/server": "^11.5.1",
|
|
44
28
|
"react": "^19.1.0",
|
|
45
29
|
"react-native": "^0.80.1"
|
|
46
30
|
},
|
|
@@ -51,18 +35,18 @@
|
|
|
51
35
|
},
|
|
52
36
|
"devDependencies": {
|
|
53
37
|
"@idealyst/components": "^1.0.21",
|
|
54
|
-
"@idealyst/navigation": "^1.0.21",
|
|
55
38
|
"@idealyst/theme": "^1.0.21",
|
|
39
|
+
"@tanstack/react-query": "^5.83.0",
|
|
40
|
+
"@trpc/client": "^11.5.1",
|
|
41
|
+
"@trpc/react-query": "^11.5.1",
|
|
42
|
+
"@trpc/server": "^11.5.1",
|
|
56
43
|
"@types/jest": "^29.5.12",
|
|
57
44
|
"@types/react": "^19.1.0",
|
|
58
45
|
"jest": "^29.7.0",
|
|
59
|
-
"react": "^19.1.0",
|
|
60
|
-
"react-native": "^0.80.1",
|
|
61
46
|
"ts-jest": "^29.1.2",
|
|
62
47
|
"typescript": "^5.0.0"
|
|
63
48
|
},
|
|
64
49
|
"files": [
|
|
65
|
-
"dist",
|
|
66
50
|
"src"
|
|
67
51
|
],
|
|
68
52
|
"keywords": [
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
3
|
+
import { trpc, createTRPCClient } from '../trpc/client';
|
|
4
|
+
import { HelloWorld } from './HelloWorld';
|
|
5
|
+
|
|
6
|
+
interface AppProps {
|
|
7
|
+
apiUrl?: string;
|
|
8
|
+
queryClient?: QueryClient;
|
|
9
|
+
headers?: () => Record<string, string>;
|
|
10
|
+
// HelloWorld component props
|
|
11
|
+
name?: string;
|
|
12
|
+
platform?: "web" | "mobile";
|
|
13
|
+
projectName?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Default query client instance
|
|
17
|
+
const defaultQueryClient = new QueryClient({
|
|
18
|
+
defaultOptions: {
|
|
19
|
+
queries: {
|
|
20
|
+
staleTime: 1000 * 60 * 5, // 5 minutes
|
|
21
|
+
cacheTime: 1000 * 60 * 10, // 10 minutes
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Unified App component that sets up tRPC and React Query providers
|
|
28
|
+
* and includes the HelloWorld component directly
|
|
29
|
+
*/
|
|
30
|
+
export const App: React.FC<AppProps> = ({
|
|
31
|
+
apiUrl = 'http://localhost:3000/trpc',
|
|
32
|
+
queryClient = defaultQueryClient,
|
|
33
|
+
headers,
|
|
34
|
+
name,
|
|
35
|
+
platform = "web",
|
|
36
|
+
projectName
|
|
37
|
+
}) => {
|
|
38
|
+
// Create tRPC client with the provided configuration
|
|
39
|
+
const trpcClient = createTRPCClient({
|
|
40
|
+
apiUrl,
|
|
41
|
+
headers,
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<trpc.Provider client={trpcClient} queryClient={queryClient}>
|
|
46
|
+
<QueryClientProvider client={queryClient}>
|
|
47
|
+
<HelloWorld
|
|
48
|
+
name={name}
|
|
49
|
+
platform={platform}
|
|
50
|
+
projectName={projectName}
|
|
51
|
+
/>
|
|
52
|
+
</QueryClientProvider>
|
|
53
|
+
</trpc.Provider>
|
|
54
|
+
);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export default App;
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
import { Button, Card, Input, Screen, Text, View } from "@idealyst/components";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { trpc } from "../trpc/client";
|
|
4
|
+
|
|
5
|
+
interface HelloWorldProps {
|
|
6
|
+
name?: string;
|
|
7
|
+
platform?: "web" | "mobile";
|
|
8
|
+
projectName?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const HelloWorld = ({
|
|
12
|
+
name = "World",
|
|
13
|
+
platform = "web",
|
|
14
|
+
projectName = "Your Project",
|
|
15
|
+
}: HelloWorldProps) => {
|
|
16
|
+
const [newTestName, setNewTestName] = useState("");
|
|
17
|
+
const [newTestMessage, setNewTestMessage] = useState("");
|
|
18
|
+
|
|
19
|
+
// Use tRPC hooks directly
|
|
20
|
+
const tests = trpc.test.getAll.useQuery({});
|
|
21
|
+
const createTestMutation = trpc.test.create.useMutation({
|
|
22
|
+
onSuccess: () => {
|
|
23
|
+
tests.refetch();
|
|
24
|
+
setNewTestName("");
|
|
25
|
+
setNewTestMessage("");
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
const deleteTestMutation = trpc.test.delete.useMutation({
|
|
29
|
+
onSuccess: () => {
|
|
30
|
+
tests.refetch();
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const handleCreateTest = async () => {
|
|
35
|
+
if (!newTestName || !newTestMessage) return;
|
|
36
|
+
|
|
37
|
+
await createTestMutation.mutateAsync({
|
|
38
|
+
name: newTestName,
|
|
39
|
+
message: newTestMessage,
|
|
40
|
+
status: "active",
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const handleDeleteTest = async (id: string) => {
|
|
45
|
+
await deleteTestMutation.mutateAsync({ id });
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const platformEmoji = platform === "mobile" ? "📱" : "🌐";
|
|
49
|
+
const platformText =
|
|
50
|
+
platform === "mobile"
|
|
51
|
+
? "Your mobile development environment is ready. This shared component works seamlessly across mobile and web platforms."
|
|
52
|
+
: "Your web development environment is ready. This shared component works seamlessly across web and mobile platforms.";
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<Screen style={{ flex: 1, padding: 20 }}>
|
|
56
|
+
<View style={{ maxWidth: 600, alignSelf: "center" }}>
|
|
57
|
+
<Text
|
|
58
|
+
size="xlarge"
|
|
59
|
+
weight="bold"
|
|
60
|
+
style={{
|
|
61
|
+
marginBottom: 16,
|
|
62
|
+
textAlign: "center",
|
|
63
|
+
color: "#1e293b",
|
|
64
|
+
}}
|
|
65
|
+
>
|
|
66
|
+
Welcome to {projectName}! {platformEmoji}
|
|
67
|
+
</Text>
|
|
68
|
+
|
|
69
|
+
<Text
|
|
70
|
+
size="large"
|
|
71
|
+
style={{
|
|
72
|
+
marginBottom: 32,
|
|
73
|
+
textAlign: "center",
|
|
74
|
+
color: "#64748b",
|
|
75
|
+
lineHeight: 24,
|
|
76
|
+
paddingHorizontal: 16,
|
|
77
|
+
}}
|
|
78
|
+
>
|
|
79
|
+
{platformText}
|
|
80
|
+
</Text>
|
|
81
|
+
{/* Framework Branding Card */}
|
|
82
|
+
<Card variant="elevated" padding="large" intent="primary">
|
|
83
|
+
<View style={{ alignItems: "center" }}>
|
|
84
|
+
<Text style={{ fontSize: 32, marginBottom: 16 }}>🚀</Text>
|
|
85
|
+
<Text
|
|
86
|
+
size="xlarge"
|
|
87
|
+
weight="bold"
|
|
88
|
+
style={{ marginBottom: 8, textAlign: "center" }}
|
|
89
|
+
>
|
|
90
|
+
Idealyst Framework
|
|
91
|
+
</Text>
|
|
92
|
+
<Text
|
|
93
|
+
size="medium"
|
|
94
|
+
style={{ marginBottom: 16, textAlign: "center" }}
|
|
95
|
+
>
|
|
96
|
+
Hello, {name}! Welcome to your cross-platform workspace.
|
|
97
|
+
</Text>
|
|
98
|
+
|
|
99
|
+
{/* Technology Tags */}
|
|
100
|
+
<View
|
|
101
|
+
style={{
|
|
102
|
+
flexDirection: "row",
|
|
103
|
+
flexWrap: "wrap",
|
|
104
|
+
justifyContent: "center",
|
|
105
|
+
gap: 8,
|
|
106
|
+
}}
|
|
107
|
+
>
|
|
108
|
+
<Card
|
|
109
|
+
variant="filled"
|
|
110
|
+
padding="small"
|
|
111
|
+
style={{ backgroundColor: "rgba(255, 255, 255, 0.2)" }}
|
|
112
|
+
>
|
|
113
|
+
<Text size="small" weight="semibold">
|
|
114
|
+
React
|
|
115
|
+
</Text>
|
|
116
|
+
</Card>
|
|
117
|
+
<Card
|
|
118
|
+
variant="filled"
|
|
119
|
+
padding="small"
|
|
120
|
+
style={{ backgroundColor: "rgba(255, 255, 255, 0.2)" }}
|
|
121
|
+
>
|
|
122
|
+
<Text size="small" weight="semibold">
|
|
123
|
+
TypeScript
|
|
124
|
+
</Text>
|
|
125
|
+
</Card>
|
|
126
|
+
<Card
|
|
127
|
+
variant="filled"
|
|
128
|
+
padding="small"
|
|
129
|
+
style={{ backgroundColor: "rgba(255, 255, 255, 0.2)" }}
|
|
130
|
+
>
|
|
131
|
+
<Text size="small" weight="semibold">
|
|
132
|
+
Cross-Platform
|
|
133
|
+
</Text>
|
|
134
|
+
</Card>
|
|
135
|
+
</View>
|
|
136
|
+
</View>
|
|
137
|
+
</Card>
|
|
138
|
+
|
|
139
|
+
{/* Quick Start Guide Card */}
|
|
140
|
+
<Card variant="outlined" padding="large" style={{ marginTop: 16 }}>
|
|
141
|
+
<Text size="large" weight="bold" style={{ marginBottom: 16 }}>
|
|
142
|
+
🎯 Quick Start Guide
|
|
143
|
+
</Text>
|
|
144
|
+
|
|
145
|
+
<View style={{ marginBottom: 16 }}>
|
|
146
|
+
<Text size="medium" weight="semibold" style={{ marginBottom: 8 }}>
|
|
147
|
+
Your Workspace Overview:
|
|
148
|
+
</Text>
|
|
149
|
+
<Text size="small" style={{ marginBottom: 4 }}>
|
|
150
|
+
• <Text weight="semibold">packages/web/</Text> - React web
|
|
151
|
+
application
|
|
152
|
+
</Text>
|
|
153
|
+
<Text size="small" style={{ marginBottom: 4 }}>
|
|
154
|
+
• <Text weight="semibold">packages/mobile/</Text> - React Native
|
|
155
|
+
mobile app
|
|
156
|
+
</Text>
|
|
157
|
+
<Text size="small" style={{ marginBottom: 4 }}>
|
|
158
|
+
• <Text weight="semibold">packages/shared/</Text> - Cross-platform
|
|
159
|
+
components
|
|
160
|
+
</Text>
|
|
161
|
+
<Text size="small" style={{ marginBottom: 4 }}>
|
|
162
|
+
• <Text weight="semibold">packages/api/</Text> - tRPC API server
|
|
163
|
+
</Text>
|
|
164
|
+
</View>
|
|
165
|
+
|
|
166
|
+
<View style={{ marginBottom: 16 }}>
|
|
167
|
+
<Text size="medium" weight="semibold" style={{ marginBottom: 8 }}>
|
|
168
|
+
Try Editing:
|
|
169
|
+
</Text>
|
|
170
|
+
<Text size="small" style={{ marginBottom: 4 }}>
|
|
171
|
+
1. Edit this component in{" "}
|
|
172
|
+
<Text weight="semibold">
|
|
173
|
+
packages/shared/src/components/HelloWorld.tsx
|
|
174
|
+
</Text>
|
|
175
|
+
</Text>
|
|
176
|
+
<Text size="small" style={{ marginBottom: 4 }}>
|
|
177
|
+
2. Watch changes appear in both web and mobile apps instantly!
|
|
178
|
+
</Text>
|
|
179
|
+
<Text size="small" style={{ marginBottom: 4 }}>
|
|
180
|
+
3. Run <Text weight="semibold">yarn dev</Text> to start all
|
|
181
|
+
development servers
|
|
182
|
+
</Text>
|
|
183
|
+
</View>
|
|
184
|
+
|
|
185
|
+
<Card variant="filled" intent="success" padding="medium">
|
|
186
|
+
<Text size="small" weight="semibold" style={{ marginBottom: 4 }}>
|
|
187
|
+
✨ Framework Features:
|
|
188
|
+
</Text>
|
|
189
|
+
<Text size="small">
|
|
190
|
+
Shared components • Type safety • Hot reload • Cross-platform
|
|
191
|
+
compatibility
|
|
192
|
+
</Text>
|
|
193
|
+
</Card>
|
|
194
|
+
</Card>
|
|
195
|
+
|
|
196
|
+
{/* API Testing Section */}
|
|
197
|
+
<Card variant="outlined" padding="large" style={{ marginTop: 16 }}>
|
|
198
|
+
<Text size="large" weight="bold" style={{ marginBottom: 16 }}>
|
|
199
|
+
🚀 API Demo - Database Integration
|
|
200
|
+
</Text>
|
|
201
|
+
<Text size="medium" style={{ marginBottom: 16, color: "#64748b" }}>
|
|
202
|
+
Test your full-stack integration! This section demonstrates
|
|
203
|
+
real-time database operations.
|
|
204
|
+
</Text>
|
|
205
|
+
|
|
206
|
+
{/* Create New Test Form */}
|
|
207
|
+
<Card
|
|
208
|
+
variant="filled"
|
|
209
|
+
padding="medium"
|
|
210
|
+
style={{ marginBottom: 16, backgroundColor: "#f8fafc" }}
|
|
211
|
+
>
|
|
212
|
+
<Text size="medium" weight="semibold" style={{ marginBottom: 12 }}>
|
|
213
|
+
Create New Test Entry
|
|
214
|
+
</Text>
|
|
215
|
+
|
|
216
|
+
<View style={{ gap: 12 }}>
|
|
217
|
+
<Input
|
|
218
|
+
placeholder="Test name"
|
|
219
|
+
value={newTestName}
|
|
220
|
+
onChangeText={setNewTestName}
|
|
221
|
+
/>
|
|
222
|
+
<Input
|
|
223
|
+
placeholder="Test message"
|
|
224
|
+
value={newTestMessage}
|
|
225
|
+
onChangeText={setNewTestMessage}
|
|
226
|
+
/>
|
|
227
|
+
<Button
|
|
228
|
+
onPress={handleCreateTest}
|
|
229
|
+
disabled={
|
|
230
|
+
!newTestName ||
|
|
231
|
+
!newTestMessage ||
|
|
232
|
+
createTestMutation.isLoading
|
|
233
|
+
}
|
|
234
|
+
style={{ alignSelf: "flex-start" }}
|
|
235
|
+
>
|
|
236
|
+
{createTestMutation.isLoading ? "Creating..." : "Create Test"}
|
|
237
|
+
</Button>
|
|
238
|
+
</View>
|
|
239
|
+
</Card>
|
|
240
|
+
|
|
241
|
+
{/* Tests List */}
|
|
242
|
+
<View>
|
|
243
|
+
<Text size="medium" weight="semibold" style={{ marginBottom: 12 }}>
|
|
244
|
+
Database Records ({tests.data?.length || 0})
|
|
245
|
+
</Text>
|
|
246
|
+
|
|
247
|
+
{tests.isLoading ? (
|
|
248
|
+
<Card variant="outlined" padding="medium">
|
|
249
|
+
<Text size="small" style={{ color: "#64748b" }}>
|
|
250
|
+
Loading tests...
|
|
251
|
+
</Text>
|
|
252
|
+
</Card>
|
|
253
|
+
) : tests.data?.length === 0 ? (
|
|
254
|
+
<Card variant="outlined" padding="medium">
|
|
255
|
+
<Text size="small" style={{ color: "#64748b" }}>
|
|
256
|
+
No tests found. Create one above!
|
|
257
|
+
</Text>
|
|
258
|
+
</Card>
|
|
259
|
+
) : (
|
|
260
|
+
<View style={{ gap: 8 }}>
|
|
261
|
+
{tests.data?.map((test: any) => (
|
|
262
|
+
<Card key={test.id} variant="outlined" padding="medium">
|
|
263
|
+
<View
|
|
264
|
+
style={{
|
|
265
|
+
flexDirection: "row",
|
|
266
|
+
justifyContent: "space-between",
|
|
267
|
+
alignItems: "center",
|
|
268
|
+
}}
|
|
269
|
+
>
|
|
270
|
+
<View style={{ flex: 1 }}>
|
|
271
|
+
<Text
|
|
272
|
+
size="small"
|
|
273
|
+
weight="semibold"
|
|
274
|
+
style={{ marginBottom: 4 }}
|
|
275
|
+
>
|
|
276
|
+
{test.name}
|
|
277
|
+
</Text>
|
|
278
|
+
<Text
|
|
279
|
+
size="small"
|
|
280
|
+
style={{ color: "#64748b", marginBottom: 4 }}
|
|
281
|
+
>
|
|
282
|
+
{test.message}
|
|
283
|
+
</Text>
|
|
284
|
+
<Text size="small" style={{ color: "#10b981" }}>
|
|
285
|
+
Status: {test.status} •{" "}
|
|
286
|
+
{new Date(test.createdAt).toLocaleDateString()}
|
|
287
|
+
</Text>
|
|
288
|
+
</View>
|
|
289
|
+
<Button
|
|
290
|
+
variant="destructive"
|
|
291
|
+
size="small"
|
|
292
|
+
onPress={() => handleDeleteTest(test.id)}
|
|
293
|
+
disabled={deleteTestMutation.isLoading}
|
|
294
|
+
>
|
|
295
|
+
Delete
|
|
296
|
+
</Button>
|
|
297
|
+
</View>
|
|
298
|
+
</Card>
|
|
299
|
+
))}
|
|
300
|
+
</View>
|
|
301
|
+
)}
|
|
302
|
+
</View>
|
|
303
|
+
</Card>
|
|
304
|
+
</View>
|
|
305
|
+
</Screen>
|
|
306
|
+
);
|
|
307
|
+
};
|