@momo-kits/foundation 0.92.3-tracking.2 → 0.92.3-tracking.4

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.
@@ -86,7 +86,6 @@ const InputDropDown = ({
86
86
  accessibilityLabel={accessibilityLabel}
87
87
  onPressIn={onPress}
88
88
  editable={false}
89
- textAlignVertical="top"
90
89
  style={[
91
90
  styles.input,
92
91
  {
@@ -119,7 +119,6 @@ const InputMoney = forwardRef(
119
119
  {...props}
120
120
  accessibilityLabel={accessibilityLabel}
121
121
  editable={!disabled}
122
- textAlignVertical="top"
123
122
  ref={inputRef}
124
123
  keyboardType={'number-pad'}
125
124
  style={[
package/Title/index.tsx CHANGED
@@ -22,8 +22,10 @@ const Title: FC<TitleProps> = ({
22
22
  badgeLabel,
23
23
  buttonTitle,
24
24
  onPressRightAction = () => {},
25
+ onPressTrailingAction = () => {},
25
26
  buttonSize = 'small',
26
27
  textOnly = false,
28
+ style,
27
29
  }) => {
28
30
  const {theme} = useContext(ApplicationContext);
29
31
  const [badgeWidth, setBadgeWidth] = useState(0);
@@ -90,18 +92,23 @@ const Title: FC<TitleProps> = ({
90
92
  )}
91
93
  {renderActionLeft()}
92
94
  </View>
93
- <Text
94
- color={theme.colors.text.secondary}
95
- typography={'description_default_regular'}>
96
- {description}
97
- </Text>
95
+ {description && (
96
+ <Text
97
+ style={styles.description}
98
+ color={theme.colors.text.secondary}
99
+ typography={'description_default_regular'}>
100
+ {description}
101
+ </Text>
102
+ )}
98
103
  </View>
99
104
  );
100
105
  };
101
106
 
102
107
  const renderActionLeft = () => {
103
108
  return (
104
- <View style={styles.iconLeftView}>
109
+ <TouchableOpacity
110
+ onPress={onPressTrailingAction}
111
+ style={styles.iconLeftView}>
105
112
  {showTrailingAction && !showRightAction && (
106
113
  <View
107
114
  style={[
@@ -119,7 +126,7 @@ const Title: FC<TitleProps> = ({
119
126
  />
120
127
  </View>
121
128
  )}
122
- </View>
129
+ </TouchableOpacity>
123
130
  );
124
131
  };
125
132
 
@@ -129,7 +136,8 @@ const Title: FC<TitleProps> = ({
129
136
  return (
130
137
  <View>
131
138
  {!buttonTitle ? (
132
- <View
139
+ <TouchableOpacity
140
+ onPress={onPressRightAction}
133
141
  style={[
134
142
  styles.iconRight,
135
143
  {
@@ -141,7 +149,7 @@ const Title: FC<TitleProps> = ({
141
149
  size={scaleSize(22)}
142
150
  color={theme.colors.primary}
143
151
  />
144
- </View>
152
+ </TouchableOpacity>
145
153
  ) : (
146
154
  <TouchableOpacity onPress={onPressRightAction}>
147
155
  <Text color={theme.colors.primary} typography={buttonTypo}>
@@ -166,7 +174,7 @@ const Title: FC<TitleProps> = ({
166
174
  }
167
175
 
168
176
  return (
169
- <View style={[styles.wrapper, isSection && styles.margin]}>
177
+ <View style={[style, styles.wrapper, isSection && styles.margin]}>
170
178
  {renderIcon()}
171
179
  {renderContent()}
172
180
  {renderActionRight()}
package/Title/styles.ts CHANGED
@@ -68,9 +68,12 @@ export default StyleSheet.create({
68
68
  contentView: {marginRight: Spacing.S, flex: 1},
69
69
  title: {
70
70
  fontWeight: 'bold',
71
- marginBottom: Spacing.XS,
71
+ color: Colors.black_17,
72
72
  },
73
73
  badge: {
74
74
  marginLeft: Spacing.XS,
75
75
  },
76
+ description: {
77
+ marginTop: Spacing.XS,
78
+ },
76
79
  });
package/Title/types.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import {ViewStyle} from 'react-native';
2
+
1
3
  export type TitleProps = {
2
4
  type?: 'card' | 'section';
3
5
  size?: 'small' | 'medium' | 'large';
@@ -12,5 +14,7 @@ export type TitleProps = {
12
14
  buttonTitle?: string;
13
15
  buttonSize?: 'small' | 'large';
14
16
  onPressRightAction?: () => void;
17
+ onPressTrailingAction?: () => void;
15
18
  textOnly?: boolean;
19
+ style?: ViewStyle;
16
20
  };
package/code-scanner.js CHANGED
@@ -1,51 +1,143 @@
1
1
  const scanner = require('react-scanner');
2
+ const fs = require('fs');
2
3
  const path = require('path');
3
4
 
4
- const scan = async config => {
5
- return await scanner.run(config);
5
+ const scan = async (config) => {
6
+ return await scanner.run(config);
6
7
  };
7
8
 
8
- const calcSum = array => {
9
- return array.reduce((a, b) => a + b, 0);
9
+ const calcSum = (array) => {
10
+ return array.reduce((a, b) => a + b, 0);
10
11
  };
11
12
 
12
- const calculateAdoptionRate = (kitJsonPath, miniappJsonPath) => {
13
- const kitJson = require(kitJsonPath);
14
- const miniAppJson = require(miniappJsonPath);
15
- const numOfKitComponents = calcSum(Object.values(kitJson));
16
- const numOfMiniAppComponents = calcSum(Object.values(miniAppJson));
17
- const adoptionRate = (numOfKitComponents / numOfMiniAppComponents) * 100;
18
- console.log("Number of kit's components: ", numOfKitComponents);
19
- console.log("Number of miniapp's components: ", numOfMiniAppComponents);
20
- console.log('Adoption rate: ', adoptionRate);
13
+ const calculateAdoptionRate = async (branchName , kitJsonPath , miniappJsonPath , reactNativeJsonPath , fsJsonPath ) => {
14
+ const kitJson = require(kitJsonPath);
15
+ const miniAppJson = require(miniappJsonPath);
16
+ const reactNativeJson = require(reactNativeJsonPath);
17
+ const fsJson = require(fsJsonPath);
18
+
19
+ const numOfKitComponents = calcSum(Object.values(kitJson));
20
+ const numOfMiniAppComponents = calcSum(Object.values(miniAppJson));
21
+ const numOfReactNativeComponents = calcSum(Object.values(reactNativeJson));
22
+ const numOfFSComponents = calcSum(Object.values(fsJson));
23
+
24
+ const adoptionRate = ((numOfKitComponents + numOfReactNativeComponents + numOfFSComponents) / numOfMiniAppComponents) * 100;
25
+
26
+ return {
27
+ miniAppName: branchName,
28
+ numOfKitComponents: numOfKitComponents,
29
+ numOfMiniAppComponents: numOfMiniAppComponents,
30
+ numOfReactNativeComponents: numOfReactNativeComponents,
31
+ numOfFSComponents: numOfFSComponents,
32
+ adoptionRate: adoptionRate.toFixed(2) + '%'
33
+ }
21
34
  };
22
35
 
36
+ function ensureFileExists(filePath , defaultContent = {}) {
37
+ if (!fs.existsSync(filePath)) {
38
+ fs.mkdirSync(path.dirname(filePath), { recursive: true });
39
+ fs.writeFileSync(filePath, JSON.stringify(defaultContent, null, 2));
40
+ }
41
+ }
42
+
43
+ const sendMessage = ({
44
+ numOfKitComponents,
45
+ numOfMiniAppComponents,
46
+ numOfFSComponents,
47
+ numOfReactNativeComponents,
48
+ adoptionRate,
49
+ miniAppName = ''
50
+ }) => {
51
+ const url = 'https://chat.googleapis.com/v1/spaces/AAAAL9P6G8M/messages?key=AIzaSyDdI0hCZtE6vySjMm-WEfRq3CPzqKqqsHI&token=fnwfYuH_u0KicBnKTSSm9S0qV6azJH5v6URm8HR7V2g';
52
+
53
+ const data = {
54
+ 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}`
55
+ };
56
+
57
+ fetch(url, {
58
+ method: 'POST',
59
+ headers: {
60
+ 'Content-Type': 'application/json'
61
+ },
62
+ body: JSON.stringify(data)
63
+ })
64
+ .then(response => response.json())
65
+ .then(data => {
66
+ console.log('Success:', data);
67
+ })
68
+ .catch((error) => {
69
+ console.error('Error:', error);
70
+ });
71
+ }
72
+
23
73
  const main = async () => {
24
- const [scanPath, kitJsonRelativePath, miniappJsonRelativePath] =
25
- process.argv.slice(2);
26
-
27
- const kitJsonPath = path.resolve(process.cwd(), kitJsonRelativePath);
28
- const miniappJsonPath = path.resolve(process.cwd(), miniappJsonRelativePath);
29
-
30
- const config1 = {
31
- crawlFrom: scanPath,
32
- includeSubComponents: true,
33
- importedFrom: /@momo-kits\/.+/,
34
- processors: [['count-components', {outputTo: kitJsonPath}]],
35
- rootDir: './',
36
- };
37
-
38
- const config2 = {
39
- crawlFrom: scanPath,
40
- includeSubComponents: true,
41
- processors: [['count-components', {outputTo: miniappJsonPath}]],
42
- rootDir: './',
43
- };
44
-
45
- await scan(config1);
46
- await scan(config2);
47
-
48
- calculateAdoptionRate(kitJsonPath, miniappJsonPath);
74
+ const rootPath = `${__dirname}/../../../`
75
+ const app = path.join(`${__dirname}/../../../`, 'app.json');
76
+ const appJson = require(app)
77
+ const branchName = appJson.appId
78
+
79
+ if (!branchName || !branchName.includes("vn.momo")){
80
+ return
81
+ }
82
+
83
+ const scanPath = path.join(rootPath, 'src')
84
+ const kitJsonPath = path.join(rootPath, './scan/kit.json')
85
+ const miniappJsonPath = path.join(rootPath, './scan/miniapp.json')
86
+ const reactNativeJsonPath = path.join(rootPath, './scan/RN.json')
87
+ const fsJsonPath = path.join(rootPath, './scan/verLib.json')
88
+
89
+ const allKitsReg = /@momo-kits/;
90
+ const fsReg = /^(?:@fs-mobile-platform\/(components|investment|screens)|@miniapp-platform\/(components|foundation))$/;
91
+ const RNReg = 'react-native'
92
+
93
+ const config1 = {
94
+ crawlFrom: scanPath,
95
+ includeSubComponents: true,
96
+ importedFrom: allKitsReg,
97
+ processors: [['count-components', { outputTo: kitJsonPath }]],
98
+ rootDir: process.cwd(),
99
+ };
100
+
101
+ const config2 = {
102
+ crawlFrom: scanPath,
103
+ includeSubComponents: true,
104
+ processors: [['count-components', { outputTo: miniappJsonPath }]],
105
+ rootDir: process.cwd(),
106
+ };
107
+
108
+ const config3 = {
109
+ crawlFrom: scanPath,
110
+ includeSubComponents: true,
111
+ importedFrom: RNReg,
112
+ processors: [['count-components', { outputTo: reactNativeJsonPath }]],
113
+ rootDir: process.cwd(),
114
+ };
115
+
116
+ const config4 = {
117
+ crawlFrom: scanPath,
118
+ includeSubComponents: true,
119
+ importedFrom: fsReg,
120
+ processors: [['count-components', { outputTo: fsJsonPath }]],
121
+ rootDir: process.cwd(),
122
+ };
123
+
124
+ try {
125
+ ensureFileExists(kitJsonPath, {});
126
+ ensureFileExists(miniappJsonPath, {});
127
+ ensureFileExists(reactNativeJsonPath, {});
128
+ ensureFileExists(fsJsonPath, {});
129
+
130
+ await scan(config1);
131
+ await scan(config2);
132
+ await scan(config3);
133
+ await scan(config4);
134
+
135
+ const result = await calculateAdoptionRate(branchName,kitJsonPath, miniappJsonPath, reactNativeJsonPath, fsJsonPath);
136
+ sendMessage(result)
137
+ console.log(result)
138
+ } catch (error) {
139
+ console.error("Error during scan or calculation:", error);
140
+ }
49
141
  };
50
142
 
51
- main().catch(console.error);
143
+ main();
@@ -0,0 +1,56 @@
1
+ const {readFileSync, writeFileSync, readdirSync, statSync} = require('fs');
2
+ const path = require('path');
3
+ let rootPath = process.argv[2];
4
+
5
+ const migrateText = [
6
+ {typo1: 'headline_s', typo2: 'headline_default_bold'},
7
+ {typo1: 'header_s', typo2: 'header_s_semibold'},
8
+ {typo1: 'header_xs', typo2: 'header_xs_semibold'},
9
+ {typo1: 'description_default', typo2: 'body_default_regular'},
10
+ {typo1: 'description_s', typo2: 'description_default_regular'},
11
+ {typo1: 'description_xs', typo2: 'description_xs_regular'},
12
+ {typo1: 'label_default', typo2: 'label_default_medium'},
13
+ {typo1: 'label_s', typo2: 'label_s_medium'},
14
+ {typo1: 'label_xs', typo2: 'label_xs_medium'},
15
+ {typo1: 'action_default', typo2: 'action_default_bold'},
16
+ {typo1: 'action_xs', typo2: 'action_xs_bold'},
17
+ {typo1: 'action_xxs', typo2: 'action_xxs_bold'},
18
+ ];
19
+
20
+ function replaceTextInFile(oldText, newText, filePath) {
21
+ try {
22
+ let content = readFileSync(filePath, {encoding: 'utf-8'});
23
+ const regex = new RegExp(`\\b${oldText}\\b`, 'g');
24
+ content = content.replace(regex, newText);
25
+ writeFileSync(filePath, content, 'utf8');
26
+ console.log(`Replaced text in: ${filePath}`);
27
+ } catch (error) {
28
+ console.error(`Error processing file ${filePath}:`, error);
29
+ }
30
+ }
31
+
32
+ function scanDirectory(directory, oldText, newText) {
33
+ const files = readdirSync(directory);
34
+
35
+ files.forEach(file => {
36
+ const filePath = path.join(directory, file);
37
+ const stat = statSync(filePath);
38
+
39
+ if (stat.isDirectory()) {
40
+ scanDirectory(filePath, oldText, newText);
41
+ } else if (
42
+ stat.isFile() &&
43
+ (filePath.endsWith('.tsx') || filePath.endsWith('.ts'))
44
+ ) {
45
+ replaceTextInFile(oldText, newText, filePath);
46
+ }
47
+ });
48
+ }
49
+
50
+ function main() {
51
+ migrateText.forEach(({typo1, typo2}) => {
52
+ scanDirectory(rootPath, typo1, typo2);
53
+ });
54
+ }
55
+
56
+ main();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.92.3-tracking.2",
3
+ "version": "0.92.3-tracking.4",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {