@@ -35,8 +35,36 @@ export default (ctx: IPluginContext) => {
35
35
} )
36
36
}
37
37
38
+ // 单独function获取@jdtaro相关的包
39
+ function getJdtaroPackages ( ctx ) {
40
+ try {
41
+ const { appPath } = ctx . paths
42
+ const fs = ctx . helper . fs
43
+ const packageJsonPath = path . join ( appPath , 'package.json' )
44
+
45
+ if ( fs . existsSync ( packageJsonPath ) ) {
46
+ const packageJsonContent = fs . readFileSync ( packageJsonPath , 'utf8' )
47
+ const packageJson = JSON . parse ( packageJsonContent )
48
+ const dependencies = Object . assign ( { } , packageJson . dependencies || { } , packageJson . devDependencies || { } )
49
+
50
+ // 筛选出@jdtaro相关的包
51
+ return Object . keys ( dependencies ) . filter ( pkg => pkg . startsWith ( '@jdtaro/' ) )
52
+ }
53
+ } catch ( error ) {
54
+ // 记录错误但不中断程序执行(添加trycatch)
55
+ console . error ( '读取或解析package.json时发生错误:' , error . message )
56
+ }
57
+
58
+ return [ ]
59
+ }
60
+
38
61
async function info ( options , ctx ) {
39
- const npmPackages = ctx . helper . UPDATE_PACKAGE_LIST . concat ( [ 'react' , 'react-native' , 'expo' , 'taro-ui' ] )
62
+ let npmPackages = ctx . helper . UPDATE_PACKAGE_LIST . concat ( [ 'react' , 'react-native' , 'expo' , 'taro-ui' ] )
63
+
64
+ // 调用新函数获取@jdtaro相关包
65
+ const jdtaroPackages = getJdtaroPackages ( ctx )
66
+ npmPackages = npmPackages . concat ( jdtaroPackages )
67
+
40
68
const info = await envinfo . run ( Object . assign ( { } , {
41
69
System : [ 'OS' , 'Shell' ] ,
42
70
Binaries : [ 'Node' , 'Yarn' , 'npm' ] ,
0 commit comments