@idealyst/cli 1.0.45 → 1.0.46

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.
@@ -1,303 +1,11 @@
1
- import React, { useState } from 'react';
2
- import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
3
- import { httpBatchLink } from '@trpc/client';
4
- import { BrowserRouter, Routes, Route, Link } from 'react-router-dom';
5
- import { trpc } from './utils/trpc';
6
- import { Screen, Text, View, Button, ScrollView } from '@idealyst/components';
1
+ import React from 'react';
7
2
 
8
- // Import shared components and utilities
9
- import {
10
- UserCard,
11
- PostCard,
12
- LoadingSpinner,
13
- ErrorMessage,
14
- FeatureCard,
15
- DEMO_USERS,
16
- DEMO_POSTS,
17
- formatRelativeTime,
18
- type User,
19
- type Post,
20
- type PostWithAuthor
21
- } from '{{workspaceScope}}/shared';
3
+ // Import shared components
4
+ import { HelloWorld } from '@{{workspaceScope}}/shared';
22
5
 
23
- // Create tRPC client
24
- const queryClient = new QueryClient();
25
-
26
- const trpcClient = trpc.createClient({
27
- links: [
28
- httpBatchLink({
29
- url: 'http://localhost:3001/trpc', // Updated to match API port
30
- // Optional: Add headers for authentication
31
- // headers() {
32
- // return {
33
- // authorization: getAuthToken(),
34
- // };
35
- // },
36
- }),
37
- ],
38
- });
39
-
40
- // Navigation Component
41
- function Navigation() {
42
- return (
43
- <View style={{
44
- flexDirection: 'row',
45
- padding: 16,
46
- backgroundColor: '#f8f9fa',
47
- borderBottomWidth: 1,
48
- borderBottomColor: '#e9ecef'
49
- }}>
50
- <Text variant="h2" style={{ marginRight: 24 }}>{{projectName}}</Text>
51
- <View style={{ flexDirection: 'row', gap: 16 }}>
52
- <Link to="/" style={{ textDecoration: 'none' }}>
53
- <Text style={{ color: '#007bff' }}>Home</Text>
54
- </Link>
55
- <Link to="/users" style={{ textDecoration: 'none' }}>
56
- <Text style={{ color: '#007bff' }}>Users</Text>
57
- </Link>
58
- <Link to="/posts" style={{ textDecoration: 'none' }}>
59
- <Text style={{ color: '#007bff' }}>Posts</Text>
60
- </Link>
61
- </View>
62
- </View>
63
- );
64
- }
65
-
66
- // Home Page Component
67
- function HomePage() {
68
- // Example tRPC usage
69
- const { data: helloData, isLoading: helloLoading, error: helloError } = trpc.hello.useQuery({ name: 'Web User' });
70
- const { data: usersData, isLoading: usersLoading } = trpc.users.getAll.useQuery();
71
- const { data: postsData, isLoading: postsLoading } = trpc.posts.getAll.useQuery();
72
-
73
- return (
74
- <ScrollView style={{ flex: 1 }}>
75
- <View style={{ padding: 20 }}>
76
- {/* Welcome Section */}
77
- <View style={{ marginBottom: 32, textAlign: 'center' }}>
78
- <Text variant="h1" style={{ marginBottom: 16 }}>
79
- Welcome to {{projectName}}! 🚀
80
- </Text>
81
- <Text variant="body" style={{ marginBottom: 16, fontSize: 18 }}>
82
- A full-stack application built with the Idealyst Framework
83
- </Text>
84
-
85
- {/* tRPC Connection Test */}
86
- <View style={{
87
- padding: 16,
88
- backgroundColor: '#e3f2fd',
89
- borderRadius: 8,
90
- marginBottom: 24
91
- }}>
92
- <Text variant="h3" style={{ marginBottom: 8 }}>🔗 API Connection:</Text>
93
- {helloLoading && <Text>Testing connection...</Text>}
94
- {helloError && <Text style={{ color: 'red' }}>Error: {helloError.message}</Text>}
95
- {helloData && <Text style={{ color: 'green' }}>✅ {helloData.greeting}</Text>}
96
- </View>
97
- </View>
98
-
99
- {/* Features Overview */}
100
- <View style={{ marginBottom: 32 }}>
101
- <Text variant="h2" style={{ marginBottom: 16 }}>🏗️ Architecture Overview</Text>
102
- <View style={{ flexDirection: 'row', flexWrap: 'wrap', gap: 16 }}>
103
- <FeatureCard
104
- icon="🗄️"
105
- title="Database Layer"
106
- description="Prisma ORM with SQLite, user management, posts, and comments"
107
- />
108
- <FeatureCard
109
- icon="🚀"
110
- title="API Server"
111
- description="tRPC API with type-safe endpoints and real-time capabilities"
112
- />
113
- <FeatureCard
114
- icon="🌐"
115
- title="Web Application"
116
- description="React web app with Idealyst components and responsive design"
117
- />
118
- <FeatureCard
119
- icon="📱"
120
- title="Mobile App"
121
- description="React Native app with shared components and unified styling"
122
- />
123
- <FeatureCard
124
- icon="📦"
125
- title="Shared Library"
126
- description="Cross-platform components, utilities, and type definitions"
127
- />
128
- <FeatureCard
129
- icon="🔗"
130
- title="Full Integration"
131
- description="End-to-end type safety and unified development workflow"
132
- />
133
- </View>
134
- </View>
135
-
136
- {/* Live Data Preview */}
137
- <View style={{ marginBottom: 32 }}>
138
- <Text variant="h2" style={{ marginBottom: 16 }}>📊 Live Data Preview</Text>
139
-
140
- {/* Users Section */}
141
- <View style={{ marginBottom: 24 }}>
142
- <Text variant="h3" style={{ marginBottom: 12 }}>👥 Users ({usersLoading ? '...' : usersData?.length || DEMO_USERS.length})</Text>
143
- {usersLoading ? (
144
- <LoadingSpinner message="Loading users..." />
145
- ) : (
146
- <View style={{ flexDirection: 'row', flexWrap: 'wrap', gap: 12 }}>
147
- {(usersData || DEMO_USERS.slice(0, 3)).map((user: User) => (
148
- <View key={user.id} style={{ width: '300px' }}>
149
- <UserCard
150
- user={user}
151
- showBio={false}
152
- onPress={() => console.log('View profile:', user.name)}
153
- />
154
- </View>
155
- ))}
156
- </View>
157
- )}
158
- </View>
159
-
160
- {/* Posts Section */}
161
- <View style={{ marginBottom: 24 }}>
162
- <Text variant="h3" style={{ marginBottom: 12 }}>📝 Recent Posts ({postsLoading ? '...' : postsData?.length || DEMO_POSTS.length})</Text>
163
- {postsLoading ? (
164
- <LoadingSpinner message="Loading posts..." />
165
- ) : (
166
- <View>
167
- {(postsData || DEMO_POSTS.slice(0, 2)).map((post: Post) => {
168
- const author = DEMO_USERS.find(u => u.id === post.authorId);
169
- return (
170
- <PostCard
171
- key={post.id}
172
- post={post}
173
- author={author}
174
- onPress={() => console.log('Read post:', post.title)}
175
- onLike={() => console.log('Like post:', post.title)}
176
- />
177
- );
178
- })}
179
- </View>
180
- )}
181
- </View>
182
- </View>
183
-
184
- {/* Quick Start Section */}
185
- <View style={{
186
- padding: 20,
187
- backgroundColor: '#f8f9fa',
188
- borderRadius: 8,
189
- marginBottom: 24
190
- }}>
191
- <Text variant="h2" style={{ marginBottom: 16 }}>🚀 Quick Start</Text>
192
- <Text variant="body" style={{ marginBottom: 12 }}>
193
- Your full-stack workspace is ready! Here's what you can do:
194
- </Text>
195
- <View style={{ marginLeft: 16 }}>
196
- <Text style={{ marginBottom: 4 }}>• 🗄️ Add your models in <code>packages/database/schema.prisma</code></Text>
197
- <Text style={{ marginBottom: 4 }}>• 🚀 Create API endpoints in <code>packages/api/src/routers/</code></Text>
198
- <Text style={{ marginBottom: 4 }}>• 📦 Build shared components in <code>packages/shared/src/</code></Text>
199
- <Text style={{ marginBottom: 4 }}>• 🌐 Customize this web app in <code>packages/web/src/</code></Text>
200
- <Text style={{ marginBottom: 4 }}>• 📱 Update the mobile app in <code>packages/mobile/src/</code></Text>
201
- </View>
202
- </View>
203
-
204
- {/* Development Commands */}
205
- <View style={{
206
- padding: 20,
207
- backgroundColor: '#e8f5e8',
208
- borderRadius: 8,
209
- marginBottom: 24
210
- }}>
211
- <Text variant="h3" style={{ marginBottom: 12 }}>💻 Development Commands</Text>
212
- <View style={{ fontFamily: 'monospace', fontSize: 14 }}>
213
- <Text style={{ marginBottom: 4 }}>yarn dev # Start all servers</Text>
214
- <Text style={{ marginBottom: 4 }}>yarn web:dev # Start web app only</Text>
215
- <Text style={{ marginBottom: 4 }}>yarn mobile:start # Start mobile bundler</Text>
216
- <Text style={{ marginBottom: 4 }}>yarn api:dev # Start API server only</Text>
217
- <Text style={{ marginBottom: 4 }}>yarn db:push # Update database schema</Text>
218
- <Text style={{ marginBottom: 4 }}>yarn db:studio # Open database admin</Text>
219
- </View>
220
- </View>
221
- </View>
222
- </ScrollView>
223
- );
224
- }
225
-
226
- // Users Page Component
227
- function UsersPage() {
228
- const { data: users, isLoading, error } = trpc.users.getAll.useQuery();
229
-
230
- if (isLoading) return <LoadingSpinner message="Loading users..." />;
231
- if (error) return <ErrorMessage message={error.message} />;
232
-
233
- const allUsers = users || DEMO_USERS;
234
-
235
- return (
236
- <ScrollView style={{ flex: 1, padding: 20 }}>
237
- <Text variant="h1" style={{ marginBottom: 20 }}>👥 Users ({allUsers.length})</Text>
238
- <View style={{ flexDirection: 'row', flexWrap: 'wrap', gap: 16 }}>
239
- {allUsers.map((user: User) => (
240
- <View key={user.id} style={{ width: '400px' }}>
241
- <UserCard
242
- user={user}
243
- showBio={true}
244
- onPress={() => console.log('View profile:', user.name)}
245
- />
246
- </View>
247
- ))}
248
- </View>
249
- </ScrollView>
250
- );
251
- }
252
-
253
- // Posts Page Component
254
- function PostsPage() {
255
- const { data: posts, isLoading, error } = trpc.posts.getAll.useQuery();
256
-
257
- if (isLoading) return <LoadingSpinner message="Loading posts..." />;
258
- if (error) return <ErrorMessage message={error.message} />;
259
-
260
- const allPosts = posts || DEMO_POSTS;
261
-
262
- return (
263
- <ScrollView style={{ flex: 1, padding: 20 }}>
264
- <Text variant="h1" style={{ marginBottom: 20 }}>📝 Posts ({allPosts.length})</Text>
265
- <View>
266
- {allPosts.map((post: Post) => {
267
- const author = DEMO_USERS.find(u => u.id === post.authorId);
268
- return (
269
- <PostCard
270
- key={post.id}
271
- post={post}
272
- author={author}
273
- showFullContent={false}
274
- onPress={() => console.log('Read post:', post.title)}
275
- onLike={() => console.log('Like post:', post.title)}
276
- />
277
- );
278
- })}
279
- </View>
280
- </ScrollView>
281
- );
282
- }
283
-
284
- // Main App Component
285
6
  function App() {
286
7
  return (
287
- <trpc.Provider client={trpcClient} queryClient={queryClient}>
288
- <QueryClientProvider client={queryClient}>
289
- <BrowserRouter>
290
- <Screen>
291
- <Navigation />
292
- <Routes>
293
- <Route path="/" element={<HomePage />} />
294
- <Route path="/users" element={<UsersPage />} />
295
- <Route path="/posts" element={<PostsPage />} />
296
- </Routes>
297
- </Screen>
298
- </BrowserRouter>
299
- </QueryClientProvider>
300
- </trpc.Provider>
8
+ <HelloWorld name="{{projectName}} Developer" platform="web" projectName="{{projectName}}" />
301
9
  );
302
10
  }
303
11
 
@@ -1,43 +0,0 @@
1
- const typescript = require('rollup-plugin-typescript2');
2
-
3
- module.exports = {
4
- input: 'src/index.ts',
5
- output: [
6
- {
7
- file: 'dist/index.js',
8
- format: 'cjs',
9
- exports: 'named',
10
- sourcemap: true,
11
- },
12
- {
13
- file: 'dist/index.esm.js',
14
- format: 'esm',
15
- exports: 'named',
16
- sourcemap: true,
17
- },
18
- ],
19
- plugins: [
20
- typescript({
21
- typescript: require('typescript'),
22
- tsconfig: './tsconfig.json',
23
- exclude: ['**/*.test.ts', '**/*.test.tsx', '**/*.native.ts', '**/*.native.tsx'],
24
- declaration: true,
25
- declarationDir: 'dist',
26
- rootDir: 'src',
27
- clean: true,
28
- }),
29
- ],
30
- external: [
31
- 'react',
32
- 'react-dom',
33
- 'react-native',
34
- 'react-native-unistyles',
35
- '@react-native/normalize-colors',
36
- 'react-native-edge-to-edge',
37
- 'react-native-nitro-modules',
38
- '@react-native-vector-icons/common',
39
- '@react-native-vector-icons/material-design-icons',
40
- '@mdi/js',
41
- '@mdi/react',
42
- ],
43
- };
@@ -1,148 +0,0 @@
1
- import { z } from 'zod';
2
-
3
- // User related schemas and types
4
- export const UserSchema = z.object({
5
- id: z.string(),
6
- email: z.string().email(),
7
- name: z.string().nullable(),
8
- avatar: z.string().url().nullable(),
9
- bio: z.string().nullable(),
10
- location: z.string().nullable(),
11
- website: z.string().url().nullable(),
12
- createdAt: z.date(),
13
- updatedAt: z.date(),
14
- });
15
-
16
- export const CreateUserSchema = z.object({
17
- email: z.string().email(),
18
- name: z.string().min(1, 'Name is required'),
19
- avatar: z.string().url().optional(),
20
- bio: z.string().optional(),
21
- location: z.string().optional(),
22
- website: z.string().url().optional(),
23
- });
24
-
25
- export const UpdateUserSchema = CreateUserSchema.partial();
26
-
27
- // Post related schemas and types
28
- export const PostSchema = z.object({
29
- id: z.string(),
30
- title: z.string(),
31
- content: z.string(),
32
- excerpt: z.string().nullable(),
33
- published: z.boolean(),
34
- tags: z.array(z.string()),
35
- authorId: z.string(),
36
- views: z.number(),
37
- likes: z.number(),
38
- createdAt: z.date(),
39
- updatedAt: z.date(),
40
- });
41
-
42
- export const CreatePostSchema = z.object({
43
- title: z.string().min(1, 'Title is required'),
44
- content: z.string().min(1, 'Content is required'),
45
- excerpt: z.string().optional(),
46
- published: z.boolean().default(false),
47
- tags: z.array(z.string()).default([]),
48
- });
49
-
50
- export const UpdatePostSchema = CreatePostSchema.partial();
51
-
52
- // Comment related schemas and types
53
- export const CommentSchema = z.object({
54
- id: z.string(),
55
- content: z.string(),
56
- authorId: z.string(),
57
- postId: z.string(),
58
- parentId: z.string().nullable(),
59
- createdAt: z.date(),
60
- updatedAt: z.date(),
61
- });
62
-
63
- export const CreateCommentSchema = z.object({
64
- content: z.string().min(1, 'Comment cannot be empty'),
65
- postId: z.string(),
66
- parentId: z.string().optional(),
67
- });
68
-
69
- // User settings schemas and types
70
- export const UserSettingsSchema = z.object({
71
- id: z.string(),
72
- theme: z.enum(['light', 'dark', 'auto']),
73
- notifications: z.boolean(),
74
- emailUpdates: z.boolean(),
75
- publicProfile: z.boolean(),
76
- userId: z.string(),
77
- createdAt: z.date(),
78
- updatedAt: z.date(),
79
- });
80
-
81
- export const UpdateUserSettingsSchema = z.object({
82
- theme: z.enum(['light', 'dark', 'auto']).optional(),
83
- notifications: z.boolean().optional(),
84
- emailUpdates: z.boolean().optional(),
85
- publicProfile: z.boolean().optional(),
86
- });
87
-
88
- // Inferred TypeScript types
89
- export type User = z.infer<typeof UserSchema>;
90
- export type CreateUser = z.infer<typeof CreateUserSchema>;
91
- export type UpdateUser = z.infer<typeof UpdateUserSchema>;
92
-
93
- export type Post = z.infer<typeof PostSchema>;
94
- export type CreatePost = z.infer<typeof CreatePostSchema>;
95
- export type UpdatePost = z.infer<typeof UpdatePostSchema>;
96
-
97
- export type Comment = z.infer<typeof CommentSchema>;
98
- export type CreateComment = z.infer<typeof CreateCommentSchema>;
99
-
100
- export type UserSettings = z.infer<typeof UserSettingsSchema>;
101
- export type UpdateUserSettings = z.infer<typeof UpdateUserSettingsSchema>;
102
-
103
- // Extended types with relations for UI components
104
- export type UserWithPosts = User & {
105
- posts: Post[];
106
- settings?: UserSettings;
107
- };
108
-
109
- export type PostWithAuthor = Post & {
110
- author: User;
111
- comments: CommentWithAuthor[];
112
- };
113
-
114
- export type CommentWithAuthor = Comment & {
115
- author: User;
116
- children?: CommentWithAuthor[];
117
- };
118
-
119
- // API Response types
120
- export type ApiResponse<T> = {
121
- data: T;
122
- success: boolean;
123
- message?: string;
124
- };
125
-
126
- export type PaginatedResponse<T> = ApiResponse<{
127
- items: T[];
128
- total: number;
129
- page: number;
130
- pageSize: number;
131
- hasMore: boolean;
132
- }>;
133
-
134
- // Common utility types
135
- export type Theme = 'light' | 'dark' | 'auto';
136
-
137
- export interface LoadingState {
138
- isLoading: boolean;
139
- error?: string;
140
- }
141
-
142
- export interface PaginationParams {
143
- page?: number;
144
- pageSize?: number;
145
- sortBy?: string;
146
- sortOrder?: 'asc' | 'desc';
147
- search?: string;
148
- }