@@ -5,8 +5,8 @@ const fs = require('fs')
55const util = require ( '../build/util.js' )
66const buildReadme = require ( '../build/build-readme.js' )
77const root = path . join ( __dirname , '..' )
8- // const modulesId = 'uni-test'
9- const modulesId = process . env . UNI_MODULES_ID
8+ const modulesId = process . env . UNI_MODULES_ID
9+ // const modulesId = 'uni-icons'
1010const comName = modulesId . replace ( / u n i - / , '' )
1111const comPath = path . join ( root , 'uni_modules' )
1212// console.error('upload.js - modulesId :' + modulesId);
@@ -19,7 +19,7 @@ const readmePath = path.join(root, 'docs', 'components', comName + '.md')
1919
2020const mdExists = fs . existsSync ( readmePath )
2121if ( mdExists ) {
22- const content = handleReadme ( readmePath )
22+ const content = handleReadme ( readmePath , comName )
2323 util . write ( path . join ( root , 'uni_modules' , modulesId , 'readme.md' ) , content )
2424}
2525
@@ -45,23 +45,24 @@ if (modulesId === 'uni-ui') {
4545 // 将组件拷贝到临时目录
4646 util . copyDir ( getModulesPath ( modulesId ) , path . join ( tempExamplePath , 'uni_modules' , modulesId ) )
4747 handlePageJson ( comName , tempExamplePath )
48-
4948 // 获取关联组件
5049 if ( packageJson && packageJson . uni_modules && packageJson . uni_modules . dependencies . length > 0 ) {
5150 relationComponents = packageJson . uni_modules . dependencies
52- }
53-
51+ }
5452 // 同步依赖组件
55- if ( relationComponents && relationComponents . length > 0 ) {
53+ if ( relationComponents && relationComponents . length > 0 ) {
5654 relationComponents . reduce ( ( promise , item ) => {
57- return new Promise ( ( resolve , reject ) => {
58- util . copyDir ( getModulesPath ( item ) , path . join ( tempExamplePath , 'uni_modules' , item ) )
55+ return new Promise ( ( resolve , reject ) => {
56+ util . copyDir ( getModulesPath ( item ) , path . join ( tempExamplePath , 'uni_modules' , item ) )
57+ resolve ( )
5958 } )
60- } , Promise . resolve ( [ ] ) ) . then ( res => {
59+ } , Promise . resolve ( [ ] ) ) . then ( res => {
6160 // console.error('所有依赖组件同步完成');
6261 setPageComponents ( modulesId , comName )
62+ } ) . catch ( ( err ) => {
63+ console . log ( 'error' , err ) ;
6364 } )
64- } else {
65+ } else {
6566 setPageComponents ( modulesId , comName )
6667 }
6768}
@@ -167,17 +168,21 @@ function getModulesPath(name) {
167168 * 处理 readme.md
168169 * @param {Object } readmePath
169170 */
170- function handleReadme ( readmePath ) {
171+ function handleReadme ( readmePath , comName ) {
171172 let content = util . read ( readmePath )
172173 // 兼容 windows ,将 \r\n 全部替换成 \n
173174 content = content . replace ( / \r \n / ig, '\n' )
174175 // 删除头部额外信息,在其他平台不支持,只在 uni ui 中支持
175- content = content . replace ( / - - - ( [ \s \S ] * ?) - - - / ig, '' )
176+ content = content . replace ( / - - - ( [ \s \S ] * ?) - - - / ig, '' ) . replace ( / # # 图 标 示 例 ( [ \s \S ] * ?) \< \/ i c o n s - l a y o u t s \> / ig, '' )
177+
176178 // 转换 ::: 语法
177179 content = content . replace ( / : : : ( .* ?) \n ( [ \s \S ] * ?) : : : / ig, function ( _ , $1 , $2 ) {
178180 $1 = $1 . replace ( / ( t i p | d a n g e r | w a r n i n g ) + / , '' )
179181 return '> **' + $1 + '**\n' + $2 . split ( '\n' ) . filter ( item => item !== '' ) . map ( item => `> ${ item } \n` ) . join ( '' )
180182 } )
183+
184+ content += `\n\n## 组件示例\n\n点击查看:[https://hellouniapp.dcloud.net.cn/pages/extUI/${ comName } /${ comName } ](https://hellouniapp.dcloud.net.cn/pages/extUI/${ comName } /${ comName } )`
185+
181186 return content
182187}
183188
0 commit comments