@momo-kits/foundation 0.92.2 → 0.92.3-tracking.10
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/BottomTab/BottomTabBar.tsx +1 -2
- package/Application/BottomTab/index.tsx +2 -2
- package/Application/Components.tsx +27 -34
- package/Application/NavigationContainer.tsx +2 -7
- package/Application/StackScreen.tsx +70 -64
- package/Application/index.ts +8 -8
- package/Application/types.ts +1 -1
- package/Application/utils.tsx +0 -37
- package/Button/index.tsx +11 -32
- package/CheckBox/index.tsx +10 -32
- package/CheckBox/types.ts +4 -6
- package/Icon/index.tsx +8 -8
- package/IconButton/index.tsx +8 -21
- package/Image/index.tsx +53 -38
- package/Image/types.ts +2 -0
- package/Input/Input.tsx +7 -35
- package/Input/InputDropDown.tsx +8 -35
- package/Input/InputMoney.tsx +7 -32
- package/Input/InputOTP.tsx +7 -27
- package/Input/InputSearch.tsx +6 -17
- package/Input/InputTextArea.tsx +1 -23
- package/Input/index.tsx +1 -9
- package/Popup/PopupNotify.tsx +5 -9
- package/Popup/PopupPromotion.tsx +6 -15
- package/Radio/index.tsx +9 -27
- package/Radio/types.ts +4 -7
- package/Switch/index.tsx +15 -26
- package/Switch/types.ts +4 -6
- package/Title/index.tsx +18 -10
- package/Title/styles.ts +4 -1
- package/Title/types.ts +4 -0
- package/code-scanner.js +131 -39
- package/migrate_typo.js +56 -0
- package/package.json +1 -1
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
|
-
|
|
5
|
+
const scan = async (config) => {
|
|
6
|
+
return await scanner.run(config);
|
|
6
7
|
};
|
|
7
8
|
|
|
8
|
-
const calcSum = array => {
|
|
9
|
-
|
|
9
|
+
const calcSum = (array) => {
|
|
10
|
+
return array.reduce((a, b) => a + b, 0);
|
|
10
11
|
};
|
|
11
12
|
|
|
12
|
-
const calculateAdoptionRate = (kitJsonPath, miniappJsonPath) => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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()
|
|
143
|
+
main();
|
package/migrate_typo.js
ADDED
|
@@ -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();
|