@mpxjs/cli 3.4.10 → 3.4.11
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/lib/createRn.js +37 -7
- package/package.json +1 -1
package/lib/createRn.js
CHANGED
|
@@ -20,13 +20,36 @@ const RN_DEP = {
|
|
|
20
20
|
'react-native-haptic-feedback': '^2.3.3',
|
|
21
21
|
'react-native-linear-gradient': '^2.8.3',
|
|
22
22
|
'react-native-reanimated': '3.16.7',
|
|
23
|
-
'react-native-screens': '
|
|
23
|
+
'react-native-screens': '~4.18.0',
|
|
24
24
|
'react-native-webview': '^13.13.2',
|
|
25
25
|
'react-native-safe-area-context': '^4.10.9',
|
|
26
26
|
react: '18.3.1',
|
|
27
27
|
'react-native': '0.77.2'
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
const RN_SCRIPTS = {
|
|
31
|
+
'bundle:ios': 'react-native bundle --platform ios --dev false --entry-file index.js --bundle-output ./ios/main.jsbundle --assets-dest ./ios',
|
|
32
|
+
'bundle:android': 'react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/'
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function updateJsonFile (filePath, updater) {
|
|
36
|
+
const config = require(filePath)
|
|
37
|
+
updater(config)
|
|
38
|
+
fs.writeFileSync(filePath, JSON.stringify(config, null, 2))
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function updateJsModule (filePath, updater) {
|
|
42
|
+
const config = require(filePath)
|
|
43
|
+
updater(config)
|
|
44
|
+
fs.writeFileSync(filePath, `module.exports = ${JSON.stringify(config, null, 2)};`)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function addArrayItem (arr, item) {
|
|
48
|
+
if (!arr.includes(item)) {
|
|
49
|
+
arr.push(item)
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
30
53
|
async function createRnProject (targetDir, options) {
|
|
31
54
|
const rnProjectPath = path.resolve(targetDir, 'ReactNativeProject')
|
|
32
55
|
const packageManager =
|
|
@@ -56,14 +79,21 @@ async function createRnProject (targetDir, options) {
|
|
|
56
79
|
],
|
|
57
80
|
{ stdio: 'inherit', cwd: targetDir }
|
|
58
81
|
)
|
|
82
|
+
|
|
59
83
|
const pkgPath = path.resolve(targetDir, 'ReactNativeProject', 'package.json')
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
'bundle:ios': 'react-native bundle --platform ios --dev false --entry-file index.js --bundle-output ./ios/main.jsbundle --assets-dest ./ios',
|
|
64
|
-
'bundle:android': 'react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/'
|
|
84
|
+
updateJsonFile(pkgPath, pkg => {
|
|
85
|
+
Object.assign(pkg.dependencies, RN_DEP)
|
|
86
|
+
Object.assign(pkg.scripts, RN_SCRIPTS)
|
|
65
87
|
})
|
|
66
|
-
|
|
88
|
+
|
|
89
|
+
const babelConfigPath = path.resolve(targetDir, 'ReactNativeProject', 'babel.config.js')
|
|
90
|
+
updateJsModule(babelConfigPath, config => {
|
|
91
|
+
if (!config.plugins) {
|
|
92
|
+
config.plugins = []
|
|
93
|
+
}
|
|
94
|
+
addArrayItem(config.plugins, 'react-native-reanimated/plugin')
|
|
95
|
+
})
|
|
96
|
+
|
|
67
97
|
await pm.install()
|
|
68
98
|
}
|
|
69
99
|
|
package/package.json
CHANGED