new-react-native-boilerplate 0.0.0-stage → 1.0.1

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 (227) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +329 -2
  3. package/package.json +49 -4
  4. package/run.sh +36 -0
  5. package/setup.js +141 -0
  6. package/template/.bundle/config +2 -0
  7. package/template/.editorconfig +14 -0
  8. package/template/.eslintrc.js +49 -0
  9. package/template/.husky/commit-msg +4 -0
  10. package/template/.husky/pre-commit +1 -0
  11. package/template/.prettierrc.js +6 -0
  12. package/template/.watchmanconfig +1 -0
  13. package/template/Gemfile +17 -0
  14. package/template/Gemfile.lock +114 -0
  15. package/template/README.md +101 -0
  16. package/template/__tests__/App.test.tsx +13 -0
  17. package/template/__tests__/CustomTextInput.test.jsx +29 -0
  18. package/template/android/app/build.gradle +119 -0
  19. package/template/android/app/debug.keystore +0 -0
  20. package/template/android/app/proguard-rules.pro +10 -0
  21. package/template/android/app/src/main/AndroidManifest.xml +27 -0
  22. package/template/android/app/src/main/assets/fonts/Poppins-Bold.ttf +0 -0
  23. package/template/android/app/src/main/assets/fonts/Poppins-Medium.ttf +0 -0
  24. package/template/android/app/src/main/assets/fonts/Poppins-Regular.ttf +0 -0
  25. package/template/android/app/src/main/assets/fonts/Poppins-SemiBold.ttf +0 -0
  26. package/template/android/app/src/main/assets/fonts/futura_book.otf +0 -0
  27. package/template/android/app/src/main/assets/fonts/futura_medium.otf +0 -0
  28. package/template/android/app/src/main/java/com/boilerplatereactnative/MainActivity.kt +22 -0
  29. package/template/android/app/src/main/java/com/boilerplatereactnative/MainApplication.kt +27 -0
  30. package/template/android/app/src/main/res/drawable/rn_edit_text_material.xml +37 -0
  31. package/template/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
  32. package/template/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
  33. package/template/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
  34. package/template/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
  35. package/template/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
  36. package/template/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
  37. package/template/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
  38. package/template/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
  39. package/template/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
  40. package/template/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
  41. package/template/android/app/src/main/res/values/strings.xml +3 -0
  42. package/template/android/app/src/main/res/values/styles.xml +9 -0
  43. package/template/android/build.gradle +21 -0
  44. package/template/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  45. package/template/android/gradle/wrapper/gradle-wrapper.properties +7 -0
  46. package/template/android/gradle.properties +49 -0
  47. package/template/android/gradlew +248 -0
  48. package/template/android/gradlew.bat +98 -0
  49. package/template/android/link-assets-manifest.json +29 -0
  50. package/template/android/settings.gradle +6 -0
  51. package/template/app.json +4 -0
  52. package/template/babel.config.js +43 -0
  53. package/template/eslint.config.mjs +175 -0
  54. package/template/index.d.ts +1 -0
  55. package/template/index.js +10 -0
  56. package/template/ios/.xcode.env +11 -0
  57. package/template/ios/BoilerPlateReactNative/AppDelegate.swift +11 -0
  58. package/template/ios/BoilerPlateReactNative/Images.xcassets/AppIcon.appiconset/Contents.json +53 -0
  59. package/template/ios/BoilerPlateReactNative/Images.xcassets/Contents.json +6 -0
  60. package/template/ios/BoilerPlateReactNative/Info.plist +102 -0
  61. package/template/ios/BoilerPlateReactNative/LaunchScreen.storyboard +47 -0
  62. package/template/ios/BoilerPlateReactNative/PrivacyInfo.xcprivacy +37 -0
  63. package/template/ios/BoilerPlateReactNative/SceneDelegate.swift +54 -0
  64. package/template/ios/BoilerPlateReactNative.xcodeproj/project.pbxproj +531 -0
  65. package/template/ios/BoilerPlateReactNative.xcodeproj/xcshareddata/xcschemes/BoilerPlateReactNative.xcscheme +88 -0
  66. package/template/ios/BoilerPlateReactNative.xcworkspace/contents.xcworkspacedata +10 -0
  67. package/template/ios/BoilerPlateReactNative.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  68. package/template/ios/Podfile +34 -0
  69. package/template/ios/Podfile.lock +2552 -0
  70. package/template/ios/link-assets-manifest.json +29 -0
  71. package/template/jest.config.js +13 -0
  72. package/template/jest.setup.js +30 -0
  73. package/template/metro.config.js +15 -0
  74. package/template/package.json +88 -0
  75. package/template/plugins/compile-js/_prompts.js +6 -0
  76. package/template/plugins/compile-js/index.js +9 -0
  77. package/template/plugins/compile-js/plugin.js +103 -0
  78. package/template/plugins/compile-js/tsconfig.build.json +20 -0
  79. package/template/plugins/index.js +46 -0
  80. package/template/plugins/printSuccess/_prompts.js +1 -0
  81. package/template/plugins/printSuccess/index.js +9 -0
  82. package/template/plugins/printSuccess/plugin.js +40 -0
  83. package/template/react-native.config.js +7 -0
  84. package/template/src/App.tsx +27 -0
  85. package/template/src/assets/fonts/Poppins-Bold.ttf +0 -0
  86. package/template/src/assets/fonts/Poppins-Medium.ttf +0 -0
  87. package/template/src/assets/fonts/Poppins-Regular.ttf +0 -0
  88. package/template/src/assets/fonts/Poppins-SemiBold.ttf +0 -0
  89. package/template/src/assets/fonts/futura_book.otf +0 -0
  90. package/template/src/assets/fonts/futura_medium.otf +0 -0
  91. package/template/src/assets/images/check.png +0 -0
  92. package/template/src/assets/images/check@2x.png +0 -0
  93. package/template/src/assets/images/check@3x.png +0 -0
  94. package/template/src/assets/images/email.png +0 -0
  95. package/template/src/assets/images/email@2x.png +0 -0
  96. package/template/src/assets/images/email@3x.png +0 -0
  97. package/template/src/assets/images/icBack.png +0 -0
  98. package/template/src/assets/images/icBack@2x.png +0 -0
  99. package/template/src/assets/images/icBack@3x.png +0 -0
  100. package/template/src/assets/images/icClose.png +0 -0
  101. package/template/src/assets/images/icClose@2x.png +0 -0
  102. package/template/src/assets/images/icClose@3x.png +0 -0
  103. package/template/src/assets/images/icComment.png +0 -0
  104. package/template/src/assets/images/icComment@2x.png +0 -0
  105. package/template/src/assets/images/icComment@3x.png +0 -0
  106. package/template/src/assets/images/icLike.png +0 -0
  107. package/template/src/assets/images/icLike@2x.png +0 -0
  108. package/template/src/assets/images/icLike@3x.png +0 -0
  109. package/template/src/assets/images/icSearch.png +0 -0
  110. package/template/src/assets/images/icSearch@2x.png +0 -0
  111. package/template/src/assets/images/icSearch@3x.png +0 -0
  112. package/template/src/assets/images/icSetting.png +0 -0
  113. package/template/src/assets/images/icSetting@2x.png +0 -0
  114. package/template/src/assets/images/icSetting@3x.png +0 -0
  115. package/template/src/assets/images/icShare.png +0 -0
  116. package/template/src/assets/images/icShare@2x.png +0 -0
  117. package/template/src/assets/images/icShare@3x.png +0 -0
  118. package/template/src/assets/images/line.png +0 -0
  119. package/template/src/assets/images/line@2x.png +0 -0
  120. package/template/src/assets/images/line@3x.png +0 -0
  121. package/template/src/assets/images/lock.png +0 -0
  122. package/template/src/assets/images/lock@2x.png +0 -0
  123. package/template/src/assets/images/lock@3x.png +0 -0
  124. package/template/src/assets/images/notification.png +0 -0
  125. package/template/src/assets/images/notification@2x.png +0 -0
  126. package/template/src/assets/images/notification@3x.png +0 -0
  127. package/template/src/assets/images/oct_dark.png +0 -0
  128. package/template/src/assets/images/oct_light.png +0 -0
  129. package/template/src/assets/images/onboard.png +0 -0
  130. package/template/src/assets/images/password_hide.png +0 -0
  131. package/template/src/assets/images/password_hide@2x.png +0 -0
  132. package/template/src/assets/images/password_hide@3x.png +0 -0
  133. package/template/src/assets/images/password_show.png +0 -0
  134. package/template/src/assets/images/password_show@2x.png +0 -0
  135. package/template/src/assets/images/password_show@3x.png +0 -0
  136. package/template/src/assets/images/right_arrow.png +0 -0
  137. package/template/src/assets/images/right_arrow@2x.png +0 -0
  138. package/template/src/assets/images/right_arrow@3x.png +0 -0
  139. package/template/src/assets/images/star.png +0 -0
  140. package/template/src/assets/images/star@2x.png +0 -0
  141. package/template/src/assets/images/star@3x.png +0 -0
  142. package/template/src/assets/images/uncheck.png +0 -0
  143. package/template/src/assets/images/uncheck@2x.png +0 -0
  144. package/template/src/assets/images/uncheck@3x.png +0 -0
  145. package/template/src/assets/images/user.png +0 -0
  146. package/template/src/assets/images/user@2x.png +0 -0
  147. package/template/src/assets/images/user@3x.png +0 -0
  148. package/template/src/components/atoms/ButtonContainer.tsx +52 -0
  149. package/template/src/components/atoms/ImageContainer.tsx +10 -0
  150. package/template/src/components/atoms/RemoteImage.tsx +8 -0
  151. package/template/src/components/atoms/RoundImageBorder.tsx +35 -0
  152. package/template/src/components/atoms/TextContainer.tsx +38 -0
  153. package/template/src/components/atoms/WrapperContainer.tsx +43 -0
  154. package/template/src/components/atoms/index.ts +6 -0
  155. package/template/src/components/molecules/AuthHeader.tsx +55 -0
  156. package/template/src/components/molecules/CustomTextInput.tsx +102 -0
  157. package/template/src/components/molecules/EmptyComp.tsx +16 -0
  158. package/template/src/components/molecules/ErrorComp.tsx +25 -0
  159. package/template/src/components/molecules/FooterView.tsx +41 -0
  160. package/template/src/components/molecules/HeaderComp.tsx +51 -0
  161. package/template/src/components/molecules/HomeHeader.tsx +63 -0
  162. package/template/src/components/molecules/HomeListHeader.tsx +48 -0
  163. package/template/src/components/molecules/HomeListItems.tsx +86 -0
  164. package/template/src/components/molecules/Loader.tsx +25 -0
  165. package/template/src/components/molecules/ModalSheet.tsx +146 -0
  166. package/template/src/components/molecules/RememberMe.tsx +58 -0
  167. package/template/src/components/molecules/SearchBar.tsx +46 -0
  168. package/template/src/components/molecules/index.ts +12 -0
  169. package/template/src/constants/apiConstant.ts +12 -0
  170. package/template/src/constants/fontFamily.ts +8 -0
  171. package/template/src/constants/imagePath.ts +25 -0
  172. package/template/src/constants/index.ts +3 -0
  173. package/template/src/constants/storageKeys.ts +5 -0
  174. package/template/src/models/ApiErrorResponse.ts +19 -0
  175. package/template/src/models/HomeData.ts +17 -0
  176. package/template/src/models/User.ts +11 -0
  177. package/template/src/navigations/AuthStack.tsx +20 -0
  178. package/template/src/navigations/MainStack.tsx +19 -0
  179. package/template/src/navigations/Routes.tsx +22 -0
  180. package/template/src/navigations/navigationProps.ts +8 -0
  181. package/template/src/redux/hooks.ts +10 -0
  182. package/template/src/redux/reducers/auth.ts +43 -0
  183. package/template/src/redux/reducers/common.ts +24 -0
  184. package/template/src/redux/reducers/index.ts +31 -0
  185. package/template/src/redux/reducers/product.ts +37 -0
  186. package/template/src/redux/reducers/settings.ts +55 -0
  187. package/template/src/redux/store.ts +19 -0
  188. package/template/src/redux/types.ts +6 -0
  189. package/template/src/screens/Home/Home.tsx +65 -0
  190. package/template/src/screens/Login/Login.tsx +35 -0
  191. package/template/src/screens/Login/components/LoginForm.tsx +88 -0
  192. package/template/src/screens/Login/hooks/useLogin.ts +38 -0
  193. package/template/src/screens/Login/styles.ts +17 -0
  194. package/template/src/screens/Login/types.ts +10 -0
  195. package/template/src/screens/Onboarding/Onboarding.tsx +87 -0
  196. package/template/src/screens/Onboarding/styles.ts +25 -0
  197. package/template/src/screens/PostDetails/PostDetails.tsx +168 -0
  198. package/template/src/screens/PostDetails/styles.ts +82 -0
  199. package/template/src/screens/Signup/Signup.tsx +32 -0
  200. package/template/src/screens/Signup/components/SignupForm.tsx +113 -0
  201. package/template/src/screens/Signup/hooks/useSignup.ts +38 -0
  202. package/template/src/screens/Signup/styles.ts +18 -0
  203. package/template/src/screens/Signup/type.ts +12 -0
  204. package/template/src/screens/index.ts +5 -0
  205. package/template/src/services/apiService.ts +144 -0
  206. package/template/src/services/authService.ts +79 -0
  207. package/template/src/services/productService.ts +45 -0
  208. package/template/src/services/statusHandler.ts +17 -0
  209. package/template/src/styles/breakpoints.ts +11 -0
  210. package/template/src/styles/themes.ts +45 -0
  211. package/template/src/styles/unistyles.ts +25 -0
  212. package/template/src/translations/ar.json +47 -0
  213. package/template/src/translations/en.json +47 -0
  214. package/template/src/translations/fr.json +47 -0
  215. package/template/src/translations/index.ts +32 -0
  216. package/template/src/typings/env.d.ts +5 -0
  217. package/template/src/typings/global.d.ts +3 -0
  218. package/template/src/utils/handleLocalStorage.ts +31 -0
  219. package/template/src/utils/i18nHelpers.ts +20 -0
  220. package/template/src/utils/index.ts +66 -0
  221. package/template/src/utils/scaling.ts +13 -0
  222. package/template/src/utils/themeHelpers.ts +10 -0
  223. package/template/src/utils/validationForm.ts +23 -0
  224. package/template/src/utils/validations.ts +69 -0
  225. package/template/tsconfig.json +22 -0
  226. package/template/yarn.lock +7728 -0
  227. package/template.config.js +6 -0
@@ -0,0 +1,29 @@
1
+ {
2
+ "migIndex": 1,
3
+ "data": [
4
+ {
5
+ "path": "src/assets/fonts/Poppins-Bold.ttf",
6
+ "sha1": "875cf0cecd647bcf22e79d633d868c1b1ec98dfa"
7
+ },
8
+ {
9
+ "path": "src/assets/fonts/Poppins-Medium.ttf",
10
+ "sha1": "283f21b44efbdbf276ba802be2d949a36bbc4233"
11
+ },
12
+ {
13
+ "path": "src/assets/fonts/Poppins-Regular.ttf",
14
+ "sha1": "fdd3002e7d814ee47c1c1b8487c72c6bbb3a2d00"
15
+ },
16
+ {
17
+ "path": "src/assets/fonts/Poppins-SemiBold.ttf",
18
+ "sha1": "8a4ace9392d06bcb7f8ea2f5169b07e4c383a90d"
19
+ },
20
+ {
21
+ "path": "src/assets/fonts/futura_book.otf",
22
+ "sha1": "81bd044285126ef7ba34fa8d8cafc3f787e3d054"
23
+ },
24
+ {
25
+ "path": "src/assets/fonts/futura_medium.otf",
26
+ "sha1": "335cb6dab2e0995ef9368234f97f006df013055d"
27
+ }
28
+ ]
29
+ }
@@ -0,0 +1,13 @@
1
+ module.exports = {
2
+ preset: '@react-native/jest-preset',
3
+ setupFilesAfterEnv: ['./jest.setup.js'],
4
+ transform: {
5
+ '^.+\\.(bmp|gif|jpg|jpeg|mp4|png|psd|svg|webp)$': require.resolve(
6
+ '@react-native/jest-preset/jest/assetFileTransformer.js',
7
+ ),
8
+ '^.+\\.(js|jsx|ts|tsx)$': 'babel-jest',
9
+ },
10
+ transformIgnorePatterns: [
11
+ 'node_modules/(?!((jest-)?react-native|@react-native(-community)?|@react-navigation|react-redux|@reduxjs/toolkit|immer|react-i18next|react-native-reanimated|react-native-worklets|react-native-unistyles|react-native-safe-area-context|react-native-screens|react-native-gesture-handler|react-native-keyboard-aware-scroll-view|react-native-iphone-x-helper|react-native-restart|react-native-localize)/)',
12
+ ],
13
+ };
@@ -0,0 +1,30 @@
1
+ /* eslint-disable @typescript-eslint/no-require-imports -- require() is needed inside jest.mock factories */
2
+ import 'react-native-gesture-handler/jestSetup';
3
+
4
+ // react-native-worklets must be mocked before react-native-reanimated is loaded.
5
+ // (jest.mock calls are hoisted to the top of this file by babel-plugin-jest-hoist)
6
+ jest.mock('react-native-worklets', () => require('react-native-worklets/src/mock'));
7
+
8
+ // react-native-reanimated runs on its in-memory mock in tests
9
+ jest.mock('react-native-reanimated', () => require('react-native-reanimated/mock'));
10
+
11
+ // Mock MMKV storage with an in-memory implementation
12
+ jest.mock('react-native-mmkv', () => {
13
+ const {createMockMMKV} = require('react-native-mmkv/lib/commonjs/createMMKV.mock');
14
+
15
+ return {
16
+ MMKV: jest.fn(() => createMockMMKV()),
17
+ };
18
+ });
19
+
20
+ jest.mock('react-native/Libraries/EventEmitter/NativeEventEmitter', () => ({
21
+ __esModule: true,
22
+ default: jest.fn().mockImplementation(() => ({
23
+ addListener: jest.fn(() => ({remove: jest.fn()})),
24
+ removeAllListeners: jest.fn(),
25
+ removeSubscription: jest.fn(),
26
+ })),
27
+ }));
28
+
29
+ // Register unistyles breakpoints/themes for component tests
30
+ import './src/styles/unistyles';
@@ -0,0 +1,15 @@
1
+ const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');
2
+
3
+ /**
4
+ * Metro configuration
5
+ * https://reactnative.dev/docs/metro
6
+ *
7
+ * @type {import('@react-native/metro-config').MetroConfig}
8
+ */
9
+ const config = {
10
+ resolver: {
11
+ sourceExts: ['js', 'jsx', 'ts', 'tsx', 'cjs', 'mjs', 'json'],
12
+ },
13
+ };
14
+
15
+ module.exports = mergeConfig(getDefaultConfig(__dirname), config);
@@ -0,0 +1,88 @@
1
+ {
2
+ "name": "BoilerPlateReactNative",
3
+ "version": "0.0.1",
4
+ "private": true,
5
+ "scripts": {
6
+ "android": "react-native run-android",
7
+ "ios": "react-native run-ios",
8
+ "lint": "eslint . --ext .ts,.tsx",
9
+ "start": "react-native start --reset-cache",
10
+ "start-logs": "npx react-native start --reset-cache --client-logs",
11
+ "reset": "react-native start --reset-cache",
12
+ "test": "jest",
13
+ "asset": "npx react-native-asset",
14
+ "test:report": "jest --collectCoverage --coverageDirectory=\"./coverage\" --ci --reporters=default --reporters=jest-junit --coverage",
15
+ "tsc": "node_modules/typescript/bin/tsc --noEmit",
16
+ "precommit": "concurrently 'yarn tsc' 'yarn lint'",
17
+ "android-bundle-release": "react-native build-android --mode=release",
18
+ "android-run-release": "react-native run-android --mode=release",
19
+ "podinstall": "cd ios && bundle exec pod install && cd ..",
20
+ "prepare": "husky"
21
+ },
22
+ "dependencies": {
23
+ "@os-team/i18next-react-native-language-detector": "^1.1.6",
24
+ "@react-navigation/native": "^7.5.1",
25
+ "@react-navigation/native-stack": "^7.21.0",
26
+ "@reduxjs/toolkit": "^2.13.0",
27
+ "axios": "^1.20.0",
28
+ "formik": "^2.4.9",
29
+ "i18next": "^26.5.4",
30
+ "react": "19.3.0",
31
+ "react-i18next": "^17.1.0",
32
+ "react-native": "0.88.0",
33
+ "react-native-gesture-handler": "^2.29.1",
34
+ "react-native-keyboard-aware-scroll-view": "^0.9.5",
35
+ "react-native-mmkv": "^3.3.3",
36
+ "react-native-reanimated": "^4.7.1",
37
+ "react-native-worklets": "^0.13.0",
38
+ "react-native-restart": "^0.0.29",
39
+ "react-native-safe-area-context": "^5.10.1",
40
+ "react-native-screens": "^4.30.0",
41
+ "react-native-is-edge-to-edge": "^1.3.1",
42
+ "react-native-unistyles": "^2.43.0",
43
+ "@react-native/normalize-colors": "0.88.0",
44
+ "react-redux": "^9.3.0",
45
+ "yup": "^1.7.1"
46
+ },
47
+ "devDependencies": {
48
+ "@babel/core": "^7.25.2",
49
+ "@babel/preset-env": "^7.25.3",
50
+ "@babel/runtime": "^7.25.0",
51
+ "@react-native-community/cli": "20.2.0",
52
+ "@react-native-community/cli-platform-android": "20.2.0",
53
+ "@react-native-community/cli-platform-ios": "20.2.0",
54
+ "@react-native/babel-preset": "0.88.0",
55
+ "@react-native/eslint-config": "0.88.0",
56
+ "@react-native/jest-preset": "0.88.0",
57
+ "@react-native/metro-config": "0.88.0",
58
+ "@react-native/typescript-config": "0.88.0",
59
+ "@testing-library/react-native": "^13.3.3",
60
+ "@types/jest": "^29.5.14",
61
+ "@types/react": "^19.2.0",
62
+ "@types/react-test-renderer": "^19.1.0",
63
+ "babel-plugin-module-resolver": "^5.0.2",
64
+ "commitlint": "^21.2.4",
65
+ "concurrently": "^10.0.6",
66
+ "eslint": "^9.39.5",
67
+ "eslint-plugin-import": "^2.32.0",
68
+ "eslint-plugin-jest": "^29.17.0",
69
+ "eslint-plugin-perfectionist": "^5.13.0",
70
+ "eslint-plugin-react": "^7.37.5",
71
+ "eslint-plugin-react-hooks": "^7.1.1",
72
+ "eslint-plugin-testing-library": "^7.16.2",
73
+ "eslint-plugin-unicorn": "^62.0.0",
74
+ "eslint-plugin-unused-imports": "^4.4.1",
75
+ "husky": "^9.1.7",
76
+ "jest": "^29.7.0",
77
+ "prettier": "2.8.8",
78
+ "react-native-dotenv": "^5.0.0",
79
+ "react-native-localize": "^3.7.2",
80
+ "react-test-renderer": "19.3.0",
81
+ "typescript": "^6.0.3",
82
+ "typescript-eslint": "^8.72.0"
83
+ },
84
+ "engines": {
85
+ "node": ">=22.11.0"
86
+ },
87
+ "packageManager": "yarn@1.22.22"
88
+ }
@@ -0,0 +1,6 @@
1
+ module.exports = {
2
+ color: "blue",
3
+ initial: true,
4
+ message: "📘 Using typescript ?",
5
+ type: "confirm",
6
+ };
@@ -0,0 +1,9 @@
1
+ /* eslint-disable @typescript-eslint/no-require-imports */
2
+ const promptsOptions = require("./_prompts");
3
+ const { apply } = require("./plugin");
4
+
5
+ module.exports = {
6
+ apply,
7
+ name: "typescript",
8
+ // promptsOptions,
9
+ };
@@ -0,0 +1,103 @@
1
+ /* eslint-disable @typescript-eslint/no-require-imports */
2
+ /* eslint-disable no-console */
3
+ const { execSync, spawnSync } = require("node:child_process");
4
+
5
+ const TYPESCRIPT_VERSION = "5.7.3";
6
+
7
+ function isYarnAvailable() {
8
+ try {
9
+ return !!(
10
+ execSync("yarn --version", {
11
+ stdio: [0, "pipe", "ignore"],
12
+ }).toString() || ""
13
+ ).trim();
14
+ } catch {
15
+ return null;
16
+ }
17
+ }
18
+ function isNpmAvailable() {
19
+ try {
20
+ return !!(
21
+ execSync("npm --version", {
22
+ stdio: [0, "pipe", "ignore"],
23
+ }).toString() || ""
24
+ ).trim();
25
+ } catch {
26
+ return null;
27
+ }
28
+ }
29
+
30
+ module.exports = {
31
+ async apply(value) {
32
+ return new Promise((resolve) => {
33
+ let packageManager = null;
34
+ let addCmd = null;
35
+
36
+ // react-native cli prefer yarn so we follow the same logic
37
+ if (isYarnAvailable()) {
38
+ packageManager = "yarn";
39
+ addCmd = "add";
40
+ } else if (isNpmAvailable()) {
41
+ packageManager = "npm";
42
+ addCmd = "install";
43
+ }
44
+
45
+ if (!packageManager) {
46
+ console.error(
47
+ "🚨 No package manager found. Please install yarn or npm."
48
+ );
49
+ process.exit(1);
50
+ }
51
+
52
+ if (value) {
53
+ console.log("\n");
54
+
55
+ console.log("📦 Loading the build tool...");
56
+ const installTypeScriptCmd = spawnSync(
57
+ packageManager,
58
+ [addCmd, "-D", `typescript@${TYPESCRIPT_VERSION}`],
59
+ { stdio: "inherit" }
60
+ );
61
+ if (installTypeScriptCmd.error) {
62
+ console.error(installTypeScriptCmd.error);
63
+ process.exit(1);
64
+ }
65
+
66
+ console.log("🧱 Building the javascript source...");
67
+ const transpileCmd = spawnSync(
68
+ "npx",
69
+ ["tsc", "--project", `plugins/compile-js/tsconfig.build.json`],
70
+ { stdio: "inherit" }
71
+ );
72
+ if (transpileCmd.error) {
73
+ console.error(transpileCmd.error);
74
+ process.exit(1);
75
+ }
76
+
77
+ try {
78
+ console.log("🖼️ Copying assets...");
79
+ execSync("cp -R src/theme/assets/images js/src/theme/assets/images");
80
+
81
+ console.log("♻️ Replacing source...");
82
+ execSync("rm -rf src", { stdio: "pipe" });
83
+ execSync("cp -R js/src ./src", { stdio: "pipe" });
84
+ execSync("rm -rf __mocks__", { stdio: "pipe" });
85
+ execSync("cp -R js/__mocks__ ./__mocks__", { stdio: "pipe" });
86
+ execSync("rm -rf js", { stdio: "pipe" });
87
+ } catch {
88
+ console.error(
89
+ "🚨 Failed to copy assets or replace source. If you are using windows, please use git bash."
90
+ );
91
+ process.exit(1);
92
+ }
93
+
94
+ console.log("🌀 Removing types ...");
95
+ execSync("rm -rf src/theme/types", { stdio: "pipe" });
96
+ execSync("rm -f src/navigation/paths.js", { stdio: "pipe" });
97
+ execSync("rm -f src/navigation/types.js", { stdio: "pipe" });
98
+ }
99
+
100
+ resolve();
101
+ });
102
+ },
103
+ };
@@ -0,0 +1,20 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "jsx": "react-native",
5
+ "baseUrl": "../../",
6
+ "paths": {
7
+ "@api/*": ["src/api/*"],
8
+ "@assets/*": ["src/assets/*"],
9
+ "@components/*": ["src/components/*"],
10
+ "@screens/*": ["src/screens/*"],
11
+ "@utils/*": ["src/utils/*"],
12
+ "@constants/*": ["src/constants/*"],
13
+ "@typings/*": ["src/typings/*"],
14
+ "@redux/*": ["src/redux/*"],
15
+ "@navigations/*": ["src/navigations/*"],
16
+ "@hooks/*": ["src/hooks/*"],
17
+ "@models/*": ["src/models/*"]
18
+ }
19
+ }
20
+ }
@@ -0,0 +1,46 @@
1
+ /* eslint-disable @typescript-eslint/no-require-imports */
2
+ // eslint-disable-next-line import/no-extraneous-dependencies
3
+ const prompts = require("prompts");
4
+ const typescriptPlugin = require("./compile-js");
5
+ const printSuccessPlugin = require("./printSuccess");
6
+
7
+ // List of plugin to apply (ordered)
8
+ const plugins = [typescriptPlugin, printSuccessPlugin];
9
+
10
+ /**
11
+ * @typedef {Object} Plugin
12
+ * @property promptsOptions {Object|null} the plugin prompt property
13
+ * @property apply {Function} the refactoring to apply to the boilerplate
14
+ */
15
+
16
+ /**
17
+ * Apply a plugin
18
+ * @param name {string}
19
+ * @param plugin {Plugin}
20
+ * @param response {Object} previous response
21
+ *
22
+ * @return {Promise<*>}
23
+ */
24
+ async function applyPlugin(name, plugin, response) {
25
+ if (!plugin.promptsOptions) {
26
+ await plugin.apply(null, response);
27
+ return { [name]: null, ...response };
28
+ }
29
+ const { value } = await prompts({ ...plugin.promptsOptions, name: "value" });
30
+ await plugin.apply(value, response);
31
+ return { [name]: value, ...response };
32
+ }
33
+
34
+ module.exports = {
35
+ /**
36
+ * Apply all plugin in the order of plugin
37
+ * @return {Promise<{apply: function(*=): Promise<void>, name: string, promptsOptions: {onRender(*): void, initial: boolean, name: string, type: string, message: string}|{type?: string, name?: string, message?: string, msg?: *, initial?: boolean, onRender?: function(*): void}}|{name?: string, promptsOptions?: {onRender(*): void, initial: boolean, name: string, type: string, message: string}|{type?: string, name?: string, message?: string, msg?: *, initial?: boolean, onRender?: function(*): void}, apply?: function(*=): Promise<void>}|{apply: function(*, *): Promise<Promise.Promise|Promise<unknown>>, name: string, promptsOptions: null}|{name?: string, promptsOptions?: null, apply?: function(*, *): Promise<Promise.Promise|Promise<unknown>>}>}
38
+ */
39
+ async applyPlugins() {
40
+ return plugins.reduce(
41
+ (acc, { name, ...plugin }) =>
42
+ acc.then((response) => applyPlugin(name, plugin, response)),
43
+ Promise.resolve({})
44
+ );
45
+ },
46
+ };
@@ -0,0 +1 @@
1
+ module.exports = null;
@@ -0,0 +1,9 @@
1
+ /* eslint-disable @typescript-eslint/no-require-imports */
2
+ const promptsOptions = require("./_prompts");
3
+ const { apply } = require("./plugin");
4
+
5
+ module.exports = {
6
+ apply,
7
+ name: "printSuccess",
8
+ promptsOptions,
9
+ };
@@ -0,0 +1,40 @@
1
+ /* eslint-disable @typescript-eslint/no-require-imports */
2
+ /* eslint-disable no-console */
3
+ // eslint-disable-next-line import/no-extraneous-dependencies
4
+ const { blue, green, red, yellow } = require("kleur");
5
+
6
+ module.exports = {
7
+ async apply(value, previousValues) {
8
+ return new Promise((resolve) => {
9
+ console.log("\n");
10
+ console.log(
11
+ "React-Native Boilerplate initialized with success ! 🚀\n"
12
+ );
13
+ if (!previousValues.typescript) {
14
+ console.log(blue(" THE TYPESCRIPT VERSION 📘"));
15
+ } else {
16
+ console.log(yellow(" THE JAVASCRIPT VERSION 📒"));
17
+ }
18
+ console.log("\n");
19
+
20
+ console.log(
21
+ "- 📚 If you need to read more about this boilerplate : https://thecodingmachine.github.io/react-native-boilerplate/"
22
+ );
23
+ console.log(
24
+ "- ⭐ If you love this boilerplate, give us a star, you will be a ray of sunshine in our lives :) https://github.com/sharmahardik59/RNBoilerplate"
25
+ );
26
+
27
+ if (previousValues.typescript) {
28
+ console.log("\n");
29
+ console.log(
30
+ red(
31
+ '🚨 You choose the javascript version, don\'t forget to run "yarn lint:fix" after the installation 🚨'
32
+ )
33
+ );
34
+ console.log("\n");
35
+ }
36
+
37
+ resolve();
38
+ });
39
+ },
40
+ };
@@ -0,0 +1,7 @@
1
+ module.exports = {
2
+ assets: ['./src/assets/fonts'],
3
+ project: {
4
+ android: {},
5
+ ios: {},
6
+ },
7
+ };
@@ -0,0 +1,27 @@
1
+ import store from '@redux/store';
2
+ import checkLocalStorage from '@utils/handleLocalStorage';
3
+ import React, { useLayoutEffect } from 'react';
4
+ import { StatusBar, useColorScheme } from 'react-native';
5
+ import { SafeAreaProvider } from 'react-native-safe-area-context';
6
+ import { Provider } from 'react-redux';
7
+ import Routes from './navigations/Routes';
8
+ import './styles/unistyles';
9
+
10
+ const App = (): React.JSX.Element => {
11
+ const isDarkMode = useColorScheme() === 'dark';
12
+
13
+ useLayoutEffect(() => {
14
+ checkLocalStorage();
15
+ }, []);
16
+
17
+ return (
18
+ <Provider store={store}>
19
+ <SafeAreaProvider>
20
+ <StatusBar barStyle={isDarkMode ? 'light-content' : 'dark-content'} />
21
+ <Routes />
22
+ </SafeAreaProvider>
23
+ </Provider>
24
+ );
25
+ };
26
+
27
+ export default App;