@idealyst/cli 1.0.88 → 1.0.90

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 (208) hide show
  1. package/dist/generators/index.js +3 -40
  2. package/dist/generators/index.js.map +1 -1
  3. package/dist/generators/init.js +273 -0
  4. package/dist/generators/init.js.map +1 -0
  5. package/dist/generators/utils.js +5 -0
  6. package/dist/generators/utils.js.map +1 -1
  7. package/dist/index.js +20 -202
  8. package/dist/index.js.map +1 -1
  9. package/dist/scripts/configure-react-native-monorepo.js +144 -0
  10. package/dist/scripts/configure-react-native-monorepo.js.map +1 -0
  11. package/dist/{templates/workspace → template}/README.md +66 -12
  12. package/dist/template/package.json +45 -0
  13. package/{templates → dist/template/packages}/api/package.json +3 -1
  14. package/{templates → dist/template/packages}/database/package.json +1 -1
  15. package/dist/{templates/native → template/packages/mobile}/babel.config.js +1 -0
  16. package/{templates/native → dist/template/packages/mobile}/metro.config.js +4 -4
  17. package/{templates/native → dist/template/packages/mobile}/package.json +5 -2
  18. package/{templates → dist/template/packages}/shared/package.json +2 -2
  19. package/{templates → dist/template/packages}/web/package.json +4 -1
  20. package/dist/types/generators/index.d.ts +1 -7
  21. package/dist/types/generators/init.d.ts +5 -0
  22. package/dist/types/scripts/configure-react-native-monorepo.d.ts +23 -0
  23. package/dist/types/types.d.ts +0 -4
  24. package/package.json +1 -1
  25. package/dist/generators/api.js +0 -31
  26. package/dist/generators/api.js.map +0 -1
  27. package/dist/generators/database.js +0 -31
  28. package/dist/generators/database.js.map +0 -1
  29. package/dist/generators/fullstack.js +0 -418
  30. package/dist/generators/fullstack.js.map +0 -1
  31. package/dist/generators/native.js +0 -112
  32. package/dist/generators/native.js.map +0 -1
  33. package/dist/generators/shared.js +0 -29
  34. package/dist/generators/shared.js.map +0 -1
  35. package/dist/generators/web.js +0 -45
  36. package/dist/generators/web.js.map +0 -1
  37. package/dist/generators/workspace.js +0 -83
  38. package/dist/generators/workspace.js.map +0 -1
  39. package/dist/templates/api/package.json +0 -54
  40. package/dist/templates/database/package.json +0 -49
  41. package/dist/templates/native/metro.config.js +0 -27
  42. package/dist/templates/native/package.json +0 -49
  43. package/dist/templates/native/src/App.tsx +0 -8
  44. package/dist/templates/shared/package.json +0 -62
  45. package/dist/templates/shared/src/components/App.tsx +0 -47
  46. package/dist/templates/shared/src/components/HelloWorld.tsx +0 -307
  47. package/dist/templates/shared/src/navigation/AppRouter.tsx +0 -98
  48. package/dist/templates/web/package.json +0 -66
  49. package/dist/templates/web/src/App.tsx +0 -14
  50. package/dist/templates/workspace/package.json +0 -35
  51. package/dist/types/generators/api.d.ts +0 -2
  52. package/dist/types/generators/database.d.ts +0 -2
  53. package/dist/types/generators/fullstack.d.ts +0 -2
  54. package/dist/types/generators/native.d.ts +0 -2
  55. package/dist/types/generators/shared.d.ts +0 -2
  56. package/dist/types/generators/web.d.ts +0 -2
  57. package/dist/types/generators/workspace.d.ts +0 -2
  58. package/templates/api/.env.example +0 -6
  59. package/templates/api/README.md +0 -274
  60. package/templates/api/__tests__/api.test.ts +0 -26
  61. package/templates/api/jest.config.js +0 -23
  62. package/templates/api/jest.setup.js +0 -9
  63. package/templates/api/src/context.ts +0 -19
  64. package/templates/api/src/controllers/TestController.ts +0 -0
  65. package/templates/api/src/index.ts +0 -9
  66. package/templates/api/src/lib/crud.ts +0 -150
  67. package/templates/api/src/lib/database.ts +0 -23
  68. package/templates/api/src/router/index.ts +0 -163
  69. package/templates/api/src/routers/test.ts +0 -59
  70. package/templates/api/src/routers/user.example.ts +0 -83
  71. package/templates/api/src/server.ts +0 -50
  72. package/templates/api/src/trpc.ts +0 -28
  73. package/templates/api/tsconfig.json +0 -43
  74. package/templates/database/README.md +0 -162
  75. package/templates/database/prisma/seed.ts +0 -64
  76. package/templates/database/schema.prisma +0 -107
  77. package/templates/database/src/index.ts +0 -15
  78. package/templates/database/src/validators.ts +0 -10
  79. package/templates/database/tsconfig.json +0 -18
  80. package/templates/native/README.md +0 -86
  81. package/templates/native/__tests__/App.test.tsx +0 -156
  82. package/templates/native/__tests__/components.test.tsx +0 -300
  83. package/templates/native/app.json +0 -5
  84. package/templates/native/babel.config.js +0 -10
  85. package/templates/native/index.js +0 -6
  86. package/templates/native/jest.config.js +0 -21
  87. package/templates/native/jest.setup.js +0 -12
  88. package/templates/native/src/App-with-trpc.tsx +0 -30
  89. package/templates/native/src/App.tsx +0 -8
  90. package/templates/native/src/utils/trpc.ts +0 -7
  91. package/templates/native/tsconfig.json +0 -28
  92. package/templates/shared/README.md +0 -135
  93. package/templates/shared/__tests__/shared.test.ts +0 -51
  94. package/templates/shared/jest.config.js +0 -22
  95. package/templates/shared/src/components/index.ts +0 -1
  96. package/templates/shared/src/index.ts +0 -14
  97. package/templates/shared/src/trpc/client.ts +0 -44
  98. package/templates/shared/tsconfig.json +0 -22
  99. package/templates/web/README.md +0 -131
  100. package/templates/web/__tests__/App.test.tsx +0 -342
  101. package/templates/web/__tests__/components.test.tsx +0 -564
  102. package/templates/web/index.html +0 -13
  103. package/templates/web/jest.config.js +0 -27
  104. package/templates/web/jest.setup.js +0 -24
  105. package/templates/web/src/App-with-trpc.tsx +0 -32
  106. package/templates/web/src/App.tsx +0 -14
  107. package/templates/web/src/components/TestDemo.tsx +0 -164
  108. package/templates/web/src/main.tsx +0 -25
  109. package/templates/web/src/utils/trpc.ts +0 -7
  110. package/templates/web/tsconfig.json +0 -26
  111. package/templates/web/vite.config.ts +0 -98
  112. package/templates/workspace/.devcontainer/Dockerfile +0 -26
  113. package/templates/workspace/.devcontainer/devcontainer.json +0 -113
  114. package/templates/workspace/.devcontainer/docker-compose.yml +0 -59
  115. package/templates/workspace/.devcontainer/figma-mcp.sh +0 -32
  116. package/templates/workspace/.devcontainer/setup.sh +0 -45
  117. package/templates/workspace/.dockerignore +0 -151
  118. package/templates/workspace/.env.example +0 -36
  119. package/templates/workspace/.env.production +0 -56
  120. package/templates/workspace/DOCKER.md +0 -0
  121. package/templates/workspace/Dockerfile +0 -111
  122. package/templates/workspace/README.md +0 -179
  123. package/templates/workspace/docker/nginx/prod.conf +0 -238
  124. package/templates/workspace/docker/nginx.conf +0 -131
  125. package/templates/workspace/docker/postgres/init.sql +0 -41
  126. package/templates/workspace/docker/prometheus/prometheus.yml +0 -52
  127. package/templates/workspace/docker-compose.prod.yml +0 -146
  128. package/templates/workspace/docker-compose.yml +0 -143
  129. package/templates/workspace/jest.config.js +0 -20
  130. package/templates/workspace/package.json +0 -38
  131. package/templates/workspace/setup.sh +0 -30
  132. package/templates/workspace/tsconfig.json +0 -31
  133. /package/dist/{templates/workspace → template}/.devcontainer/Dockerfile +0 -0
  134. /package/dist/{templates/workspace → template}/.devcontainer/devcontainer.json +0 -0
  135. /package/dist/{templates/workspace → template}/.devcontainer/docker-compose.yml +0 -0
  136. /package/dist/{templates/workspace → template}/.devcontainer/figma-mcp.sh +0 -0
  137. /package/dist/{templates/workspace → template}/.devcontainer/setup.sh +0 -0
  138. /package/dist/{templates/workspace → template}/.dockerignore +0 -0
  139. /package/dist/{templates/workspace → template}/.env.example +0 -0
  140. /package/dist/{templates/workspace → template}/DOCKER.md +0 -0
  141. /package/dist/{templates/workspace → template}/Dockerfile +0 -0
  142. /package/dist/{templates/workspace → template}/docker/nginx/prod.conf +0 -0
  143. /package/dist/{templates/workspace → template}/docker/nginx.conf +0 -0
  144. /package/dist/{templates/workspace → template}/docker/postgres/init.sql +0 -0
  145. /package/dist/{templates/workspace → template}/docker/prometheus/prometheus.yml +0 -0
  146. /package/dist/{templates/workspace → template}/docker-compose.prod.yml +0 -0
  147. /package/dist/{templates/workspace → template}/docker-compose.yml +0 -0
  148. /package/dist/{templates/workspace → template}/jest.config.js +0 -0
  149. /package/dist/{templates → template/packages}/api/.env.example +0 -0
  150. /package/dist/{templates → template/packages}/api/README.md +0 -0
  151. /package/dist/{templates → template/packages}/api/__tests__/api.test.ts +0 -0
  152. /package/dist/{templates → template/packages}/api/jest.config.js +0 -0
  153. /package/dist/{templates → template/packages}/api/jest.setup.js +0 -0
  154. /package/dist/{templates → template/packages}/api/src/context.ts +0 -0
  155. /package/dist/{templates → template/packages}/api/src/controllers/TestController.ts +0 -0
  156. /package/dist/{templates → template/packages}/api/src/index.ts +0 -0
  157. /package/dist/{templates → template/packages}/api/src/lib/crud.ts +0 -0
  158. /package/dist/{templates → template/packages}/api/src/lib/database.ts +0 -0
  159. /package/dist/{templates → template/packages}/api/src/router/index.ts +0 -0
  160. /package/dist/{templates → template/packages}/api/src/routers/test.ts +0 -0
  161. /package/dist/{templates → template/packages}/api/src/routers/user.example.ts +0 -0
  162. /package/dist/{templates → template/packages}/api/src/server.ts +0 -0
  163. /package/dist/{templates → template/packages}/api/src/trpc.ts +0 -0
  164. /package/dist/{templates → template/packages}/api/tsconfig.json +0 -0
  165. /package/dist/{templates → template/packages}/database/README.md +0 -0
  166. /package/dist/{templates → template/packages}/database/prisma/seed.ts +0 -0
  167. /package/dist/{templates → template/packages}/database/schema.prisma +0 -0
  168. /package/dist/{templates → template/packages}/database/src/index.ts +0 -0
  169. /package/dist/{templates → template/packages}/database/src/validators.ts +0 -0
  170. /package/dist/{templates → template/packages}/database/tsconfig.json +0 -0
  171. /package/dist/{templates/native → template/packages/mobile}/README.md +0 -0
  172. /package/dist/{templates/native → template/packages/mobile}/__tests__/App.test.tsx +0 -0
  173. /package/dist/{templates/native → template/packages/mobile}/__tests__/components.test.tsx +0 -0
  174. /package/dist/{templates/native → template/packages/mobile}/app.json +0 -0
  175. /package/dist/{templates/native → template/packages/mobile}/index.js +0 -0
  176. /package/dist/{templates/native → template/packages/mobile}/jest.config.js +0 -0
  177. /package/dist/{templates/native → template/packages/mobile}/jest.setup.js +0 -0
  178. /package/dist/{templates/native → template/packages/mobile}/src/App-with-trpc-and-shared.tsx +0 -0
  179. /package/dist/{templates/native → template/packages/mobile}/src/App-with-trpc.tsx +0 -0
  180. /package/{templates/native/src/App-with-trpc-and-shared.tsx → dist/template/packages/mobile/src/App.tsx} +0 -0
  181. /package/dist/{templates/native → template/packages/mobile}/src/utils/trpc.ts +0 -0
  182. /package/dist/{templates/native → template/packages/mobile}/tsconfig.json +0 -0
  183. /package/dist/{templates → template/packages}/shared/README.md +0 -0
  184. /package/dist/{templates → template/packages}/shared/__tests__/shared.test.ts +0 -0
  185. /package/dist/{templates → template/packages}/shared/jest.config.js +0 -0
  186. /package/{templates → dist/template/packages}/shared/src/components/App.tsx +0 -0
  187. /package/{templates → dist/template/packages}/shared/src/components/HelloWorld.tsx +0 -0
  188. /package/dist/{templates → template/packages}/shared/src/components/index.ts +0 -0
  189. /package/dist/{templates → template/packages}/shared/src/index.ts +0 -0
  190. /package/{templates → dist/template/packages}/shared/src/navigation/AppRouter.tsx +0 -0
  191. /package/dist/{templates → template/packages}/shared/src/trpc/client.ts +0 -0
  192. /package/dist/{templates → template/packages}/shared/tsconfig.json +0 -0
  193. /package/dist/{templates → template/packages}/web/README.md +0 -0
  194. /package/dist/{templates → template/packages}/web/__tests__/App.test.tsx +0 -0
  195. /package/dist/{templates → template/packages}/web/__tests__/components.test.tsx +0 -0
  196. /package/dist/{templates → template/packages}/web/index.html +0 -0
  197. /package/dist/{templates → template/packages}/web/jest.config.js +0 -0
  198. /package/dist/{templates → template/packages}/web/jest.setup.js +0 -0
  199. /package/dist/{templates → template/packages}/web/src/App-with-trpc-and-shared.tsx +0 -0
  200. /package/dist/{templates → template/packages}/web/src/App-with-trpc.tsx +0 -0
  201. /package/{templates/web/src/App-with-trpc-and-shared.tsx → dist/template/packages/web/src/App.tsx} +0 -0
  202. /package/dist/{templates → template/packages}/web/src/components/TestDemo.tsx +0 -0
  203. /package/dist/{templates → template/packages}/web/src/main.tsx +0 -0
  204. /package/dist/{templates → template/packages}/web/src/utils/trpc.ts +0 -0
  205. /package/dist/{templates → template/packages}/web/tsconfig.json +0 -0
  206. /package/dist/{templates → template/packages}/web/vite.config.ts +0 -0
  207. /package/dist/{templates/workspace → template}/setup.sh +0 -0
  208. /package/dist/{templates/workspace → template}/tsconfig.json +0 -0
@@ -1,86 +0,0 @@
1
- # {{projectName}}
2
-
3
- {{description}}
4
-
5
- ## Getting Started
6
-
7
- This is a React Native application built with the Idealyst Framework.
8
-
9
- ### Prerequisites
10
-
11
- - Node.js 18+
12
- - Yarn
13
- - React Native development environment
14
- - Android Studio (for Android development)
15
- - Xcode (for iOS development)
16
-
17
- ### Installation
18
-
19
- Install dependencies:
20
- ```bash
21
- yarn install
22
- ```
23
-
24
- ### Running the App
25
-
26
- Start the Metro bundler:
27
- ```bash
28
- yarn start
29
- ```
30
-
31
- Run on Android:
32
- ```bash
33
- yarn android
34
- ```
35
-
36
- Run on iOS:
37
- ```bash
38
- yarn ios
39
- ```
40
-
41
- ### Project Structure
42
-
43
- ```
44
- {{projectName}}/
45
- ├── src/
46
- │ └── App.tsx # Main app component
47
- ├── android/ # Android-specific code
48
- ├── ios/ # iOS-specific code
49
- ├── babel.config.js # Babel configuration
50
- ├── metro.config.js # Metro configuration
51
- └── tsconfig.json # TypeScript configuration
52
- ```
53
-
54
- ### Features
55
-
56
- - **Idealyst Components**: Pre-built UI components
57
- - **Idealyst Navigation**: Cross-platform navigation
58
- - **Idealyst Theme**: Consistent theming system
59
- - **TypeScript**: Full type safety
60
- - **React Native 0.80.1**: Latest stable version
61
-
62
- ### Development
63
-
64
- The app uses the Idealyst Framework for consistent UI and navigation across platforms.
65
-
66
- Edit `src/App.tsx` to start building your application.
67
-
68
- ### Building for Production
69
-
70
- Build Android APK:
71
- ```bash
72
- yarn build:android
73
- ```
74
-
75
- ### Testing
76
-
77
- Run tests:
78
- ```bash
79
- yarn test
80
- ```
81
-
82
- ### Learn More
83
-
84
- - [Idealyst Framework Documentation](https://github.com/your-username/idealyst-framework)
85
- - [React Native Documentation](https://reactnative.dev/)
86
- - [TypeScript Documentation](https://www.typescriptlang.org/)
@@ -1,156 +0,0 @@
1
- /**
2
- * @format
3
- */
4
-
5
- import React from 'react';
6
- import ReactTestRenderer from 'react-test-renderer';
7
- import App from '../App';
8
-
9
- // Mock the NavigatorProvider to avoid complex navigation setup
10
- jest.mock('@idealyst/navigation', () => ({
11
- NavigatorProvider: ({ children }: { children?: React.ReactNode }) => (
12
- React.createElement('View', { testID: 'navigator-provider' }, children || 'Navigator Content')
13
- ),
14
- }));
15
-
16
- jest.mock('@idealyst/navigation/examples', () => ({
17
- ExampleStackRouter: {},
18
- }));
19
-
20
- describe('App Component', () => {
21
- it('renders correctly', async () => {
22
- let component: ReactTestRenderer.ReactTestRenderer;
23
-
24
- await ReactTestRenderer.act(() => {
25
- component = ReactTestRenderer.create(<App />);
26
- });
27
-
28
- expect(component!).toBeDefined();
29
- expect(component!.toJSON()).toMatchSnapshot();
30
- });
31
-
32
- it('renders without crashing', () => {
33
- const tree = ReactTestRenderer.create(<App />);
34
- expect(tree).toBeDefined();
35
- expect(tree.root).toBeDefined();
36
- });
37
-
38
- it('contains NavigatorProvider', () => {
39
- const tree = ReactTestRenderer.create(<App />);
40
- const navigatorProvider = tree.root.findByProps({ testID: 'navigator-provider' });
41
- expect(navigatorProvider).toBeDefined();
42
- });
43
-
44
- it('has proper SafeAreaView structure', () => {
45
- const tree = ReactTestRenderer.create(<App />);
46
- const safeAreaView = tree.root.findByType('SafeAreaView');
47
- expect(safeAreaView).toBeDefined();
48
- expect(safeAreaView.props.style).toEqual({ flex: 1 });
49
- });
50
- });
51
-
52
- describe('Sample Component Tests', () => {
53
- // Example of testing a simple functional component
54
- const SimpleButton = ({ title, onPress, disabled = false }: {
55
- title: string;
56
- onPress: () => void;
57
- disabled?: boolean;
58
- }) => {
59
- return React.createElement(
60
- 'TouchableOpacity',
61
- {
62
- testID: 'simple-button',
63
- onPress: disabled ? undefined : onPress,
64
- style: { opacity: disabled ? 0.5 : 1 }
65
- },
66
- React.createElement('Text', null, title)
67
- );
68
- };
69
-
70
- it('renders button with correct title', () => {
71
- const mockPress = jest.fn();
72
- const tree = ReactTestRenderer.create(
73
- <SimpleButton title="Test Button" onPress={mockPress} />
74
- );
75
-
76
- const textElement = tree.root.findByType('Text');
77
- expect(textElement.children).toEqual(['Test Button']);
78
- });
79
-
80
- it('handles press events', () => {
81
- const mockPress = jest.fn();
82
- const tree = ReactTestRenderer.create(
83
- <SimpleButton title="Test Button" onPress={mockPress} />
84
- );
85
-
86
- const button = tree.root.findByProps({ testID: 'simple-button' });
87
- ReactTestRenderer.act(() => {
88
- button.props.onPress();
89
- });
90
-
91
- expect(mockPress).toHaveBeenCalledTimes(1);
92
- });
93
-
94
- it('disables button when disabled prop is true', () => {
95
- const mockPress = jest.fn();
96
- const tree = ReactTestRenderer.create(
97
- <SimpleButton title="Disabled Button" onPress={mockPress} disabled={true} />
98
- );
99
-
100
- const button = tree.root.findByProps({ testID: 'simple-button' });
101
- expect(button.props.onPress).toBeUndefined();
102
- expect(button.props.style.opacity).toBe(0.5);
103
- });
104
-
105
- it('handles component state changes', () => {
106
- const StatefulComponent = () => {
107
- const [count, setCount] = React.useState(0);
108
-
109
- return React.createElement(
110
- 'View',
111
- { testID: 'stateful-component' },
112
- React.createElement('Text', { testID: 'count' }, count.toString()),
113
- React.createElement(
114
- 'TouchableOpacity',
115
- {
116
- testID: 'increment-button',
117
- onPress: () => setCount(c => c + 1)
118
- },
119
- React.createElement('Text', null, 'Increment')
120
- )
121
- );
122
- };
123
-
124
- const tree = ReactTestRenderer.create(<StatefulComponent />);
125
-
126
- // Check initial state
127
- const countText = tree.root.findByProps({ testID: 'count' });
128
- expect(countText.children).toEqual(['0']);
129
-
130
- // Simulate button press
131
- const incrementButton = tree.root.findByProps({ testID: 'increment-button' });
132
- ReactTestRenderer.act(() => {
133
- incrementButton.props.onPress();
134
- });
135
-
136
- // Check updated state
137
- expect(countText.children).toEqual(['1']);
138
- });
139
- });
140
-
141
- describe('Sample Native Tests', () => {
142
- it('should pass a basic test', () => {
143
- expect(1 + 1).toBe(2);
144
- });
145
-
146
- it('should handle string operations', () => {
147
- const greeting = 'Hello World';
148
- expect(greeting).toContain('World');
149
- });
150
-
151
- it('should work with arrays', () => {
152
- const items = [1, 2, 3];
153
- expect(items).toHaveLength(3);
154
- expect(items).toContain(2);
155
- });
156
- });
@@ -1,300 +0,0 @@
1
- /**
2
- * Example component tests for React Native
3
- * @format
4
- */
5
-
6
- import React from 'react';
7
- import ReactTestRenderer from 'react-test-renderer';
8
-
9
- describe('React Native Component Testing Examples', () => {
10
- // Example 1: Simple Text Component
11
- const SimpleText = ({ text, color = 'black' }: { text: string; color?: string }) => {
12
- return React.createElement('Text', { style: { color }, testID: 'simple-text' }, text);
13
- };
14
-
15
- describe('SimpleText Component', () => {
16
- it('renders text correctly', () => {
17
- const tree = ReactTestRenderer.create(<SimpleText text="Hello World" />);
18
- const textComponent = tree.root.findByProps({ testID: 'simple-text' });
19
- expect(textComponent.children).toEqual(['Hello World']);
20
- });
21
-
22
- it('applies custom color', () => {
23
- const tree = ReactTestRenderer.create(<SimpleText text="Colored Text" color="red" />);
24
- const textComponent = tree.root.findByProps({ testID: 'simple-text' });
25
- expect(textComponent.props.style.color).toBe('red');
26
- });
27
-
28
- it('uses default color when not specified', () => {
29
- const tree = ReactTestRenderer.create(<SimpleText text="Default Color" />);
30
- const textComponent = tree.root.findByProps({ testID: 'simple-text' });
31
- expect(textComponent.props.style.color).toBe('black');
32
- });
33
- });
34
-
35
- // Example 2: Button with Press Handler
36
- const PressableButton = ({
37
- title,
38
- onPress,
39
- disabled = false
40
- }: {
41
- title: string;
42
- onPress: () => void;
43
- disabled?: boolean;
44
- }) => {
45
- return React.createElement(
46
- 'TouchableOpacity',
47
- {
48
- testID: 'pressable-button',
49
- onPress: disabled ? undefined : onPress,
50
- style: { opacity: disabled ? 0.5 : 1 }
51
- },
52
- React.createElement('Text', { testID: 'button-text' }, title)
53
- );
54
- };
55
-
56
- describe('PressableButton Component', () => {
57
- it('renders button with title', () => {
58
- const mockPress = jest.fn();
59
- const tree = ReactTestRenderer.create(
60
- <PressableButton title="Press Me" onPress={mockPress} />
61
- );
62
-
63
- const buttonText = tree.root.findByProps({ testID: 'button-text' });
64
- expect(buttonText.children).toEqual(['Press Me']);
65
- });
66
-
67
- it('calls onPress when pressed', () => {
68
- const mockPress = jest.fn();
69
- const tree = ReactTestRenderer.create(
70
- <PressableButton title="Press Me" onPress={mockPress} />
71
- );
72
-
73
- const button = tree.root.findByProps({ testID: 'pressable-button' });
74
- ReactTestRenderer.act(() => {
75
- button.props.onPress();
76
- });
77
-
78
- expect(mockPress).toHaveBeenCalledTimes(1);
79
- });
80
-
81
- it('does not call onPress when disabled', () => {
82
- const mockPress = jest.fn();
83
- const tree = ReactTestRenderer.create(
84
- <PressableButton title="Disabled" onPress={mockPress} disabled />
85
- );
86
-
87
- const button = tree.root.findByProps({ testID: 'pressable-button' });
88
- expect(button.props.onPress).toBeUndefined();
89
- expect(button.props.style.opacity).toBe(0.5);
90
- });
91
- });
92
-
93
- // Example 3: List Component
94
- const ItemList = ({ items }: { items: string[] }) => {
95
- return React.createElement(
96
- 'FlatList',
97
- {
98
- testID: 'item-list',
99
- data: items,
100
- renderItem: ({ item, index }: { item: string; index: number }) =>
101
- React.createElement(
102
- 'View',
103
- { key: index, testID: `item-${index}` },
104
- React.createElement('Text', { testID: `item-text-${index}` }, item)
105
- ),
106
- keyExtractor: (item: string, index: number) => `${item}-${index}`
107
- }
108
- );
109
- };
110
-
111
- describe('ItemList Component', () => {
112
- it('renders list with items', () => {
113
- const items = ['Item 1', 'Item 2', 'Item 3'];
114
- const tree = ReactTestRenderer.create(<ItemList items={items} />);
115
-
116
- const flatList = tree.root.findByProps({ testID: 'item-list' });
117
- expect(flatList.props.data).toEqual(items);
118
- });
119
-
120
- it('generates correct key extractor', () => {
121
- const items = ['Apple', 'Banana'];
122
- const tree = ReactTestRenderer.create(<ItemList items={items} />);
123
-
124
- const flatList = tree.root.findByProps({ testID: 'item-list' });
125
- const keyExtractor = flatList.props.keyExtractor;
126
-
127
- expect(keyExtractor('Apple', 0)).toBe('Apple-0');
128
- expect(keyExtractor('Banana', 1)).toBe('Banana-1');
129
- });
130
- });
131
-
132
- // Example 4: Form Input Component
133
- const TextInput = ({
134
- value,
135
- onChangeText,
136
- placeholder,
137
- secureTextEntry = false
138
- }: {
139
- value: string;
140
- onChangeText: (text: string) => void;
141
- placeholder?: string;
142
- secureTextEntry?: boolean;
143
- }) => {
144
- return React.createElement('TextInput', {
145
- testID: 'text-input',
146
- value,
147
- onChangeText,
148
- placeholder,
149
- secureTextEntry,
150
- style: { borderWidth: 1, padding: 10 }
151
- });
152
- };
153
-
154
- describe('TextInput Component', () => {
155
- it('renders with initial value', () => {
156
- const mockChange = jest.fn();
157
- const tree = ReactTestRenderer.create(
158
- <TextInput value="Initial Value" onChangeText={mockChange} />
159
- );
160
-
161
- const input = tree.root.findByProps({ testID: 'text-input' });
162
- expect(input.props.value).toBe('Initial Value');
163
- });
164
-
165
- it('calls onChangeText when text changes', () => {
166
- const mockChange = jest.fn();
167
- const tree = ReactTestRenderer.create(
168
- <TextInput value="" onChangeText={mockChange} />
169
- );
170
-
171
- const input = tree.root.findByProps({ testID: 'text-input' });
172
- ReactTestRenderer.act(() => {
173
- input.props.onChangeText('New Text');
174
- });
175
-
176
- expect(mockChange).toHaveBeenCalledWith('New Text');
177
- });
178
-
179
- it('shows placeholder when provided', () => {
180
- const mockChange = jest.fn();
181
- const tree = ReactTestRenderer.create(
182
- <TextInput
183
- value=""
184
- onChangeText={mockChange}
185
- placeholder="Enter text here"
186
- />
187
- );
188
-
189
- const input = tree.root.findByProps({ testID: 'text-input' });
190
- expect(input.props.placeholder).toBe('Enter text here');
191
- });
192
-
193
- it('enables secure text entry when specified', () => {
194
- const mockChange = jest.fn();
195
- const tree = ReactTestRenderer.create(
196
- <TextInput
197
- value=""
198
- onChangeText={mockChange}
199
- secureTextEntry
200
- />
201
- );
202
-
203
- const input = tree.root.findByProps({ testID: 'text-input' });
204
- expect(input.props.secureTextEntry).toBe(true);
205
- });
206
- });
207
-
208
- // Example 5: Component with Hooks
209
- const Counter = ({ initialValue = 0 }: { initialValue?: number }) => {
210
- const [count, setCount] = React.useState(initialValue);
211
-
212
- return React.createElement(
213
- 'View',
214
- { testID: 'counter-container' },
215
- React.createElement('Text', { testID: 'counter-value' }, count.toString()),
216
- React.createElement(
217
- 'TouchableOpacity',
218
- {
219
- testID: 'increment-button',
220
- onPress: () => setCount(prev => prev + 1)
221
- },
222
- React.createElement('Text', null, '+')
223
- ),
224
- React.createElement(
225
- 'TouchableOpacity',
226
- {
227
- testID: 'decrement-button',
228
- onPress: () => setCount(prev => prev - 1)
229
- },
230
- React.createElement('Text', null, '-')
231
- ),
232
- React.createElement(
233
- 'TouchableOpacity',
234
- {
235
- testID: 'reset-button',
236
- onPress: () => setCount(initialValue)
237
- },
238
- React.createElement('Text', null, 'Reset')
239
- )
240
- );
241
- };
242
-
243
- describe('Counter Component', () => {
244
- it('renders with initial value', () => {
245
- const tree = ReactTestRenderer.create(<Counter initialValue={5} />);
246
- const counterValue = tree.root.findByProps({ testID: 'counter-value' });
247
- expect(counterValue.children).toEqual(['5']);
248
- });
249
-
250
- it('increments counter when increment button is pressed', () => {
251
- const tree = ReactTestRenderer.create(<Counter />);
252
- const counterValue = tree.root.findByProps({ testID: 'counter-value' });
253
- const incrementButton = tree.root.findByProps({ testID: 'increment-button' });
254
-
255
- expect(counterValue.children).toEqual(['0']);
256
-
257
- ReactTestRenderer.act(() => {
258
- incrementButton.props.onPress();
259
- });
260
-
261
- expect(counterValue.children).toEqual(['1']);
262
- });
263
-
264
- it('decrements counter when decrement button is pressed', () => {
265
- const tree = ReactTestRenderer.create(<Counter initialValue={10} />);
266
- const counterValue = tree.root.findByProps({ testID: 'counter-value' });
267
- const decrementButton = tree.root.findByProps({ testID: 'decrement-button' });
268
-
269
- expect(counterValue.children).toEqual(['10']);
270
-
271
- ReactTestRenderer.act(() => {
272
- decrementButton.props.onPress();
273
- });
274
-
275
- expect(counterValue.children).toEqual(['9']);
276
- });
277
-
278
- it('resets counter to initial value when reset is pressed', () => {
279
- const tree = ReactTestRenderer.create(<Counter initialValue={5} />);
280
- const counterValue = tree.root.findByProps({ testID: 'counter-value' });
281
- const incrementButton = tree.root.findByProps({ testID: 'increment-button' });
282
- const resetButton = tree.root.findByProps({ testID: 'reset-button' });
283
-
284
- // Increment a few times
285
- ReactTestRenderer.act(() => {
286
- incrementButton.props.onPress();
287
- incrementButton.props.onPress();
288
- });
289
-
290
- expect(counterValue.children).toEqual(['7']);
291
-
292
- // Reset
293
- ReactTestRenderer.act(() => {
294
- resetButton.props.onPress();
295
- });
296
-
297
- expect(counterValue.children).toEqual(['5']);
298
- });
299
- });
300
- });
@@ -1,5 +0,0 @@
1
- {
2
- "name": "{{appName}}",
3
- "displayName": "{{appName}}",
4
- "react-native-version": "0.80.1"
5
- }
@@ -1,10 +0,0 @@
1
- module.exports = {
2
- presets: ['module:@react-native/babel-preset'],
3
- plugins: [
4
- ['react-native-unistyles/plugin', {
5
- root: 'src',
6
- autoProcessPaths: ['@idealyst/components', '@idealyst/navigation', '@idealyst/theme'],
7
- }],
8
- 'react-native-reanimated/plugin',
9
- ],
10
- };
@@ -1,6 +0,0 @@
1
- import '@idealyst/theme/unistyles';
2
-
3
- import { AppRegistry } from 'react-native';
4
- import App from './src/App';
5
-
6
- AppRegistry.registerComponent('{{projectName}}', () => App);
@@ -1,21 +0,0 @@
1
- module.exports = {
2
- preset: 'react-native',
3
- setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
4
- testMatch: [
5
- '**/__tests__/**/*.{ts,tsx,js}',
6
- '**/*.{test,spec}.{ts,tsx,js}'
7
- ],
8
- transform: {
9
- '^.+\\.(js|jsx|ts|tsx)$': 'babel-jest',
10
- },
11
- transformIgnorePatterns: [
12
- 'node_modules/(?!(react-native|@react-native|@idealyst)/)',
13
- ],
14
- collectCoverageFrom: [
15
- 'src/**/*.{ts,tsx}',
16
- '!src/**/*.d.ts',
17
- '!src/**/index.ts',
18
- ],
19
- coverageDirectory: 'coverage',
20
- testEnvironment: 'jsdom',
21
- };
@@ -1,12 +0,0 @@
1
- // Global test setup for React Native tests
2
- import 'react-native-gesture-handler/jestSetup';
3
-
4
- // Mock react-native modules that are not available in test environment
5
- jest.mock('react-native-reanimated', () => {
6
- const Reanimated = require('react-native-reanimated/mock');
7
- Reanimated.default.call = () => {};
8
- return Reanimated;
9
- });
10
-
11
- // Silence the warning: Animated: `useNativeDriver` is not supported
12
- jest.mock('react-native/Libraries/Animated/NativeAnimatedHelper');
@@ -1,30 +0,0 @@
1
- import React from 'react';
2
- import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
3
- import { NavigatorProvider } from '@idealyst/navigation';
4
- import { trpc, createTRPCClient, AppRouter } from '{{workspaceScope}}/shared';
5
-
6
- // Create tRPC client using shared factory
7
- const queryClient = new QueryClient();
8
-
9
- const trpcClient = createTRPCClient({
10
- apiUrl: 'http://localhost:3000/trpc', // Update this to your API URL
11
- // For device testing, you might need: 'http://192.168.1.xxx:3000/trpc'
12
- // Optional: Add headers for authentication
13
- // headers() {
14
- // return {
15
- // authorization: getAuthToken(),
16
- // };
17
- // },
18
- });
19
-
20
- function App() {
21
- return (
22
- <trpc.Provider client={trpcClient} queryClient={queryClient}>
23
- <QueryClientProvider client={queryClient}>
24
- <NavigatorProvider route={AppRouter} />
25
- </QueryClientProvider>
26
- </trpc.Provider>
27
- );
28
- }
29
-
30
- export default App;
@@ -1,8 +0,0 @@
1
- import React from 'react';
2
- import { App } from '@{{workspaceScope}}/shared';
3
-
4
- function NativeApp() {
5
- return <App />;
6
- }
7
-
8
- export default NativeApp;
@@ -1,7 +0,0 @@
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';
@@ -1,28 +0,0 @@
1
- {
2
- "extends": "@react-native/typescript-config/tsconfig.json",
3
- "compilerOptions": {
4
- "allowJs": true,
5
- "allowSyntheticDefaultImports": true,
6
- "esModuleInterop": true,
7
- "isolatedModules": true,
8
- "jsx": "react-native",
9
- "lib": ["es2017"],
10
- "noEmit": true,
11
- "strict": true,
12
- "target": "esnext",
13
- "skipLibCheck": true,
14
- "baseUrl": "./",
15
- "paths": {
16
- "@/*": ["./src/*"]
17
- }
18
- },
19
- "include": [
20
- "src/**/*",
21
- "index.js"
22
- ],
23
- "exclude": [
24
- "node_modules",
25
- "android",
26
- "ios"
27
- ]
28
- }