diff --git a/helper/build-npm.js b/helper/build-npm.js index db24d12..fecef55 100644 --- a/helper/build-npm.js +++ b/helper/build-npm.js @@ -87,6 +87,8 @@ function copyToNPM () { gulp.src(['src/cnchar/main/package.json']) .pipe(gulp.dest('npm/packages/cnchar')); + copyCncharTypes(gulpReadme); + alias.forEach(alia => { gulp.src(`src/cnchar/alias/${alia}/package.json`) .pipe(gulp.dest(`npm/packages/${alia}`)); @@ -97,6 +99,13 @@ function copyToNPM () { }); } +function copyCncharTypes (gulpReadme) { + gulp.src(['src/cnchar-types/**/*.ts', 'src/cnchar-types/package.json']) + .pipe(gulp.dest('npm/packages/cnchar-types')); + + gulpReadme.pipe(gulp.dest(`npm/packages/cnchar-types`)); +} + function copyLatest () { // gulp.src(`dist/*.${version}.min.js`) // .pipe(rename(function (path) { @@ -126,4 +135,5 @@ function copyLatest () { .pipe(gulp.dest('npm/packages/hanzi-util-base')); } + task(); \ No newline at end of file diff --git a/helper/publish.js b/helper/publish.js index 3fbde75..876afb3 100644 --- a/helper/publish.js +++ b/helper/publish.js @@ -10,7 +10,7 @@ async function main () { const publish = 'npm publish '; const publishPackage = `${publish}npm/packages/`; const publishAll = `${publishPackage}cnchar-all`; - const publishTypes = `${publish}src/cnchar-types`; + const publishTypes = `${publishPackage}cnchar-types`; const publishMain = `${publishPackage}cnchar`; let cmds = []; let cmdConsole = []; @@ -49,11 +49,24 @@ async function main () { ]; } console.log(`Start Publish... [0/${cmds.length}]`); + const errorList = []; for (let i = 0; i < cmds.length; i++) { - await exec(cmds[i]); - console.log(`${cmdConsole[i]} publish success. [${i + 1}/${cmds.length}]`); + const {success, stderr} = await exec(cmds[i]); { + if (success) { + console.log(`${cmdConsole[i]} publish success. [${i + 1}/${cmds.length}]`); + } else { + console.log(stderr); + console.log(`${cmdConsole[i]} publish fail!. [${i + 1}/${cmds.length}]`); + errorList.push(cmdConsole[i]); + } + } } console.log('Finished!'); + + if (errorList.length > 0) { + console.log(`Fail Items: ${cmdConsole.toString()}`); + } } -main(); \ No newline at end of file +main(); + diff --git a/helper/publish.sh b/helper/publish.sh new file mode 100755 index 0000000..70be472 --- /dev/null +++ b/helper/publish.sh @@ -0,0 +1,33 @@ +### + # @Author: tackchen + # @Date: 2021-12-16 17:39:00 + # @LastEditors: tackchen + # @FilePath: /cnchar/helper/publish.sh + # @Description: Coding something +### + +#!/bin/bash + +# cd $(cd `dirname $0`; pwd) +# cd ../npm/packages + +# bast_path=$(pwd) + +# echo "$bast_path/cnchar" + +# packages=("cnchar" "cnchar-poly" ) + +# for package in ${packages[@]} +# do +# echo "The value is: $package" +# done + +# cd $(cd `dirname $0`; pwd) +# cd ../npm/packages + +# bast_path=$(pwd) +# files=$(ls $bast_path) +# for filename in ${files[@]} +# do +# echo "$bast_path/$filename" +# done \ No newline at end of file diff --git a/helper/tool.js b/helper/tool.js index 5ccae46..b3e36b8 100644 --- a/helper/tool.js +++ b/helper/tool.js @@ -45,13 +45,14 @@ async function exec (cmd) { return new Promise(resolve => { childProcess.exec(cmd, function (error, stdout, stderr) { if (error) { - throw new Error('publish error'); + resolve({success: false, stdout, stderr}); + } else { + resolve({ + success: true, + stdout, + stderr + }); } - resolve({ - success: true, - stdout, - stderr - }); }); }); } diff --git a/src/cnchar-types/package-lock.json b/src/cnchar-types/package-lock.json index e781bca..51a9d38 100644 --- a/src/cnchar-types/package-lock.json +++ b/src/cnchar-types/package-lock.json @@ -1,5 +1,5 @@ { "name": "cnchar-types", - "version": "3.0.2", + "version": "3.0.5", "lockfileVersion": 1 }