@idealyst/cli 1.0.52 → 1.0.54

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.
Files changed (31) hide show
  1. package/dist/generators/fullstack.js +0 -11
  2. package/dist/generators/fullstack.js.map +1 -1
  3. package/dist/generators/utils.js +3 -2
  4. package/dist/generators/utils.js.map +1 -1
  5. package/dist/templates/native/src/App-with-trpc-and-shared.tsx +36 -0
  6. package/dist/templates/native/src/App-with-trpc.tsx +3 -26
  7. package/dist/templates/native/src/App.tsx +5 -10
  8. package/dist/templates/native/src/navigation/AppRouter.tsx +121 -0
  9. package/dist/templates/shared/src/index.ts +3 -0
  10. package/dist/templates/shared/src/navigation/AppRouter.tsx +93 -0
  11. package/dist/templates/web/src/App-with-trpc-and-shared.tsx +32 -10
  12. package/dist/templates/web/src/App-with-trpc.tsx +4 -33
  13. package/dist/templates/web/src/App.tsx +2 -2
  14. package/dist/templates/web/src/navigation/AppRouter.tsx +121 -0
  15. package/dist/templates/web/src/navigation/AppRouterWithTrpc.tsx +117 -0
  16. package/dist/templates/web/vite.config.ts +10 -2
  17. package/package.json +1 -1
  18. package/templates/native/src/App-with-trpc-and-shared.tsx +31 -0
  19. package/templates/native/src/App-with-trpc.tsx +14 -42
  20. package/templates/native/src/App.tsx +5 -10
  21. package/templates/native/src/navigation/AppRouter.tsx +121 -0
  22. package/templates/shared/package.json +2 -1
  23. package/templates/shared/src/index.ts +3 -0
  24. package/templates/shared/src/navigation/AppRouter.tsx +93 -0
  25. package/templates/shared/src/trpc/client.ts +12 -7
  26. package/templates/web/src/App-with-trpc-and-shared.tsx +27 -10
  27. package/templates/web/src/App-with-trpc.tsx +14 -48
  28. package/templates/web/src/App.tsx +2 -2
  29. package/templates/web/src/navigation/AppRouter.tsx +121 -0
  30. package/templates/web/src/navigation/AppRouterWithTrpc.tsx +117 -0
  31. package/templates/web/vite.config.ts +10 -2
@@ -1,16 +1,33 @@
1
1
  import React from 'react';
2
- import { App } from '@{{workspaceScope}}/shared';
2
+ import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
3
+ import { BrowserRouter } from 'react-router-dom';
4
+ import { NavigatorProvider } from '@idealyst/navigation';
5
+ import { trpc, createTRPCClient } from './utils/trpc';
6
+ import { AppRouter } from '@{{workspaceScope}}/shared';
3
7
 
4
- // Main App component using shared App wrapper
5
- function AppWithTrpcAndShared() {
8
+ // Create tRPC client using shared factory
9
+ const queryClient = new QueryClient();
10
+
11
+ const trpcClient = createTRPCClient({
12
+ apiUrl: 'http://localhost:3000/trpc', // Update this to match your API URL
13
+ // Optional: Add headers for authentication
14
+ // headers() {
15
+ // return {
16
+ // authorization: getAuthToken(),
17
+ // };
18
+ // },
19
+ });
20
+
21
+ function App() {
6
22
  return (
7
- <App
8
- apiUrl="http://localhost:3000/trpc"
9
- name="{{projectName}} Developer"
10
- platform="web"
11
- projectName="{{projectName}}"
12
- />
23
+ <trpc.Provider client={trpcClient} queryClient={queryClient}>
24
+ <QueryClientProvider client={queryClient}>
25
+ <BrowserRouter>
26
+ <NavigatorProvider route={AppRouter} />
27
+ </BrowserRouter>
28
+ </QueryClientProvider>
29
+ </trpc.Provider>
13
30
  );
14
31
  }
15
32
 
16
- export default AppWithTrpcAndShared;
33
+ export default App;
@@ -1,63 +1,29 @@
1
1
  import React from 'react';
2
2
  import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
3
- import { httpBatchLink } from '@trpc/client';
4
- import { BrowserRouter, Routes, Route } from 'react-router-dom';
5
- import { trpc } from './utils/trpc';
6
- import { Screen, Text, View } from '@idealyst/components';
3
+ import { BrowserRouter } from 'react-router-dom';
4
+ import { NavigatorProvider } from '@idealyst/navigation';
5
+ import { trpc, createTRPCClient } from './utils/trpc';
6
+ import AppRouterWithTrpc from './navigation/AppRouterWithTrpc';
7
7
 
8
- // Create tRPC client
8
+ // Create tRPC client using shared factory
9
9
  const queryClient = new QueryClient();
10
10
 
11
- const trpcClient = trpc.createClient({
12
- links: [
13
- httpBatchLink({
14
- url: 'http://localhost:3000/trpc', // Update this to match your API URL
15
- // Optional: Add headers for authentication
16
- // headers() {
17
- // return {
18
- // authorization: getAuthToken(),
19
- // };
20
- // },
21
- }),
22
- ],
11
+ const trpcClient = createTRPCClient({
12
+ apiUrl: 'http://localhost:3000/trpc', // Update this to match your API URL
13
+ // Optional: Add headers for authentication
14
+ // headers() {
15
+ // return {
16
+ // authorization: getAuthToken(),
17
+ // };
18
+ // },
23
19
  });
24
20
 
25
- function HomePage() {
26
- // Example tRPC usage
27
- const { data, isLoading, error } = trpc.hello.useQuery({ name: 'World' });
28
-
29
- return (
30
- <Screen>
31
- <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
32
- <Text variant="h1">Welcome to {{projectName}}!</Text>
33
- <Text variant="body">
34
- This is a React Web app built with the Idealyst Framework
35
- </Text>
36
-
37
- {/* tRPC Example */}
38
- <View style={{ marginTop: 20 }}>
39
- <Text variant="h3">tRPC Example:</Text>
40
- {isLoading && <Text>Loading...</Text>}
41
- {error && <Text>Error: {error.message}</Text>}
42
- {data && <Text>{data.greeting}</Text>}
43
- </View>
44
-
45
- <Text variant="caption" style={{ marginTop: 20 }}>
46
- Edit src/App.tsx to get started
47
- </Text>
48
- </View>
49
- </Screen>
50
- );
51
- }
52
-
53
21
  function App() {
54
22
  return (
55
23
  <trpc.Provider client={trpcClient} queryClient={queryClient}>
56
24
  <QueryClientProvider client={queryClient}>
57
25
  <BrowserRouter>
58
- <Routes>
59
- <Route path="/" element={<HomePage />} />
60
- </Routes>
26
+ <NavigatorProvider route={AppRouterWithTrpc} />
61
27
  </BrowserRouter>
62
28
  </QueryClientProvider>
63
29
  </trpc.Provider>
@@ -1,12 +1,12 @@
1
1
  import { BrowserRouter } from 'react-router-dom';
2
- import { ExampleStackRouter, } from '@idealyst/navigation/examples';
3
2
  import { NavigatorProvider } from '@idealyst/navigation';
3
+ import AppRouter from './navigation/AppRouter';
4
4
 
5
5
  function App() {
6
6
  return (
7
7
  <div className="App">
8
8
  <BrowserRouter>
9
- <NavigatorProvider route={ExampleStackRouter} />
9
+ <NavigatorProvider route={AppRouter} />
10
10
  </BrowserRouter>
11
11
  </div>
12
12
  );
@@ -0,0 +1,121 @@
1
+ import React from 'react';
2
+ import { RouteParam } from '@idealyst/navigation';
3
+ import { Screen, Text, View, Icon } from '@idealyst/components';
4
+
5
+ // Simple API test component for web-only projects
6
+ const ApiTest = () => {
7
+ const [result, setResult] = React.useState<string>('Click to test API');
8
+
9
+ const testApi = async () => {
10
+ try {
11
+ setResult('Testing...');
12
+ // Simple fetch test - replace with actual API endpoint
13
+ const response = await fetch('/api/test');
14
+ if (response.ok) {
15
+ setResult('✅ API connection successful!');
16
+ } else {
17
+ setResult('❌ API connection failed');
18
+ }
19
+ } catch (error) {
20
+ setResult('❌ API connection failed');
21
+ }
22
+ };
23
+
24
+ return (
25
+ <View spacing="sm">
26
+ <Text size="small">{result}</Text>
27
+ <button onClick={testApi} style={{ padding: '8px 16px', marginTop: '8px' }}>
28
+ Test API
29
+ </button>
30
+ </View>
31
+ );
32
+ };
33
+
34
+ const HomeScreen = () => (
35
+ <Screen>
36
+ <View spacing="lg">
37
+ <Text size="xlarge" weight="bold">Home</Text>
38
+ <Text size="medium">Welcome to your {{projectName}} app!</Text>
39
+ <View spacing="md" style={{ marginTop: 24 }}>
40
+ <Text size="small">
41
+ This app uses tab navigation. Navigate between tabs using the top bar or menu.
42
+ </Text>
43
+ </View>
44
+
45
+ {/* API Testing Component */}
46
+ <View spacing="md" style={{ marginTop: 32 }}>
47
+ <Text size="medium" weight="semibold">API Test</Text>
48
+ <ApiTest />
49
+ </View>
50
+ </View>
51
+ </Screen>
52
+ );
53
+
54
+ const ProfileScreen = () => (
55
+ <Screen>
56
+ <View spacing="lg">
57
+ <Text size="xlarge" weight="bold">Profile</Text>
58
+ <Text size="medium">User profile and account settings</Text>
59
+ <View spacing="md" style={{ marginTop: 24 }}>
60
+ <Text size="small">
61
+ Manage your account details and preferences here.
62
+ </Text>
63
+ </View>
64
+ </View>
65
+ </Screen>
66
+ );
67
+
68
+ const SettingsScreen = () => (
69
+ <Screen>
70
+ <View spacing="lg">
71
+ <Text size="xlarge" weight="bold">Settings</Text>
72
+ <Text size="medium">App configuration and preferences</Text>
73
+ <View spacing="md" style={{ marginTop: 24 }}>
74
+ <Text size="small">
75
+ Customize your app experience with various settings and options.
76
+ </Text>
77
+ </View>
78
+ </View>
79
+ </Screen>
80
+ );
81
+
82
+ const AppRouter: RouteParam = {
83
+ path: "/",
84
+ component: HomeScreen,
85
+ layout: {
86
+ type: "tab",
87
+ },
88
+ screenOptions: {
89
+ title: 'Home',
90
+ tabBarLabel: 'Home',
91
+ tabBarIcon: ({ focused, size }) => (
92
+ <Icon name="home" color={focused ? 'blue' : 'gray'} size={size || 24} />
93
+ ),
94
+ },
95
+ routes: [
96
+ {
97
+ path: "profile",
98
+ component: ProfileScreen,
99
+ screenOptions: {
100
+ title: 'Profile',
101
+ tabBarLabel: 'Profile',
102
+ tabBarIcon: ({ focused, size }) => (
103
+ <Icon name="account" color={focused ? 'blue' : 'gray'} size={size || 24} />
104
+ ),
105
+ },
106
+ },
107
+ {
108
+ path: "settings",
109
+ component: SettingsScreen,
110
+ screenOptions: {
111
+ title: 'Settings',
112
+ tabBarLabel: 'Settings',
113
+ tabBarIcon: ({ focused, size }) => (
114
+ <Icon name="cog" color={focused ? 'blue' : 'gray'} size={size || 24} />
115
+ ),
116
+ },
117
+ },
118
+ ],
119
+ };
120
+
121
+ export default AppRouter;
@@ -0,0 +1,117 @@
1
+ import React from 'react';
2
+ import { RouteParam } from '@idealyst/navigation';
3
+ import { Screen, Text, View, Icon, Button } from '@idealyst/components';
4
+ import { trpc } from '../utils/trpc';
5
+
6
+ const HomeScreen = () => {
7
+ // Example tRPC usage
8
+ const [name, setName] = React.useState('{{projectName}}');
9
+ const { data, isLoading, error, refetch } = trpc.hello.useQuery({ name });
10
+
11
+ return (
12
+ <Screen>
13
+ <View spacing="lg">
14
+ <Text size="xlarge" weight="bold">Home</Text>
15
+ <Text size="medium">Welcome to your {{projectName}} app!</Text>
16
+ <View spacing="md" style={{ marginTop: 24 }}>
17
+ <Text size="small">
18
+ This app uses tab navigation with tRPC integration. Navigate between tabs using the top bar or menu.
19
+ </Text>
20
+
21
+ {/* tRPC API Test */}
22
+ <View spacing="sm" style={{ marginTop: 20 }}>
23
+ <Text size="medium" weight="semibold">API Test (tRPC):</Text>
24
+ <View spacing="xs">
25
+ <input
26
+ type="text"
27
+ value={name}
28
+ onChange={(e) => setName(e.target.value)}
29
+ placeholder="Enter your name"
30
+ style={{ padding: '8px', border: '1px solid #ccc', borderRadius: '4px' }}
31
+ />
32
+ <Button variant="outlined" onPress={() => refetch()} size="small">
33
+ Test tRPC API
34
+ </Button>
35
+ </View>
36
+
37
+ {/* Results */}
38
+ <View style={{ marginTop: 12 }}>
39
+ {isLoading && <Text size="small">Loading...</Text>}
40
+ {error && <Text size="small" color="error">Error: {error.message}</Text>}
41
+ {data && <Text size="small">✅ {data.greeting}</Text>}
42
+ </View>
43
+ </View>
44
+ </View>
45
+ </View>
46
+ </Screen>
47
+ );
48
+ };
49
+
50
+ const ProfileScreen = () => (
51
+ <Screen>
52
+ <View spacing="lg">
53
+ <Text size="xlarge" weight="bold">Profile</Text>
54
+ <Text size="medium">User profile and account settings</Text>
55
+ <View spacing="md" style={{ marginTop: 24 }}>
56
+ <Text size="small">
57
+ Manage your account details and preferences here.
58
+ </Text>
59
+ </View>
60
+ </View>
61
+ </Screen>
62
+ );
63
+
64
+ const SettingsScreen = () => (
65
+ <Screen>
66
+ <View spacing="lg">
67
+ <Text size="xlarge" weight="bold">Settings</Text>
68
+ <Text size="medium">App configuration and preferences</Text>
69
+ <View spacing="md" style={{ marginTop: 24 }}>
70
+ <Text size="small">
71
+ Customize your app experience with various settings and options.
72
+ </Text>
73
+ </View>
74
+ </View>
75
+ </Screen>
76
+ );
77
+
78
+ const AppRouterWithTrpc: RouteParam = {
79
+ path: "/",
80
+ component: HomeScreen,
81
+ layout: {
82
+ type: "tab",
83
+ },
84
+ screenOptions: {
85
+ title: 'Home',
86
+ tabBarLabel: 'Home',
87
+ tabBarIcon: ({ focused, size }) => (
88
+ <Icon name="home" color={focused ? 'blue' : 'gray'} size={size || 24} />
89
+ ),
90
+ },
91
+ routes: [
92
+ {
93
+ path: "profile",
94
+ component: ProfileScreen,
95
+ screenOptions: {
96
+ title: 'Profile',
97
+ tabBarLabel: 'Profile',
98
+ tabBarIcon: ({ focused, size }) => (
99
+ <Icon name="account" color={focused ? 'blue' : 'gray'} size={size || 24} />
100
+ ),
101
+ },
102
+ },
103
+ {
104
+ path: "settings",
105
+ component: SettingsScreen,
106
+ screenOptions: {
107
+ title: 'Settings',
108
+ tabBarLabel: 'Settings',
109
+ tabBarIcon: ({ focused, size }) => (
110
+ <Icon name="cog" color={focused ? 'blue' : 'gray'} size={size || 24} />
111
+ ),
112
+ },
113
+ },
114
+ ],
115
+ };
116
+
117
+ export default AppRouterWithTrpc;
@@ -7,7 +7,7 @@ import path from 'path'
7
7
  export default defineConfig({
8
8
  plugins: [
9
9
  babel({
10
- filter: (id) => id.includes('node_modules/@idealyst/') && /\.(js|jsx|ts|tsx)$/.test(id),
10
+ filter: (id) => id.includes("node_modules/@idealyst/"),
11
11
  babelConfig: {
12
12
  presets: [
13
13
  ['@babel/preset-typescript', {
@@ -59,8 +59,16 @@ export default defineConfig({
59
59
  '@idealyst/components',
60
60
  '@idealyst/navigation',
61
61
  '@idealyst/theme',
62
- '@testproject/shared',
62
+ '@{{workspaceScope}}/shared',
63
63
  ],
64
+ esbuildOptions: {
65
+ loader: {
66
+ '.tsx': 'tsx',
67
+ '.ts': 'ts',
68
+ '.jsx': 'jsx',
69
+ '.js': 'jsx' // Important: treat .js files as JSX for React Native compatibility
70
+ }
71
+ }
64
72
  },
65
73
  server: {
66
74
  host: '0.0.0.0',