@@ -7,7 +7,7 @@ import { pri, tempPath, declarationPath } from '../../../node';
77import { buildComponent } from '../../command-build/plugin/build' ;
88import { commandBundle } from '../../command-bundle/plugin/command-bundle' ;
99import { isWorkingTreeClean , getCurrentBranchName } from '../../../utils/git-operate' ;
10- import { logInfo , spinner } from '../../../utils/log' ;
10+ import { logInfo , spinner , logFatal } from '../../../utils/log' ;
1111import { getMonoAndNpmDepsOnce , DepMap } from '../../../utils/packages' ;
1212import { PackageInfo } from '../../../utils/define' ;
1313import {
@@ -96,7 +96,9 @@ async function publishByPackageName(
9696) {
9797 logInfo ( `Start publish ${ sourceType } .` ) ;
9898
99- const { targetPackageJson, targetConfig, targetRoot, targetPackageInfo } = prePareParamsBeforePublish ( sourceType ) ;
99+ const {
100+ targetPackageJson, targetConfig, targetRoot, targetPackageInfo,
101+ } = prePareParamsBeforePublish ( sourceType ) ;
100102
101103 // Change source config here
102104 pri . sourceConfig = targetConfig ;
@@ -121,8 +123,8 @@ async function publishByPackageName(
121123
122124 // Update version in depMao
123125 if ( depMap ) {
124- depMap . forEach ( value => {
125- value . depMonoPackages . forEach ( eachPackage => {
126+ depMap . forEach ( ( value ) => {
127+ value . depMonoPackages . forEach ( ( eachPackage ) => {
126128 if ( eachPackage . name === sourceType ) {
127129 // eslint-disable-next-line no-param-reassign
128130 eachPackage . packageJson . version = targetPackageJson . version ;
@@ -157,7 +159,9 @@ async function publishPackageAndItsMonoPackage(
157159) {
158160 logInfo ( `Start publish ${ sourceType } .` ) ;
159161
160- const { targetPackageJson, targetConfig, targetRoot, targetPackageInfo } = prePareParamsBeforePublish ( sourceType ) ;
162+ const {
163+ targetPackageJson, targetConfig, targetRoot, targetPackageInfo,
164+ } = prePareParamsBeforePublish ( sourceType ) ;
161165
162166 // Change source config here
163167 pri . sourceConfig = targetConfig ;
@@ -176,7 +180,7 @@ async function publishPackageAndItsMonoPackage(
176180
177181 // Generate all package version and upgrade
178182
179- await depMonoPackages . forEach ( async item => {
183+ await depMonoPackages . forEach ( async ( item ) => {
180184 const version = await generateVersion ( options , isDevelopBranch , item . packageJson , item . config , currentBranchName ) ;
181185
182186 monoPackageVersion [ item . name as string ] = version ;
@@ -190,8 +194,8 @@ async function publishPackageAndItsMonoPackage(
190194
191195 // Update depMonoPackages version
192196
193- depMonoPackages . forEach ( item => {
194- depMap . get ( item . name ) . depMonoPackages . forEach ( eachPackage => {
197+ depMonoPackages . forEach ( ( item ) => {
198+ depMap . get ( item . name ) . depMonoPackages . forEach ( ( eachPackage ) => {
195199 if ( monoPackageVersion [ eachPackage . packageJson . name ] ) {
196200 eachPackage . packageJson . version = monoPackageVersion [ eachPackage . packageJson . name ] ;
197201 }
@@ -220,23 +224,21 @@ async function publishPackageAndItsMonoPackage(
220224 } ) ;
221225 }
222226
223- try {
224- const publishQueue = [ ] ;
225- // async publish & add tag and push
226- depMonoPackages . map ( item => {
227- publishQueue . push ( buildComponentAndPublish ( item , options , depMap , isDevelopBranch ) ) ;
228- } ) ;
227+ const publishQueue = [ ] ;
228+ // async publish & add tag and push
229+ depMonoPackages . map ( ( item ) => {
230+ publishQueue . push ( buildComponentAndPublish ( item , options , depMap , isDevelopBranch ) ) ;
231+ } ) ;
229232
230- // publish current package
231- publishQueue . push ( buildComponentAndPublish ( targetPackageInfo , options , depMap , isDevelopBranch ) ) ;
233+ // publish current package
234+ publishQueue . push ( buildComponentAndPublish ( targetPackageInfo , options , depMap , isDevelopBranch ) ) ;
232235
233- return Promise . all ( publishQueue ) ;
234- } catch ( e ) {
235- logInfo ( `publish error ${ e } stop publish` ) ;
236+ return Promise . all ( publishQueue ) . catch ( async ( e ) => {
236237 await fs . remove ( path . join ( pri . projectRootPath , tempPath . dir , declarationPath . dir ) ) ;
237238 await exec ( `git push origin ${ currentBranchName } ` ) ;
238- return process . exit ( 0 ) ;
239- }
239+ logFatal ( `publish error stop publish: ${ e } ` ) ;
240+ process . exit ( 0 ) ;
241+ } ) ;
240242}
241243
242244async function buildComponentAndPublish (
@@ -245,23 +247,20 @@ async function buildComponentAndPublish(
245247 depMap : DepMap ,
246248 isDevelopBranch : boolean ,
247249) {
248- return new Promise ( async resolve => {
249- await buildComponent ( packageInfo ) ;
250+ await buildComponent ( packageInfo ) ;
250251
251- if ( options . bundle ) {
252- await commandBundle ( { skipLint : true } ) ;
253- }
252+ if ( options . bundle ) {
253+ await commandBundle ( { skipLint : true } ) ;
254+ }
254255
255- await moveSourceFilesToTempFolderAndPublish (
256- packageInfo . name ,
257- options ,
258- packageInfo . config ,
259- packageInfo . rootPath ,
260- depMap ,
261- isDevelopBranch ,
262- ) ;
263-
264- await addTagAndPush ( generateTag ( packageInfo . name , packageInfo . packageJson ) , packageInfo . packageJson ) ;
265- resolve ( ) ;
266- } ) ;
256+ await moveSourceFilesToTempFolderAndPublish (
257+ packageInfo . name ,
258+ options ,
259+ packageInfo . config ,
260+ packageInfo . rootPath ,
261+ depMap ,
262+ isDevelopBranch ,
263+ ) ;
264+
265+ await addTagAndPush ( generateTag ( packageInfo . name , packageInfo . packageJson ) , packageInfo . packageJson ) ;
267266}
0 commit comments