nx-react-native-cli 1.1.0 → 2.0.0

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 (57) hide show
  1. package/README.md +69 -21
  2. package/lib/index.cjs +49 -39
  3. package/package.json +1 -1
  4. package/templates/.husky/pre-commit +0 -3
  5. package/templates/.husky/pre-push +0 -3
  6. package/templates/.vscode/settings.json +2 -5
  7. package/templates/apps/mobile/.eslintrc.json +4 -1
  8. package/templates/apps/mobile/Gemfile +5 -0
  9. package/templates/apps/mobile/android/app/build.gradle +3 -3
  10. package/templates/apps/mobile/android/app/src/main/java/com/appsmobile/MainActivity.kt +28 -0
  11. package/templates/apps/mobile/android/app/src/main/java/com/appsmobile/MainApplication.kt +2 -1
  12. package/templates/apps/mobile/android/build.gradle +3 -3
  13. package/templates/apps/mobile/android/gradle/wrapper/gradle-wrapper.properties +2 -2
  14. package/templates/apps/mobile/android/gradlew +4 -2
  15. package/templates/apps/mobile/android/gradlew.bat +2 -0
  16. package/templates/apps/mobile/babel.config.json +23 -0
  17. package/templates/apps/mobile/fastlane/.env.template +7 -2
  18. package/templates/apps/mobile/fastlane/Fastfile +46 -5
  19. package/templates/apps/mobile/fastlane/Matchfile +3 -3
  20. package/templates/apps/mobile/ios/AppDelegate.mm +33 -0
  21. package/templates/apps/mobile/metro.config.js +42 -0
  22. package/templates/apps/mobile/package.json +2 -3
  23. package/templates/apps/mobile/project.json +2 -1
  24. package/templates/apps/mobile/src/app/index.tsx +22 -7
  25. package/templates/apps/mobile/src/components/atoms/BottomSheet/bottom-sheet.component.tsx +9 -4
  26. package/templates/apps/mobile/src/components/atoms/Button/button.component.tsx +3 -3
  27. package/templates/apps/mobile/src/components/atoms/Divider/divider-component.tsx +3 -3
  28. package/templates/apps/mobile/src/components/atoms/ExcludedEdges/excluded-edges.component.tsx +2 -2
  29. package/templates/apps/mobile/src/components/atoms/InputLayout/input-layout.component.tsx +3 -3
  30. package/templates/apps/mobile/src/components/atoms/KeyboardAwareScrollView/keyboard-aware-scroll-view.component.tsx +11 -5
  31. package/templates/apps/mobile/src/components/atoms/ListLoadingItem/list-loading-item.component.tsx +4 -4
  32. package/templates/apps/mobile/src/components/atoms/Modal/modal.component.tsx +2 -2
  33. package/templates/apps/mobile/src/components/atoms/ScreenLoader/screen-loader.component.tsx +2 -2
  34. package/templates/apps/mobile/src/components/atoms/Skeleton/skeleton.component.tsx +7 -6
  35. package/templates/apps/mobile/src/components/atoms/TextInput/text-input.component.tsx +6 -4
  36. package/templates/apps/mobile/src/components/atoms/Typography/typography.component.tsx +2 -2
  37. package/templates/apps/mobile/src/components/molecules/BackButton/back-button.component.tsx +5 -5
  38. package/templates/apps/mobile/src/components/molecules/BottomActionsContainer/BottomActionsContainer.component.tsx +2 -2
  39. package/templates/apps/mobile/src/components/molecules/ScreenContainer/screen-container.component.tsx +11 -12
  40. package/templates/apps/mobile/src/components/molecules/ScreenHeader/screen-header.component.tsx +5 -5
  41. package/templates/apps/mobile/src/components/molecules/StorageManager/StorageManager.component.tsx +3 -1
  42. package/templates/apps/mobile/src/hooks/useGetLayoutHeight.hook.tsx +1 -1
  43. package/templates/apps/mobile/src/hooks/useGetLayoutWidth.hook.tsx +1 -1
  44. package/templates/apps/mobile/src/hooks/useNavigation.hook.tsx +1 -1
  45. package/templates/apps/mobile/src/hooks/useTextInputChangeFocus.hook.tsx +2 -2
  46. package/templates/apps/mobile/src/hooks/useToggleDarkMode.hook.tsx +1 -1
  47. package/templates/apps/mobile/src/main.tsx +1 -1
  48. package/templates/apps/mobile/src/routes/index.tsx +7 -7
  49. package/templates/apps/mobile/src/routes/privateRoutes.tsx +3 -4
  50. package/templates/apps/mobile/src/routes/publicRoutes.tsx +3 -4
  51. package/templates/apps/mobile/src/screens/HomeScreen/home.screen.tsx +3 -2
  52. package/templates/apps/mobile/src/screens/LandingScreen/landing.screen.tsx +12 -7
  53. package/templates/apps/mobile/src/stores/local-storage.store.ts +1 -1
  54. package/templates/apps/mobile/src/stores/mmkvStorage.ts +1 -1
  55. package/templates/apps/mobile/tsconfig.app.json +5 -1
  56. package/templates/clean-generated-outputs.sh +1 -1
  57. package/templates/apps/mobile/.env +0 -3
@@ -1,10 +1,10 @@
1
1
  import React from 'react';
2
-
3
- import { tw } from '../../../tailwind';
4
- import { DefaultComponentProps } from '../../../types';
5
- import { Skeleton } from '../Skeleton';
6
2
  import { View } from 'react-native';
7
3
 
4
+ import { Skeleton } from '@/components/atoms/Skeleton';
5
+ import { tw } from '@/tailwind';
6
+ import { DefaultComponentProps } from '@/types';
7
+
8
8
  type Props = DefaultComponentProps & {
9
9
  isLoading: boolean;
10
10
  };
@@ -4,8 +4,8 @@ import React, { useCallback, useState } from 'react';
4
4
  import { Keyboard, ModalBaseProps, StyleProp, View, ViewStyle } from 'react-native';
5
5
  import RNModal from 'react-native-modal';
6
6
 
7
- import { tw } from '../../../tailwind';
8
- import { DefaultComponentProps } from '../../../types';
7
+ import { tw } from '@/tailwind';
8
+ import { DefaultComponentProps } from '@/types';
9
9
 
10
10
  export type ModalProps = DefaultComponentProps &
11
11
  ModalBaseProps & {
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
2
  import { ActivityIndicator, View } from 'react-native';
3
3
 
4
- import { colors, tw } from '../../../tailwind';
5
- import { DefaultComponentProps } from '../../../types/component.type';
4
+ import { colors, tw } from '@/tailwind';
5
+ import { DefaultComponentProps } from '@/types';
6
6
 
7
7
  type Props = DefaultComponentProps;
8
8
 
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import { View } from 'react-native';
2
3
  import Animated, {
3
4
  useAnimatedStyle,
4
5
  useSharedValue,
@@ -6,16 +7,16 @@ import Animated, {
6
7
  withTiming,
7
8
  } from 'react-native-reanimated';
8
9
 
9
- import { View } from 'react-native';
10
- import { tw } from '../../../tailwind';
10
+ import { tw } from '@/tailwind';
11
+ import { DefaultComponentProps } from '@/types';
11
12
 
12
- type Props = {
13
+ type Props = DefaultComponentProps & {
13
14
  children?: React.ReactNode;
14
15
  isLoading: boolean;
15
- }
16
+ };
16
17
 
17
18
  export function Skeleton(props: Props) {
18
- const { children, isLoading } = props;
19
+ const { children, isLoading, style } = props;
19
20
  const opacity = useSharedValue(1);
20
21
 
21
22
  const animatedStyle = useAnimatedStyle(
@@ -35,7 +36,7 @@ export function Skeleton(props: Props) {
35
36
  }
36
37
 
37
38
  return (
38
- <Animated.View style={[tw`rounded-lg bg-gray-200`, animatedStyle]}>
39
+ <Animated.View style={[tw`rounded-lg bg-gray-200`, animatedStyle, style]}>
39
40
  <View style={tw`opacity-0`}>{children}</View>
40
41
  </Animated.View>
41
42
  );
@@ -7,16 +7,18 @@ import {
7
7
  View,
8
8
  } from 'react-native';
9
9
 
10
+ import {
11
+ DefaultNameInputProps,
12
+ DefaultTextAreaInputProps,
13
+ } from '@/components/atoms/TextInput/constants';
10
14
  import {
11
15
  colors,
12
16
  defaultInputContainerStyle,
13
17
  defaultInputTextStyle,
14
18
  disabledInputStyle,
15
19
  focusedInputStyle,
16
- } from '../../../tailwind';
17
- import { DefaultComponentProps } from '../../../types';
18
-
19
- import { DefaultNameInputProps, DefaultTextAreaInputProps } from './constants';
20
+ } from '@/tailwind';
21
+ import { DefaultComponentProps } from '@/types';
20
22
 
21
23
  export const TEXT_INPUT_MIN_HEIGHT = 100;
22
24
  export const TEXT_INPUT_LINE_HEIGHT = 21;
@@ -1,7 +1,7 @@
1
- import React from 'react';
1
+ import React, { JSX } from 'react';
2
2
  import { Text as RNText, TextProps } from 'react-native';
3
3
 
4
- import { tw } from '../../../tailwind';
4
+ import { tw } from '@/tailwind';
5
5
 
6
6
  type Props = TextProps & {
7
7
  numberOfLines?: number;
@@ -10,11 +10,11 @@ import {
10
10
  ViewStyle,
11
11
  } from 'react-native';
12
12
 
13
- import { useNavigation } from '../../../hooks';
14
- import { ArrowLeftIcon } from '../../../icons';
15
- import { Screens } from '../../../routes';
16
- import { tw } from '../../../tailwind';
17
- import { DefaultComponentProps } from '../../../types/component.type';
13
+ import { useNavigation } from '@/hooks';
14
+ import { ArrowLeftIcon } from '@/icons';
15
+ import { Screens } from '@/routes';
16
+ import { tw } from '@/tailwind';
17
+ import { DefaultComponentProps } from '@/types';
18
18
 
19
19
  type Props = DefaultComponentProps &
20
20
  PressableProps & {
@@ -2,8 +2,8 @@ import React from 'react';
2
2
  import { ViewProps } from 'react-native';
3
3
  import { SafeAreaView } from 'react-native-safe-area-context';
4
4
 
5
- import { tw } from '../../../tailwind';
6
- import { DefaultComponentProps } from '../../../types';
5
+ import { tw } from '@/tailwind';
6
+ import { DefaultComponentProps } from '@/types';
7
7
 
8
8
  type Props = DefaultComponentProps &
9
9
  ViewProps & {
@@ -1,10 +1,12 @@
1
1
  import { useFocusEffect } from '@react-navigation/core';
2
- import React, { ReactElement, useEffect } from 'react';
2
+ import React, { ReactElement } from 'react';
3
3
  import {
4
4
  NativeScrollEvent,
5
5
  NativeSyntheticEvent,
6
6
  Platform,
7
+ RefreshControlProps,
7
8
  StatusBar,
9
+ StatusBarStyle,
8
10
  StyleProp,
9
11
  View,
10
12
  ViewStyle,
@@ -12,11 +14,12 @@ import {
12
14
  import { KeyboardAwareScrollView as RNKeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view';
13
15
  import { Edge, SafeAreaProviderProps, SafeAreaView } from 'react-native-safe-area-context';
14
16
 
15
- import CONFIG from '../../../config';
16
- import { tw } from '../../../tailwind';
17
- import { KeyboardAwareScrollView } from '../../atoms';
17
+ import { KeyboardAwareScrollView } from '@/components';
18
+ import CONFIG from '@/config';
19
+ import { tw } from '@/tailwind';
18
20
 
19
21
  type Props = SafeAreaProviderProps & {
22
+ barStyle?: StatusBarStyle;
20
23
  scrollViewRef?: React.RefObject<RNKeyboardAwareScrollView>;
21
24
  containerStyle?: StyleProp<ViewStyle>;
22
25
  excludedEdges?: Edge[];
@@ -39,6 +42,7 @@ const safeAreaViewEdges: Edge[] = Platform.select({
39
42
 
40
43
  export function ScreenContainer(props: Props) {
41
44
  const {
45
+ barStyle = 'dark-content',
42
46
  children,
43
47
  containerStyle,
44
48
  excludedEdges = [],
@@ -57,17 +61,12 @@ export function ScreenContainer(props: Props) {
57
61
  ? safeAreaViewEdges.filter((edge) => !excludedEdges.includes(edge))
58
62
  : safeAreaViewEdges;
59
63
 
60
- useEffect(() => {
61
- if (CONFIG.IS_ANDROID) {
62
- StatusBar.setBackgroundColor(statusBarColor);
63
- }
64
- }, [statusBarColor]);
65
-
66
64
  useFocusEffect(() => {
67
65
  StatusBar.setHidden(!shouldShowStatusBar);
68
66
  if (CONFIG.IS_ANDROID) {
69
67
  StatusBar.setBackgroundColor(statusBarColor);
70
68
  StatusBar.setTranslucent(!shouldBeTranslucent);
69
+ StatusBar.setBarStyle(barStyle);
71
70
  }
72
71
  });
73
72
 
@@ -79,11 +78,11 @@ export function ScreenContainer(props: Props) {
79
78
  ];
80
79
 
81
80
  return (
82
- <SafeAreaView edges={edges} style={[tw`flex-1 bg-gray-50`, style]}>
81
+ <SafeAreaView edges={edges} style={[tw`flex-1 bg-white`, style]}>
83
82
  {hasScroll ? (
84
83
  <KeyboardAwareScrollView
85
84
  containerStyle={defaultContainerStyle}
86
- refreshControl={refreshControl}
85
+ refreshControl={refreshControl as ReactElement<RefreshControlProps>}
87
86
  scrollViewRef={scrollViewRef}
88
87
  onScroll={onScroll}
89
88
  >
@@ -1,11 +1,11 @@
1
1
  import React from 'react';
2
2
  import { StyleProp, TouchableOpacity, View, ViewStyle } from 'react-native';
3
3
 
4
- import { GearIcon } from '../../../icons';
5
- import { tw } from '../../../tailwind';
6
- import { DefaultComponentProps } from '../../../types/component.type';
7
- import { Typography } from '../../atoms/Typography';
8
- import { BackButton } from '../BackButton';
4
+ import { Typography } from '@/components';
5
+ import { BackButton } from '@/components/molecules/BackButton';
6
+ import { GearIcon } from '@/icons';
7
+ import { tw } from '@/tailwind';
8
+ import { DefaultComponentProps } from '@/types';
9
9
 
10
10
  type Props = DefaultComponentProps & {
11
11
  hasBackButton?: boolean;
@@ -1,4 +1,6 @@
1
- import { useLocalStorageState } from '../../../stores';
1
+ import { JSX } from 'react';
2
+
3
+ import { useLocalStorageState } from '@/stores';
2
4
 
3
5
  type Props = {
4
6
  children: JSX.Element;
@@ -1,7 +1,7 @@
1
1
  import { useState } from 'react';
2
2
  import { LayoutChangeEvent } from 'react-native';
3
3
 
4
- import { useDebounce } from './useDebounce.hook';
4
+ import { useDebounce } from '@/hooks/useDebounce.hook';
5
5
 
6
6
  export function useGetLayoutHeight(
7
7
  initialHeight = 0,
@@ -1,7 +1,7 @@
1
1
  import { useState } from 'react';
2
2
  import { LayoutChangeEvent } from 'react-native';
3
3
 
4
- import { useDebounce } from './useDebounce.hook';
4
+ import { useDebounce } from '@/hooks/useDebounce.hook';
5
5
 
6
6
  export function useGetLayoutWidth(
7
7
  initialWidth = 0,
@@ -1,7 +1,7 @@
1
1
  import { ParamListBase, useNavigation as RNUseNavigation } from '@react-navigation/native';
2
2
  import { StackNavigationProp } from '@react-navigation/stack';
3
3
 
4
- import { PrivateStackParams, PublicStackParams } from '../routes';
4
+ import { PrivateStackParams, PublicStackParams } from '@/routes';
5
5
 
6
6
  export function useNavigation<T extends PublicStackParams | PrivateStackParams | ParamListBase>() {
7
7
  return RNUseNavigation<StackNavigationProp<T, keyof T>>();
@@ -1,8 +1,8 @@
1
1
  import React, { useRef } from 'react';
2
2
  import { TextInput } from 'react-native';
3
3
 
4
- export function useTextInputChangeFocus(): [React.MutableRefObject<TextInput>, () => void] {
5
- const ref = useRef() as React.MutableRefObject<TextInput>;
4
+ export function useTextInputChangeFocus(): [React.RefObject<TextInput>, () => void] {
5
+ const ref = useRef<any>(null) as React.RefObject<TextInput>;
6
6
 
7
7
  function changeFocus() {
8
8
  ref?.current?.focus();
@@ -1,6 +1,6 @@
1
1
  import { useAppColorScheme } from 'twrnc';
2
2
 
3
- import { tw } from '../tailwind';
3
+ import { tw } from '@/tailwind';
4
4
 
5
5
  export function useToggleDarkMode() {
6
6
  const [, toggleColorScheme] = useAppColorScheme(tw);
@@ -1,5 +1,5 @@
1
1
  import { AppRegistry } from 'react-native';
2
2
 
3
- import App from './app';
3
+ import App from '@/app';
4
4
 
5
5
  AppRegistry.registerComponent('AppsMobile', () => App);
@@ -3,13 +3,12 @@ import { createNativeStackNavigator } from '@react-navigation/native-stack';
3
3
  import React, { useEffect } from 'react';
4
4
  import { StatusBar } from 'react-native';
5
5
 
6
- import CONFIG from '../config';
7
- import { colors } from '../tailwind';
8
-
9
- import PrivateRoutes from './privateRoutes';
10
- import PublicRoutes from './publicRoutes';
11
- import { Routes } from './routes.enum';
12
- import { screenOptions } from './screen-options';
6
+ import CONFIG from '@/config';
7
+ import { Routes } from '@/routes';
8
+ import PrivateRoutes from '@/routes/privateRoutes';
9
+ import PublicRoutes from '@/routes/publicRoutes';
10
+ import { screenOptions } from '@/routes/screen-options';
11
+ import { colors } from '@/tailwind';
13
12
 
14
13
  const RootStack = createNativeStackNavigator();
15
14
 
@@ -36,6 +35,7 @@ export default function ApplicationRoutes() {
36
35
  if (CONFIG.IS_ANDROID) {
37
36
  StatusBar.setBackgroundColor('transparent');
38
37
  StatusBar.setTranslucent(true);
38
+ StatusBar.setBarStyle('dark-content');
39
39
  }
40
40
  }, []);
41
41
 
@@ -3,10 +3,9 @@ import { MaterialTopTabScreenProps } from '@react-navigation/material-top-tabs';
3
3
  import { createNativeStackNavigator, NativeStackScreenProps } from '@react-navigation/native-stack';
4
4
  import React from 'react';
5
5
 
6
- import { HomeScreen } from '../screens/HomeScreen/home.screen';
7
-
8
- import { screenOptions } from './screen-options';
9
- import { Screens } from './screens.enum';
6
+ import { Screens } from '@/routes';
7
+ import { screenOptions } from '@/routes/screen-options';
8
+ import { HomeScreen } from '@/screens/HomeScreen/home.screen';
10
9
 
11
10
  const PrivateStack = createNativeStackNavigator<PrivateStackParams>();
12
11
 
@@ -2,10 +2,9 @@ import { BottomSheetModalProvider } from '@gorhom/bottom-sheet';
2
2
  import { createNativeStackNavigator, NativeStackScreenProps } from '@react-navigation/native-stack';
3
3
  import React from 'react';
4
4
 
5
- import { LandingScreen } from '../screens/LandingScreen/landing.screen';
6
-
7
- import { screenOptions } from './screen-options';
8
- import { Screens } from './screens.enum';
5
+ import { Screens } from '@/routes';
6
+ import { screenOptions } from '@/routes/screen-options';
7
+ import { LandingScreen } from '@/screens/LandingScreen/landing.screen';
9
8
 
10
9
  const PublicStack = createNativeStackNavigator<PublicStackParams>();
11
10
 
@@ -1,7 +1,8 @@
1
1
  import React from 'react';
2
2
 
3
- import { ScreenContainer, Typography } from '../../components';
4
- import { PrivateScreenProps, Screens } from '../../routes';
3
+ import { ScreenContainer, Typography } from '@/components';
4
+ import { PrivateScreenProps } from '@/routes';
5
+ import { Screens } from '@/routes/screens.enum';
5
6
 
6
7
  export function HomeScreen(props: PrivateScreenProps<Screens.HOME>) {
7
8
  return (
@@ -1,31 +1,36 @@
1
1
  import React from 'react';
2
-
3
2
  import { View } from 'react-native';
3
+
4
4
  import {
5
5
  BottomSheet,
6
6
  Button,
7
+ Divider,
7
8
  OutlinedButton,
8
9
  ScreenContainer,
9
10
  ScreenHeader,
10
11
  Typography,
11
12
  useBottomSheet,
12
- } from '../../components';
13
- import { PublicScreenProps, Screens } from '../../routes';
14
- import { tw } from '../../tailwind';
15
- import { toast } from '../../utils';
13
+ } from '@/components';
14
+ import { ArrowLeftIcon, HomeIcon } from '@/icons';
15
+ import { PublicScreenProps, Screens } from '@/routes';
16
+ import { tw } from '@/tailwind';
17
+ import { toast } from '@/utils';
16
18
 
17
19
  export function LandingScreen(props: PublicScreenProps<Screens.LANDING>) {
18
20
  const { expandSheet, sheetRef } = useBottomSheet();
19
21
 
20
22
  function toastHi() {
21
- toast('Hi!')
23
+ toast('Hi!');
22
24
  }
23
25
 
24
26
  return (
25
27
  <ScreenContainer>
26
28
  <ScreenHeader title="Landing" onExtraActionPress={toastHi} />
29
+ <ArrowLeftIcon />
30
+ <Divider />
31
+ <HomeIcon />
27
32
  <View style={tw`mx-4`}>
28
- <View row style={tw`gap-2`}>
33
+ <View style={tw`gap-2`}>
29
34
  <Button title="Show Bottom Sheet" onPress={expandSheet} />
30
35
  <OutlinedButton title="Login" />
31
36
  </View>
@@ -1,7 +1,7 @@
1
1
  import { StateCreator, create } from 'zustand';
2
2
  import { PersistOptions, createJSONStorage, persist } from 'zustand/middleware';
3
3
 
4
- import { MmkvStorage } from './mmkvStorage';
4
+ import { MmkvStorage } from '@/stores/mmkvStorage';
5
5
 
6
6
  const initialState = {
7
7
  _hasHydrated: false,
@@ -1,7 +1,7 @@
1
1
  import { MMKV } from 'react-native-mmkv';
2
2
  import { StateStorage } from 'zustand/middleware';
3
3
 
4
- import CONFIG from '../config';
4
+ import CONFIG from '@/config';
5
5
 
6
6
  const storage = new MMKV({
7
7
  encryptionKey: CONFIG.STORAGE_KEY,
@@ -3,7 +3,11 @@
3
3
  "compilerOptions": {
4
4
  "outDir": "../../dist/out-tsc",
5
5
  "strict": true,
6
- "types": ["node"]
6
+ "types": ["node"],
7
+ "baseUrl": ".",
8
+ "paths": {
9
+ "@/*": ["src/*"]
10
+ }
7
11
  },
8
12
  "files": ["../../node_modules/@nx/react-native/typings/svg.d.ts"],
9
13
  "exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.spec.tsx", "test-setup.ts"],
@@ -27,6 +27,6 @@ rm -rf "$app_rn_ios_build_path"
27
27
  echo "Deleting $app_rn_android_gradle_path..."
28
28
  rm -rf "$app_rn_android_gradle_path"
29
29
 
30
- npm install
30
+ yarn install
31
31
 
32
32
  echo "Done!"
@@ -1,3 +0,0 @@
1
- IS_LIVE=false
2
- STORAGE_KEY=MMKV-STORAGE-KEY
3
- API_BASE_URL=