@momo-kits/foundation 0.92.8 → 0.92.9-beta.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.
- package/Application/BottomSheet.tsx +93 -100
- package/Application/BottomTab/BottomTabBar.tsx +5 -18
- package/Application/BottomTab/index.tsx +13 -8
- package/Application/Components.tsx +4 -4
- package/Application/StackScreen.tsx +0 -1
- package/Application/types.ts +5 -4
- package/Application/utils.tsx +1 -1
- package/Assets/icon_bank.json +1 -1
- package/Button/index.tsx +7 -7
- package/Icon/index.tsx +1 -1
- package/Icon/types.ts +1 -1
- package/Image/index.tsx +0 -1
- package/Input/InputDropDown.tsx +2 -2
- package/Input/InputMoney.tsx +9 -0
- package/Input/InputOTP.tsx +4 -7
- package/Input/InputTextArea.tsx +0 -1
- package/Input/index.tsx +12 -18
- package/Input/utils.ts +1 -1
- package/Layout/Card.tsx +4 -3
- package/Layout/FloatingButton.tsx +3 -3
- package/Layout/GridSystem.tsx +1 -1
- package/Layout/Screen.tsx +16 -13
- package/Layout/Section.tsx +4 -3
- package/Layout/utils.ts +2 -2
- package/Loader/index.tsx +2 -0
- package/Popup/PopupNotify.tsx +4 -4
- package/Popup/PopupPromotion.tsx +1 -1
- package/Popup/types.ts +1 -1
- package/Title/index.tsx +7 -2
- package/code-scanner.js +141 -124
- package/package.json +2 -2
- package/publish.sh +21 -16
- package/tsconfig.json +1 -1
package/Input/index.tsx
CHANGED
|
@@ -6,13 +6,6 @@ import InputOTP from './InputOTP';
|
|
|
6
6
|
import InputSearch from './InputSearch';
|
|
7
7
|
import InputTextArea from './InputTextArea';
|
|
8
8
|
|
|
9
|
-
export interface InputRef {
|
|
10
|
-
focus: () => void;
|
|
11
|
-
blur: () => void;
|
|
12
|
-
clear: () => void;
|
|
13
|
-
setText: (text: string) => void;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
9
|
export interface InputProps extends TextInputProps {
|
|
17
10
|
/**
|
|
18
11
|
* Optional. Defines the size of the Input component.
|
|
@@ -105,14 +98,8 @@ export interface InputProps extends TextInputProps {
|
|
|
105
98
|
hintText?: string;
|
|
106
99
|
}
|
|
107
100
|
|
|
108
|
-
|
|
109
|
-
InputProps,
|
|
110
|
-
'size' | 'icon' | 'iconColor'
|
|
111
|
-
>;
|
|
112
|
-
|
|
113
|
-
type InputPropsWithoutPlaceholder = Omit<InputProps, 'placeholder'>;
|
|
114
|
-
|
|
115
|
-
export interface InputTextAreaProps extends InputPropsWithoutSizeAndIcon {
|
|
101
|
+
export interface InputTextAreaProps
|
|
102
|
+
extends Omit<InputProps, 'size' | 'icon' | 'iconColor'> {
|
|
116
103
|
/**
|
|
117
104
|
* Optional. Defines the height of the InputTextArea component.
|
|
118
105
|
* It can be used to set a specific height for the text area.
|
|
@@ -132,6 +119,9 @@ export interface InputSearchProps extends TextInputProps {
|
|
|
132
119
|
*/
|
|
133
120
|
showButtonText?: boolean;
|
|
134
121
|
|
|
122
|
+
/**
|
|
123
|
+
* Optional. Represents the value for the floating title in the InputSearch component.
|
|
124
|
+
*/
|
|
135
125
|
onPressButtonText?: () => void;
|
|
136
126
|
|
|
137
127
|
/**
|
|
@@ -145,18 +135,22 @@ export interface InputSearchProps extends TextInputProps {
|
|
|
145
135
|
icon?: string;
|
|
146
136
|
|
|
147
137
|
/**
|
|
148
|
-
*
|
|
138
|
+
* Optional. If `true`, the user won't be able to interact with the Input component.
|
|
149
139
|
*/
|
|
150
140
|
hasColorBG?: boolean;
|
|
151
141
|
|
|
142
|
+
/**
|
|
143
|
+
* Optional. Represents the style of the InputSearch component.
|
|
144
|
+
*/
|
|
152
145
|
params?: any;
|
|
153
146
|
}
|
|
154
147
|
|
|
155
|
-
export interface InputMoneyProps extends
|
|
148
|
+
export interface InputMoneyProps extends Omit<InputProps, 'placeholder'> {}
|
|
156
149
|
|
|
157
150
|
export type OTPInputLength = 2 | 4 | 6 | 8 | 10;
|
|
158
151
|
|
|
159
|
-
export interface InputOTPProps
|
|
152
|
+
export interface InputOTPProps
|
|
153
|
+
extends Omit<InputProps, 'size' | 'icon' | 'iconColor'> {
|
|
160
154
|
/**
|
|
161
155
|
* Optional. Defines the length of the OTP (One Time Password) input.
|
|
162
156
|
* Can be 2, 4, 6, 8, or 10.
|
package/Input/utils.ts
CHANGED
|
@@ -61,7 +61,7 @@ const formatMoneyToNumber = (money: string, currencyUnit: string) => {
|
|
|
61
61
|
};
|
|
62
62
|
const checkTyping = (text: string, value: boolean, setValue: any) => {
|
|
63
63
|
let typing = text?.length > 0;
|
|
64
|
-
if (typing
|
|
64
|
+
if (typing !== value) {
|
|
65
65
|
setValue(typing);
|
|
66
66
|
}
|
|
67
67
|
};
|
package/Layout/Card.tsx
CHANGED
|
@@ -86,7 +86,7 @@ const Card: React.FC<CardProps> = ({
|
|
|
86
86
|
{rows.map((i: React.ReactElement, index: number) => {
|
|
87
87
|
return (
|
|
88
88
|
<View key={`Item${cursor}${index}`} style={{flexDirection: 'row'}}>
|
|
89
|
-
{index
|
|
89
|
+
{index !== 0 && (
|
|
90
90
|
<View style={{width: gridContext.gutterSize}}></View>
|
|
91
91
|
)}
|
|
92
92
|
{i}
|
|
@@ -126,14 +126,14 @@ const Card: React.FC<CardProps> = ({
|
|
|
126
126
|
rows = [item];
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
-
if (i
|
|
129
|
+
if (i === arrayChild.length - 1) {
|
|
130
130
|
cursor += 1;
|
|
131
131
|
element.push(addRowView(rows, cursor, true));
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
} else {
|
|
135
135
|
element.push(children);
|
|
136
|
-
if (children?.type
|
|
136
|
+
if (children?.type === Fragment) {
|
|
137
137
|
return renderView(children?.props.children);
|
|
138
138
|
}
|
|
139
139
|
}
|
|
@@ -144,6 +144,7 @@ const Card: React.FC<CardProps> = ({
|
|
|
144
144
|
<GridContext.Provider value={gridContext}>
|
|
145
145
|
<View
|
|
146
146
|
{...props}
|
|
147
|
+
onLayout={undefined}
|
|
147
148
|
style={[
|
|
148
149
|
{backgroundColor: theme.colors.background.surface},
|
|
149
150
|
style,
|
|
@@ -34,7 +34,7 @@ export const FloatingButton: React.FC<FloatingButtonProps> = ({
|
|
|
34
34
|
}: FloatingButtonProps) => {
|
|
35
35
|
const {theme} = useContext(ApplicationContext);
|
|
36
36
|
const maxWidth = useRef(0);
|
|
37
|
-
const minWidth = size
|
|
37
|
+
const minWidth = size === 'small' ? 36 : 48;
|
|
38
38
|
const [opacityAnimated] = useState(new Animated.Value(0)); // Initial opacity set to 0
|
|
39
39
|
const [widthAnimated, setWidthAnimated] = useState<Animated.Value>();
|
|
40
40
|
const lastOffset = useRef(0);
|
|
@@ -84,7 +84,7 @@ export const FloatingButton: React.FC<FloatingButtonProps> = ({
|
|
|
84
84
|
});
|
|
85
85
|
|
|
86
86
|
return () => {
|
|
87
|
-
if (listener
|
|
87
|
+
if (listener !== null) {
|
|
88
88
|
animatedValue?.removeListener(listener);
|
|
89
89
|
}
|
|
90
90
|
};
|
|
@@ -123,7 +123,7 @@ export const FloatingButton: React.FC<FloatingButtonProps> = ({
|
|
|
123
123
|
right: position === 'right' ? 12 : undefined,
|
|
124
124
|
alignSelf: position === 'center' ? 'center' : 'flex-end',
|
|
125
125
|
width: widthAnimated,
|
|
126
|
-
height: size
|
|
126
|
+
height: size === 'small' ? 36 : 48,
|
|
127
127
|
backgroundColor: theme.colors.primary,
|
|
128
128
|
bottom,
|
|
129
129
|
},
|
package/Layout/GridSystem.tsx
CHANGED
|
@@ -53,7 +53,7 @@ const GridSystem: React.FC<any> = ({
|
|
|
53
53
|
{list.map((_, index) => {
|
|
54
54
|
return (
|
|
55
55
|
<View style={{flexDirection: 'row'}} key={index.toString()}>
|
|
56
|
-
{index
|
|
56
|
+
{index !== -0 && <View style={{width: grid.gutterSize}} />}
|
|
57
57
|
<View
|
|
58
58
|
key={`Grid${index.toString()}`}
|
|
59
59
|
pointerEvents="none"
|
package/Layout/Screen.tsx
CHANGED
|
@@ -33,6 +33,9 @@ import styles from './styles';
|
|
|
33
33
|
import {HeaderType} from './types';
|
|
34
34
|
|
|
35
35
|
export interface ScreenProps extends ViewProps {
|
|
36
|
+
/**
|
|
37
|
+
* ReactNode representing the content of the screen.
|
|
38
|
+
*/
|
|
36
39
|
children: React.ReactNode;
|
|
37
40
|
/**
|
|
38
41
|
* Optional. Navigation object for handling navigation actions.
|
|
@@ -90,9 +93,10 @@ export interface ScreenProps extends ViewProps {
|
|
|
90
93
|
floatingButtonProps?: Omit<FloatingButtonProps, 'animatedValue' | 'bottom'>;
|
|
91
94
|
|
|
92
95
|
/**
|
|
93
|
-
*
|
|
96
|
+
* Optional. Keyboard vertical offset.
|
|
94
97
|
*/
|
|
95
|
-
|
|
98
|
+
keyboardVerticalOffset?: number;
|
|
99
|
+
|
|
96
100
|
/**
|
|
97
101
|
* Optional. If `true`, the screen content is using grid layout by span.
|
|
98
102
|
*/
|
|
@@ -115,13 +119,11 @@ const Screen = forwardRef(
|
|
|
115
119
|
headerType = 'default',
|
|
116
120
|
floatingButtonProps,
|
|
117
121
|
useGridLayout = true,
|
|
118
|
-
|
|
122
|
+
keyboardVerticalOffset,
|
|
119
123
|
}: ScreenProps,
|
|
120
124
|
ref,
|
|
121
125
|
) => {
|
|
122
|
-
const animatedValue = useRef<Animated.Value>(
|
|
123
|
-
animated ?? new Animated.Value(0),
|
|
124
|
-
);
|
|
126
|
+
const animatedValue = useRef<Animated.Value>(new Animated.Value(0));
|
|
125
127
|
const {theme} = useContext(ApplicationContext);
|
|
126
128
|
const insets = useSafeAreaInsets();
|
|
127
129
|
const heightHeader = useHeaderHeight();
|
|
@@ -132,10 +134,9 @@ const Screen = forwardRef(
|
|
|
132
134
|
let handleScroll;
|
|
133
135
|
let headerBackground: string | undefined = undefined;
|
|
134
136
|
let Component: any = View;
|
|
135
|
-
let
|
|
136
|
-
|
|
137
|
+
let keyboardOffset = heightHeader - 20;
|
|
137
138
|
if (headerType == 'extended' || animatedHeader) {
|
|
138
|
-
|
|
139
|
+
keyboardOffset = -20;
|
|
139
140
|
}
|
|
140
141
|
|
|
141
142
|
if (headerType == 'extended') {
|
|
@@ -235,7 +236,7 @@ const Screen = forwardRef(
|
|
|
235
236
|
if (scrollable) {
|
|
236
237
|
Component = Animated.ScrollView;
|
|
237
238
|
handleScroll = scrollViewProps?.onScroll;
|
|
238
|
-
if (animatedHeader || floatingButtonProps) {
|
|
239
|
+
if (animatedHeader || floatingButtonProps?.icon) {
|
|
239
240
|
handleScroll = Animated.event(
|
|
240
241
|
[
|
|
241
242
|
{
|
|
@@ -296,7 +297,8 @@ const Screen = forwardRef(
|
|
|
296
297
|
style={{
|
|
297
298
|
marginTop: space,
|
|
298
299
|
flex: item.props?.expanded ? 1 : undefined,
|
|
299
|
-
}}
|
|
300
|
+
}}
|
|
301
|
+
onLayout={item.props?.onLayout}>
|
|
300
302
|
{item}
|
|
301
303
|
</View>
|
|
302
304
|
);
|
|
@@ -314,7 +316,8 @@ const Screen = forwardRef(
|
|
|
314
316
|
style={{
|
|
315
317
|
marginTop: space,
|
|
316
318
|
flex: item?.props?.expanded ? 1 : undefined,
|
|
317
|
-
}}
|
|
319
|
+
}}
|
|
320
|
+
onLayout={item?.props?.onLayout}>
|
|
318
321
|
{children}
|
|
319
322
|
</View>
|
|
320
323
|
);
|
|
@@ -337,7 +340,7 @@ const Screen = forwardRef(
|
|
|
337
340
|
<KeyboardAvoidingView
|
|
338
341
|
style={Styles.flex}
|
|
339
342
|
enabled={enableKeyboardAvoidingView}
|
|
340
|
-
keyboardVerticalOffset={keyboardVerticalOffset}
|
|
343
|
+
keyboardVerticalOffset={keyboardVerticalOffset ?? keyboardOffset}
|
|
341
344
|
behavior={Platform.select({
|
|
342
345
|
ios: 'padding',
|
|
343
346
|
android: undefined,
|
package/Layout/Section.tsx
CHANGED
|
@@ -85,7 +85,7 @@ const Section: React.FC<SectionProps> = ({
|
|
|
85
85
|
{rows.map((i: React.ReactElement, index: number) => {
|
|
86
86
|
return (
|
|
87
87
|
<View key={`Card${cursor}${index}`} style={{flexDirection: 'row'}}>
|
|
88
|
-
{index
|
|
88
|
+
{index !== 0 && (
|
|
89
89
|
<View style={{width: gridContext.gutterSize}}></View>
|
|
90
90
|
)}
|
|
91
91
|
{i}
|
|
@@ -125,14 +125,14 @@ const Section: React.FC<SectionProps> = ({
|
|
|
125
125
|
rows = [item];
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
-
if (i
|
|
128
|
+
if (i === arrayChild.length - 1) {
|
|
129
129
|
cursor += 1;
|
|
130
130
|
element.push(addRowView(rows, cursor, true));
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
} else {
|
|
134
134
|
element.push(children);
|
|
135
|
-
if (children?.type
|
|
135
|
+
if (children?.type === Fragment) {
|
|
136
136
|
return renderView(children?.props.children);
|
|
137
137
|
}
|
|
138
138
|
}
|
|
@@ -151,6 +151,7 @@ const Section: React.FC<SectionProps> = ({
|
|
|
151
151
|
}}>
|
|
152
152
|
<View
|
|
153
153
|
{...props}
|
|
154
|
+
onLayout={undefined}
|
|
154
155
|
style={[
|
|
155
156
|
style,
|
|
156
157
|
styles.protectedStyle,
|
package/Layout/utils.ts
CHANGED
|
@@ -12,7 +12,7 @@ const validateChildren = (
|
|
|
12
12
|
) => {
|
|
13
13
|
const validateType = (child: React.ReactElement) => {
|
|
14
14
|
const valid = childrenTypes.some(
|
|
15
|
-
childrenType => child?.type === childrenType || child?.type
|
|
15
|
+
childrenType => child?.type === childrenType || child?.type === Fragment,
|
|
16
16
|
);
|
|
17
17
|
if (!valid) {
|
|
18
18
|
console.warn(
|
|
@@ -42,7 +42,7 @@ const useGridSystem = () => {
|
|
|
42
42
|
useEffect(() => {
|
|
43
43
|
const subscription: any = Dimensions.addEventListener('change', () => {
|
|
44
44
|
const newColumns = Dimensions.get('window').width > 600 ? 24 : 12;
|
|
45
|
-
if (newColumns
|
|
45
|
+
if (newColumns !== numberOfColumns) {
|
|
46
46
|
setNumberOfColumns(newColumns);
|
|
47
47
|
}
|
|
48
48
|
});
|
package/Loader/index.tsx
CHANGED
package/Popup/PopupNotify.tsx
CHANGED
|
@@ -139,7 +139,7 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
|
|
|
139
139
|
);
|
|
140
140
|
};
|
|
141
141
|
|
|
142
|
-
if (buttonDirection
|
|
142
|
+
if (buttonDirection === 'auto') {
|
|
143
143
|
if (
|
|
144
144
|
secondary?.title &&
|
|
145
145
|
(secondary.title.length > 12 || primary.title.length > 12)
|
|
@@ -148,7 +148,7 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
|
|
|
148
148
|
}
|
|
149
149
|
return renderRow();
|
|
150
150
|
}
|
|
151
|
-
if (buttonDirection
|
|
151
|
+
if (buttonDirection === 'row') {
|
|
152
152
|
return renderRow();
|
|
153
153
|
}
|
|
154
154
|
return renderColumn();
|
|
@@ -188,7 +188,7 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
|
|
|
188
188
|
|
|
189
189
|
return (
|
|
190
190
|
<View
|
|
191
|
-
accessibilityLabel={'
|
|
191
|
+
accessibilityLabel={'popup_notify'}
|
|
192
192
|
style={[
|
|
193
193
|
styles.container,
|
|
194
194
|
{backgroundColor: theme.colors.background.surface},
|
|
@@ -204,7 +204,7 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
|
|
|
204
204
|
typography={'body_default_regular'}
|
|
205
205
|
onTextLayout={({nativeEvent: {lines}}) => {
|
|
206
206
|
const enableScroll = lines.length > 3;
|
|
207
|
-
if (enableScroll
|
|
207
|
+
if (enableScroll !== scrollContent) {
|
|
208
208
|
setScrollContent(enableScroll);
|
|
209
209
|
}
|
|
210
210
|
}}>
|
package/Popup/PopupPromotion.tsx
CHANGED
package/Popup/types.ts
CHANGED
|
@@ -18,7 +18,7 @@ export type PopupNotifyProps = {
|
|
|
18
18
|
/**
|
|
19
19
|
* `description`: Represents the description text to be displayed in the PopupNotify component.
|
|
20
20
|
*/
|
|
21
|
-
description
|
|
21
|
+
description?: string | React.ReactNode;
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* `error`: Optional. Represents additional error text to be displayed in the PopupNotify component.
|
package/Title/index.tsx
CHANGED
|
@@ -143,8 +143,14 @@ const Title: FC<TitleProps> = ({
|
|
|
143
143
|
const renderActionRight = () => {
|
|
144
144
|
if (!showRightAction || showTrailingAction) return false;
|
|
145
145
|
|
|
146
|
+
const lineHeight = styleSheet[typography].lineHeight;
|
|
147
|
+
|
|
146
148
|
return (
|
|
147
|
-
<View
|
|
149
|
+
<View
|
|
150
|
+
style={{
|
|
151
|
+
height: lineHeight,
|
|
152
|
+
justifyContent: 'center',
|
|
153
|
+
}}>
|
|
148
154
|
{!buttonTitle ? (
|
|
149
155
|
<TouchableOpacity
|
|
150
156
|
onPress={onPressRightAction}
|
|
@@ -174,7 +180,6 @@ const Title: FC<TitleProps> = ({
|
|
|
174
180
|
if (textOnly) {
|
|
175
181
|
return (
|
|
176
182
|
<View style={isSection && styles.margin}>
|
|
177
|
-
zZ
|
|
178
183
|
<RNText
|
|
179
184
|
numberOfLines={numberOfLines}
|
|
180
185
|
style={[styleSheet[typography], styles.title]}>
|
package/code-scanner.js
CHANGED
|
@@ -2,142 +2,159 @@ const scanner = require('react-scanner');
|
|
|
2
2
|
const fs = require('fs');
|
|
3
3
|
const path = require('path');
|
|
4
4
|
|
|
5
|
-
const scan = async
|
|
6
|
-
|
|
5
|
+
const scan = async config => {
|
|
6
|
+
return await scanner.run(config);
|
|
7
7
|
};
|
|
8
8
|
|
|
9
|
-
const calcSum =
|
|
10
|
-
|
|
9
|
+
const calcSum = array => {
|
|
10
|
+
return array.reduce((a, b) => a + b, 0);
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
const calculateAdoptionRate = async (
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
13
|
+
const calculateAdoptionRate = async (
|
|
14
|
+
branchName,
|
|
15
|
+
kitJsonPath,
|
|
16
|
+
miniappJsonPath,
|
|
17
|
+
reactNativeJsonPath,
|
|
18
|
+
fsJsonPath,
|
|
19
|
+
) => {
|
|
20
|
+
const kitJson = require(kitJsonPath);
|
|
21
|
+
const miniAppJson = require(miniappJsonPath);
|
|
22
|
+
const reactNativeJson = require(reactNativeJsonPath);
|
|
23
|
+
const fsJson = require(fsJsonPath);
|
|
24
|
+
|
|
25
|
+
const numOfKitComponents = calcSum(Object.values(kitJson));
|
|
26
|
+
const numOfMiniAppComponents = calcSum(Object.values(miniAppJson));
|
|
27
|
+
const numOfReactNativeComponents = calcSum(Object.values(reactNativeJson));
|
|
28
|
+
const numOfFSComponents = calcSum(Object.values(fsJson));
|
|
29
|
+
|
|
30
|
+
const adoptionRate =
|
|
31
|
+
((numOfKitComponents + numOfReactNativeComponents + numOfFSComponents) /
|
|
32
|
+
numOfMiniAppComponents) *
|
|
33
|
+
100;
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
miniAppName: branchName,
|
|
37
|
+
numOfKitComponents: numOfKitComponents,
|
|
38
|
+
numOfMiniAppComponents: numOfMiniAppComponents,
|
|
39
|
+
numOfReactNativeComponents: numOfReactNativeComponents,
|
|
40
|
+
numOfFSComponents: numOfFSComponents,
|
|
41
|
+
adoptionRate: adoptionRate.toFixed(2) + '%',
|
|
42
|
+
};
|
|
34
43
|
};
|
|
35
44
|
|
|
36
|
-
function ensureFileExists(filePath
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
45
|
+
function ensureFileExists(filePath, defaultContent = {}) {
|
|
46
|
+
if (!fs.existsSync(filePath)) {
|
|
47
|
+
fs.mkdirSync(path.dirname(filePath), {recursive: true});
|
|
48
|
+
fs.writeFileSync(filePath, JSON.stringify(defaultContent, null, 2));
|
|
49
|
+
}
|
|
41
50
|
}
|
|
42
51
|
|
|
43
52
|
const sendMessage = ({
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
53
|
+
numOfKitComponents,
|
|
54
|
+
numOfMiniAppComponents,
|
|
55
|
+
numOfFSComponents,
|
|
56
|
+
numOfReactNativeComponents,
|
|
57
|
+
adoptionRate,
|
|
58
|
+
miniAppName = '',
|
|
59
|
+
}) => {
|
|
60
|
+
const url =
|
|
61
|
+
'https://chat.googleapis.com/v1/spaces/AAAAL9P6G8M/messages?key=AIzaSyDdI0hCZtE6vySjMm-WEfRq3CPzqKqqsHI&token=fnwfYuH_u0KicBnKTSSm9S0qV6azJH5v6URm8HR7V2g';
|
|
62
|
+
|
|
63
|
+
const data = {
|
|
64
|
+
text: `MiniApp: ${miniAppName}\nNumber of kit's components: ${numOfKitComponents}\nNumber of miniapp's components: ${numOfMiniAppComponents}\nNumber of FS's components: ${numOfFSComponents}\nNumber of React Native's components: ${numOfReactNativeComponents}\nAdoption rate: ${adoptionRate}`,
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
fetch(url, {
|
|
68
|
+
method: 'POST',
|
|
69
|
+
headers: {
|
|
70
|
+
'Content-Type': 'application/json',
|
|
71
|
+
},
|
|
72
|
+
body: JSON.stringify(data),
|
|
73
|
+
})
|
|
74
|
+
.then(response => response.json())
|
|
75
|
+
.then(data => {
|
|
76
|
+
console.log('Success:', data);
|
|
63
77
|
})
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
.catch((error) => {
|
|
69
|
-
console.error('Error:', error);
|
|
70
|
-
});
|
|
71
|
-
}
|
|
78
|
+
.catch(error => {
|
|
79
|
+
console.error('Error:', error);
|
|
80
|
+
});
|
|
81
|
+
};
|
|
72
82
|
|
|
73
83
|
const main = async () => {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
84
|
+
const rootPath = `${__dirname}/../../../`;
|
|
85
|
+
const app = path.join(`${__dirname}/../../../`, 'app.json');
|
|
86
|
+
const appJson = require(app);
|
|
87
|
+
const branchName = appJson.appId;
|
|
88
|
+
|
|
89
|
+
if (!branchName || !branchName.includes('vn.momo')) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const scanPath = path.join(rootPath, 'src');
|
|
94
|
+
const kitJsonPath = path.join(rootPath, './scan/kit.json');
|
|
95
|
+
const miniappJsonPath = path.join(rootPath, './scan/miniapp.json');
|
|
96
|
+
const reactNativeJsonPath = path.join(rootPath, './scan/RN.json');
|
|
97
|
+
const fsJsonPath = path.join(rootPath, './scan/verLib.json');
|
|
98
|
+
|
|
99
|
+
const allKitsReg = /@momo-kits/;
|
|
100
|
+
const fsReg =
|
|
101
|
+
/^(?:@fs-mobile-platform\/(components|investment|screens)|@miniapp-platform\/(components|foundation))$/;
|
|
102
|
+
const RNReg = 'react-native';
|
|
103
|
+
|
|
104
|
+
const config1 = {
|
|
105
|
+
crawlFrom: scanPath,
|
|
106
|
+
includeSubComponents: true,
|
|
107
|
+
importedFrom: allKitsReg,
|
|
108
|
+
processors: [['count-components', {outputTo: kitJsonPath}]],
|
|
109
|
+
rootDir: process.cwd(),
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
const config2 = {
|
|
113
|
+
crawlFrom: scanPath,
|
|
114
|
+
includeSubComponents: true,
|
|
115
|
+
processors: [['count-components', {outputTo: miniappJsonPath}]],
|
|
116
|
+
rootDir: process.cwd(),
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
const config3 = {
|
|
120
|
+
crawlFrom: scanPath,
|
|
121
|
+
includeSubComponents: true,
|
|
122
|
+
importedFrom: RNReg,
|
|
123
|
+
processors: [['count-components', {outputTo: reactNativeJsonPath}]],
|
|
124
|
+
rootDir: process.cwd(),
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
const config4 = {
|
|
128
|
+
crawlFrom: scanPath,
|
|
129
|
+
includeSubComponents: true,
|
|
130
|
+
importedFrom: fsReg,
|
|
131
|
+
processors: [['count-components', {outputTo: fsJsonPath}]],
|
|
132
|
+
rootDir: process.cwd(),
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
try {
|
|
136
|
+
ensureFileExists(kitJsonPath, {});
|
|
137
|
+
ensureFileExists(miniappJsonPath, {});
|
|
138
|
+
ensureFileExists(reactNativeJsonPath, {});
|
|
139
|
+
ensureFileExists(fsJsonPath, {});
|
|
140
|
+
|
|
141
|
+
await scan(config1);
|
|
142
|
+
await scan(config2);
|
|
143
|
+
await scan(config3);
|
|
144
|
+
await scan(config4);
|
|
145
|
+
|
|
146
|
+
const result = await calculateAdoptionRate(
|
|
147
|
+
branchName,
|
|
148
|
+
kitJsonPath,
|
|
149
|
+
miniappJsonPath,
|
|
150
|
+
reactNativeJsonPath,
|
|
151
|
+
fsJsonPath,
|
|
152
|
+
);
|
|
153
|
+
sendMessage(result);
|
|
154
|
+
console.log(result);
|
|
155
|
+
} catch (error) {
|
|
156
|
+
console.error('Error during scan or calculation:', error);
|
|
157
|
+
}
|
|
141
158
|
};
|
|
142
159
|
|
|
143
160
|
main();
|