@idealyst/cli 1.0.24 → 1.0.26

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 (48) hide show
  1. package/README.md +109 -109
  2. package/dist/index.js +233 -36
  3. package/dist/types/generators/api.d.ts +2 -0
  4. package/dist/types/generators/index.d.ts +1 -0
  5. package/dist/types/generators/utils.d.ts +18 -1
  6. package/dist/types/types.d.ts +2 -1
  7. package/package.json +1 -1
  8. package/templates/api/README.md +207 -0
  9. package/templates/api/env.example +12 -0
  10. package/templates/api/package.json +49 -0
  11. package/templates/api/prisma/schema.prisma +21 -0
  12. package/templates/api/src/context.ts +23 -0
  13. package/templates/api/src/controllers/UserController.ts +102 -0
  14. package/templates/api/src/index.ts +14 -0
  15. package/templates/api/src/lib/controller.ts +90 -0
  16. package/templates/api/src/lib/middleware.ts +170 -0
  17. package/templates/api/src/middleware/auth.ts +75 -0
  18. package/templates/api/src/middleware/common.ts +103 -0
  19. package/templates/api/src/router/index.ts +130 -0
  20. package/templates/api/src/server.ts +50 -0
  21. package/templates/api/src/trpc.ts +28 -0
  22. package/templates/api/tsconfig.json +44 -0
  23. package/templates/native/.yarnrc.yml +18 -18
  24. package/templates/native/App.tsx +23 -23
  25. package/templates/native/README.md +85 -85
  26. package/templates/native/app.json +4 -4
  27. package/templates/native/babel.config.js +9 -9
  28. package/templates/native/index.js +5 -5
  29. package/templates/native/metro.config.js +27 -27
  30. package/templates/native/package.json +9 -9
  31. package/templates/native/src/App-with-trpc.tsx +72 -0
  32. package/templates/native/src/utils/trpc.ts +127 -0
  33. package/templates/native/tsconfig.json +29 -29
  34. package/templates/shared/README.md +108 -108
  35. package/templates/shared/package.json +39 -39
  36. package/templates/shared/tsconfig.json +24 -24
  37. package/templates/web/README.md +89 -89
  38. package/templates/web/index.html +12 -12
  39. package/templates/web/package.json +55 -51
  40. package/templates/web/src/App-with-trpc.tsx +80 -0
  41. package/templates/web/src/App.tsx +14 -14
  42. package/templates/web/src/main.tsx +24 -24
  43. package/templates/web/src/utils/trpc.ts +93 -0
  44. package/templates/web/tsconfig.json +26 -26
  45. package/templates/web/vite.config.ts +68 -68
  46. package/templates/workspace/.yarnrc.yml +25 -25
  47. package/templates/workspace/README.md +79 -79
  48. package/templates/workspace/package.json +24 -24
@@ -0,0 +1,80 @@
1
+ import React from 'react';
2
+ import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
3
+ import { httpBatchLink } from '@trpc/client';
4
+ import { UnistylesRegistry } from 'react-native-unistyles';
5
+ import { BrowserRouter, Routes, Route } from 'react-router-dom';
6
+ import { trpc } from './utils/trpc';
7
+ import { Screen, Text, View } from '@idealyst/components';
8
+ import { breakpoints, lightTheme, darkTheme } from '@idealyst/theme';
9
+
10
+ // Register the Unistyles themes and breakpoints
11
+ UnistylesRegistry
12
+ .addBreakpoints(breakpoints)
13
+ .addThemes({
14
+ light: lightTheme,
15
+ dark: darkTheme,
16
+ })
17
+ .addConfig({
18
+ adaptiveThemes: true,
19
+ });
20
+
21
+ // Create tRPC client
22
+ const queryClient = new QueryClient();
23
+
24
+ const trpcClient = trpc.createClient({
25
+ links: [
26
+ httpBatchLink({
27
+ url: 'http://localhost:3000/trpc', // Update this to match your API URL
28
+ // Optional: Add headers for authentication
29
+ // headers() {
30
+ // return {
31
+ // authorization: getAuthToken(),
32
+ // };
33
+ // },
34
+ }),
35
+ ],
36
+ });
37
+
38
+ function HomePage() {
39
+ // Example tRPC usage
40
+ const { data, isLoading, error } = trpc.hello.useQuery({ name: 'World' });
41
+
42
+ return (
43
+ <Screen>
44
+ <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
45
+ <Text variant="h1">Welcome to {{projectName}}!</Text>
46
+ <Text variant="body">
47
+ This is a React Web app built with the Idealyst Framework
48
+ </Text>
49
+
50
+ {/* tRPC Example */}
51
+ <View style={{ marginTop: 20 }}>
52
+ <Text variant="h3">tRPC Example:</Text>
53
+ {isLoading && <Text>Loading...</Text>}
54
+ {error && <Text>Error: {error.message}</Text>}
55
+ {data && <Text>{data.greeting}</Text>}
56
+ </View>
57
+
58
+ <Text variant="caption" style={{ marginTop: 20 }}>
59
+ Edit src/App.tsx to get started
60
+ </Text>
61
+ </View>
62
+ </Screen>
63
+ );
64
+ }
65
+
66
+ function App() {
67
+ return (
68
+ <trpc.Provider client={trpcClient} queryClient={queryClient}>
69
+ <QueryClientProvider client={queryClient}>
70
+ <BrowserRouter>
71
+ <Routes>
72
+ <Route path="/" element={<HomePage />} />
73
+ </Routes>
74
+ </BrowserRouter>
75
+ </QueryClientProvider>
76
+ </trpc.Provider>
77
+ );
78
+ }
79
+
80
+ export default App;
@@ -1,15 +1,15 @@
1
- import { BrowserRouter } from 'react-router-dom';
2
- import { ExampleStackRouter, } from '@idealyst/navigation/examples';
3
- import { NavigatorProvider } from '@idealyst/navigation';
4
-
5
- function App() {
6
- return (
7
- <div className="App">
8
- <BrowserRouter>
9
- <NavigatorProvider route={ExampleStackRouter} />
10
- </BrowserRouter>
11
- </div>
12
- );
13
- }
14
-
1
+ import { BrowserRouter } from 'react-router-dom';
2
+ import { ExampleStackRouter, } from '@idealyst/navigation/examples';
3
+ import { NavigatorProvider } from '@idealyst/navigation';
4
+
5
+ function App() {
6
+ return (
7
+ <div className="App">
8
+ <BrowserRouter>
9
+ <NavigatorProvider route={ExampleStackRouter} />
10
+ </BrowserRouter>
11
+ </div>
12
+ );
13
+ }
14
+
15
15
  export default App;
@@ -1,25 +1,25 @@
1
- import '@idealyst/navigation/examples/unistyles';
2
-
3
- import * as React from 'react';
4
- import ReactDOM from 'react-dom/client';
5
- import App from './App.tsx';
6
-
7
- // Hydrate the app if it's SSR, otherwise render normally
8
- const container = document.getElementById('root')!;
9
-
10
- if (container.hasChildNodes()) {
11
- // If the container has child nodes, it means we're hydrating SSR content
12
- ReactDOM.hydrateRoot(container,
13
- <React.StrictMode>
14
- <App />
15
- </React.StrictMode>
16
- );
17
- } else {
18
- // Otherwise, render normally (for development)
19
- const root = ReactDOM.createRoot(container);
20
- root.render(
21
- <React.StrictMode>
22
- <App />
23
- </React.StrictMode>
24
- );
1
+ import '@idealyst/navigation/examples/unistyles';
2
+
3
+ import * as React from 'react';
4
+ import ReactDOM from 'react-dom/client';
5
+ import App from './App.tsx';
6
+
7
+ // Hydrate the app if it's SSR, otherwise render normally
8
+ const container = document.getElementById('root')!;
9
+
10
+ if (container.hasChildNodes()) {
11
+ // If the container has child nodes, it means we're hydrating SSR content
12
+ ReactDOM.hydrateRoot(container,
13
+ <React.StrictMode>
14
+ <App />
15
+ </React.StrictMode>
16
+ );
17
+ } else {
18
+ // Otherwise, render normally (for development)
19
+ const root = ReactDOM.createRoot(container);
20
+ root.render(
21
+ <React.StrictMode>
22
+ <App />
23
+ </React.StrictMode>
24
+ );
25
25
  }
@@ -0,0 +1,93 @@
1
+ import { createTRPCReact } from '@trpc/react-query';
2
+ import { createTRPCProxyClient, httpBatchLink } from '@trpc/client';
3
+
4
+ // Import your API types here when you have an API project
5
+ // Example: import type { AppRouter } from '@your-workspace/api';
6
+
7
+ // For now, we'll use a generic type that you can replace
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
19
+ // headers() {
20
+ // return {
21
+ // authorization: getAuthToken(),
22
+ // };
23
+ // },
24
+ }),
25
+ ],
26
+ });
27
+
28
+ /*
29
+ Usage Examples:
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 { QueryClient, QueryClientProvider } from '@tanstack/react-query';
41
+ import { httpBatchLink } from '@trpc/client';
42
+ import { trpc } from './utils/trpc';
43
+
44
+ const queryClient = new QueryClient();
45
+
46
+ const trpcClient = trpc.createClient({
47
+ links: [
48
+ httpBatchLink({
49
+ url: 'http://localhost:3000/trpc',
50
+ }),
51
+ ],
52
+ });
53
+
54
+ function App() {
55
+ return (
56
+ <trpc.Provider client={trpcClient} queryClient={queryClient}>
57
+ <QueryClientProvider client={queryClient}>
58
+ {/* Your app components */}
59
+ </QueryClientProvider>
60
+ </trpc.Provider>
61
+ );
62
+ }
63
+ ```
64
+
65
+ 4. Use tRPC in your components:
66
+
67
+ ```tsx
68
+ import { trpc } from '../utils/trpc';
69
+
70
+ function UsersList() {
71
+ const { data: users, isLoading } = trpc.users.getAll.useQuery();
72
+ const createUser = trpc.users.create.useMutation();
73
+
74
+ if (isLoading) return <div>Loading...</div>;
75
+
76
+ return (
77
+ <div>
78
+ {users?.map(user => (
79
+ <div key={user.id}>{user.name}</div>
80
+ ))}
81
+ <button
82
+ onClick={() => createUser.mutate({
83
+ email: 'test@example.com',
84
+ name: 'Test User'
85
+ })}
86
+ >
87
+ Create User
88
+ </button>
89
+ </div>
90
+ );
91
+ }
92
+ ```
93
+ */
@@ -1,27 +1,27 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2020",
4
- "lib": ["ES2020", "DOM", "DOM.Iterable"],
5
- "module": "ESNext",
6
- "skipLibCheck": true,
7
- "moduleResolution": "node",
8
- "allowImportingTsExtensions": true,
9
- "isolatedModules": true,
10
- "moduleDetection": "force",
11
- "noEmit": true,
12
- "jsx": "react-jsx",
13
- "strict": true,
14
- "noUnusedLocals": true,
15
- "noUnusedParameters": true,
16
- "noFallthroughCasesInSwitch": true,
17
- "noUncheckedIndexedAccess": true,
18
- "baseUrl": ".",
19
- "paths": {
20
- "@/*": ["./src/*"],
21
- "react-native": ["node_modules/react-native-web"]
22
- },
23
- "types": ["vite/client"]
24
- },
25
- "include": ["src/**/*"],
26
- "exclude": ["node_modules", "dist"]
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "lib": ["ES2020", "DOM", "DOM.Iterable"],
5
+ "module": "ESNext",
6
+ "skipLibCheck": true,
7
+ "moduleResolution": "node",
8
+ "allowImportingTsExtensions": true,
9
+ "isolatedModules": true,
10
+ "moduleDetection": "force",
11
+ "noEmit": true,
12
+ "jsx": "react-jsx",
13
+ "strict": true,
14
+ "noUnusedLocals": true,
15
+ "noUnusedParameters": true,
16
+ "noFallthroughCasesInSwitch": true,
17
+ "noUncheckedIndexedAccess": true,
18
+ "baseUrl": ".",
19
+ "paths": {
20
+ "@/*": ["./src/*"],
21
+ "react-native": ["node_modules/react-native-web"]
22
+ },
23
+ "types": ["vite/client"]
24
+ },
25
+ "include": ["src/**/*"],
26
+ "exclude": ["node_modules", "dist"]
27
27
  }
@@ -1,69 +1,69 @@
1
- import { defineConfig } from 'vite'
2
- import react from '@vitejs/plugin-react'
3
- import babel from 'vite-plugin-babel'
4
- import path from 'path'
5
-
6
- // https://vitejs.dev/config/
7
- export default defineConfig({
8
- plugins: [
9
- babel({
10
- filter: (id) => id.includes('node_modules/@idealyst/') && /\.(js|jsx|ts|tsx)$/.test(id),
11
- babelConfig: {
12
- presets: [
13
- ['@babel/preset-typescript', {
14
- isTSX: true,
15
- allExtensions: true,
16
- }]
17
- ],
18
- plugins: [
19
- ['react-native-unistyles/plugin', {
20
- root: 'src',
21
- autoProcessPaths: ['@idealyst/components', '@idealyst/navigation', '@idealyst/theme'],
22
- }],
23
- ['@idealyst/components/plugin/web', { root: 'src' }]
24
- ]
25
- }
26
- }),
27
- // Then process everything else with React plugin
28
- react(),
29
- ],
30
- resolve: {
31
- alias: {
32
- // Use absolute path to resolve react-native-web properly
33
- 'react-native': path.resolve(__dirname, 'node_modules/react-native-web'),
34
- '@react-native/normalize-colors': path.resolve(__dirname, 'node_modules/@react-native/normalize-colors'),
35
- },
36
- // Platform-specific file resolution
37
- extensions: ['.web.tsx', '.web.ts', '.tsx', '.ts', '.js', '.jsx'],
38
- // Ensure proper resolution of package exports
39
- conditions: ['browser', 'import', 'module', 'default'],
40
- // Ensure workspace dependencies resolve properly
41
- preserveSymlinks: false
42
- },
43
- define: {
44
- global: 'globalThis',
45
- __DEV__: JSON.stringify(true),
46
- },
47
- optimizeDeps: {
48
- include: [
49
- 'react-native-web',
50
- '@react-native/normalize-colors',
51
- 'react-native-unistyles',
52
- 'react-native-unistyles/web',
53
- '@mdi/react',
54
- '@mdi/js',
55
- ],
56
- exclude: [
57
- 'react-native-edge-to-edge',
58
- 'react-native-nitro-modules',
59
- '@idealyst/components',
60
- '@idealyst/navigation',
61
- '@idealyst/theme',
62
- '@testproject/shared',
63
- ],
64
- },
65
- server: {
66
- host: '0.0.0.0',
67
- port: 5173,
68
- },
1
+ import { defineConfig } from 'vite'
2
+ import react from '@vitejs/plugin-react'
3
+ import babel from 'vite-plugin-babel'
4
+ import path from 'path'
5
+
6
+ // https://vitejs.dev/config/
7
+ export default defineConfig({
8
+ plugins: [
9
+ babel({
10
+ filter: (id) => id.includes('node_modules/@idealyst/') && /\.(js|jsx|ts|tsx)$/.test(id),
11
+ babelConfig: {
12
+ presets: [
13
+ ['@babel/preset-typescript', {
14
+ isTSX: true,
15
+ allExtensions: true,
16
+ }]
17
+ ],
18
+ plugins: [
19
+ ['react-native-unistyles/plugin', {
20
+ root: 'src',
21
+ autoProcessPaths: ['@idealyst/components', '@idealyst/navigation', '@idealyst/theme'],
22
+ }],
23
+ ['@idealyst/components/plugin/web', { root: 'src' }]
24
+ ]
25
+ }
26
+ }),
27
+ // Then process everything else with React plugin
28
+ react(),
29
+ ],
30
+ resolve: {
31
+ alias: {
32
+ // Use absolute path to resolve react-native-web properly
33
+ 'react-native': path.resolve(__dirname, 'node_modules/react-native-web'),
34
+ '@react-native/normalize-colors': path.resolve(__dirname, 'node_modules/@react-native/normalize-colors'),
35
+ },
36
+ // Platform-specific file resolution
37
+ extensions: ['.web.tsx', '.web.ts', '.tsx', '.ts', '.js', '.jsx'],
38
+ // Ensure proper resolution of package exports
39
+ conditions: ['browser', 'import', 'module', 'default'],
40
+ // Ensure workspace dependencies resolve properly
41
+ preserveSymlinks: false
42
+ },
43
+ define: {
44
+ global: 'globalThis',
45
+ __DEV__: JSON.stringify(true),
46
+ },
47
+ optimizeDeps: {
48
+ include: [
49
+ 'react-native-web',
50
+ '@react-native/normalize-colors',
51
+ 'react-native-unistyles',
52
+ 'react-native-unistyles/web',
53
+ '@mdi/react',
54
+ '@mdi/js',
55
+ ],
56
+ exclude: [
57
+ 'react-native-edge-to-edge',
58
+ 'react-native-nitro-modules',
59
+ '@idealyst/components',
60
+ '@idealyst/navigation',
61
+ '@idealyst/theme',
62
+ '@testproject/shared',
63
+ ],
64
+ },
65
+ server: {
66
+ host: '0.0.0.0',
67
+ port: 5173,
68
+ },
69
69
  })
@@ -1,26 +1,26 @@
1
- nodeLinker: "node-modules"
2
-
3
- # Enable transparent workspaces for better workspace dependency resolution
4
- enableTransparentWorkspaces: true
5
-
6
- # Enable network for package downloads
7
- enableNetwork: true
8
-
9
- # Timeout for HTTP requests (in milliseconds)
10
- httpTimeout: 60000
11
-
12
- # Number of retry attempts for HTTP requests
13
- httpRetry: 3
14
-
15
- # Registry configuration
16
- npmRegistryServer: "https://registry.yarnpkg.com"
17
-
18
- # Enable progress bars
19
- enableProgressBars: true
20
-
21
- # Enable colors in output
22
- enableColors: true
23
-
24
- # Prevent hoisting to avoid React Native issues
25
- # This ensures React Native dependencies stay in their local node_modules
1
+ nodeLinker: "node-modules"
2
+
3
+ # Enable transparent workspaces for better workspace dependency resolution
4
+ enableTransparentWorkspaces: true
5
+
6
+ # Enable network for package downloads
7
+ enableNetwork: true
8
+
9
+ # Timeout for HTTP requests (in milliseconds)
10
+ httpTimeout: 60000
11
+
12
+ # Number of retry attempts for HTTP requests
13
+ httpRetry: 3
14
+
15
+ # Registry configuration
16
+ npmRegistryServer: "https://registry.yarnpkg.com"
17
+
18
+ # Enable progress bars
19
+ enableProgressBars: true
20
+
21
+ # Enable colors in output
22
+ enableColors: true
23
+
24
+ # Prevent hoisting to avoid React Native issues
25
+ # This ensures React Native dependencies stay in their local node_modules
26
26
  nmHoistingLimits: workspaces
@@ -1,80 +1,80 @@
1
- # {{projectName}}
2
-
3
- {{description}}
4
-
5
- ## Getting Started
6
-
7
- This workspace contains your Idealyst Framework packages and applications.
8
-
9
- ### Structure
10
-
11
- ```
12
- {{projectName}}/
13
- ├── packages/ # Shared packages
14
- │ ├── theme/ # Theme configuration
15
- │ ├── components/ # UI components
16
- │ └── utils/ # Shared utilities
17
- ├── mobile-app/ # React Native app (generated)
18
- ├── web-app/ # React web app (generated)
19
- └── shared-lib/ # Shared library (generated)
20
- ```
21
-
22
- ### Development
23
-
24
- Install dependencies:
25
- ```bash
26
- yarn install
27
- ```
28
-
29
- Build all packages:
30
- ```bash
31
- yarn build:all
32
- ```
33
-
34
- Test all packages:
35
- ```bash
36
- yarn test:all
37
- ```
38
-
39
- ### Adding Applications
40
-
41
- Generate a new React Native app:
42
- ```bash
43
- idealyst create mobile-app --type native
44
- ```
45
-
46
- Generate a new React web app:
47
- ```bash
48
- idealyst create web-app --type web
49
- ```
50
-
51
- Generate a new shared library:
52
- ```bash
53
- idealyst create shared-lib --type shared
54
- ```
55
-
56
- **Note:** The CLI will automatically add new projects to the workspace configuration when run from the workspace root.
57
-
58
- ### Publishing
59
-
60
- Publish all packages:
61
- ```bash
62
- yarn publish:all
63
- ```
64
-
65
- ### Version Management
66
-
67
- Update patch version for all packages:
68
- ```bash
69
- yarn version:patch
70
- ```
71
-
72
- Update minor version for all packages:
73
- ```bash
74
- yarn version:minor
75
- ```
76
-
77
- Update major version for all packages:
78
- ```bash
79
- yarn version:major
1
+ # {{projectName}}
2
+
3
+ {{description}}
4
+
5
+ ## Getting Started
6
+
7
+ This workspace contains your Idealyst Framework packages and applications.
8
+
9
+ ### Structure
10
+
11
+ ```
12
+ {{projectName}}/
13
+ ├── packages/ # Shared packages
14
+ │ ├── theme/ # Theme configuration
15
+ │ ├── components/ # UI components
16
+ │ └── utils/ # Shared utilities
17
+ ├── mobile-app/ # React Native app (generated)
18
+ ├── web-app/ # React web app (generated)
19
+ └── shared-lib/ # Shared library (generated)
20
+ ```
21
+
22
+ ### Development
23
+
24
+ Install dependencies:
25
+ ```bash
26
+ yarn install
27
+ ```
28
+
29
+ Build all packages:
30
+ ```bash
31
+ yarn build:all
32
+ ```
33
+
34
+ Test all packages:
35
+ ```bash
36
+ yarn test:all
37
+ ```
38
+
39
+ ### Adding Applications
40
+
41
+ Generate a new React Native app:
42
+ ```bash
43
+ idealyst create mobile-app --type native
44
+ ```
45
+
46
+ Generate a new React web app:
47
+ ```bash
48
+ idealyst create web-app --type web
49
+ ```
50
+
51
+ Generate a new shared library:
52
+ ```bash
53
+ idealyst create shared-lib --type shared
54
+ ```
55
+
56
+ **Note:** The CLI will automatically add new projects to the workspace configuration when run from the workspace root.
57
+
58
+ ### Publishing
59
+
60
+ Publish all packages:
61
+ ```bash
62
+ yarn publish:all
63
+ ```
64
+
65
+ ### Version Management
66
+
67
+ Update patch version for all packages:
68
+ ```bash
69
+ yarn version:patch
70
+ ```
71
+
72
+ Update minor version for all packages:
73
+ ```bash
74
+ yarn version:minor
75
+ ```
76
+
77
+ Update major version for all packages:
78
+ ```bash
79
+ yarn version:major
80
80
  ```