合并代码

This commit is contained in:
cheney 2022-08-18 15:05:35 +08:00
parent 3b246776aa
commit 8ee487fbd0
12 changed files with 4 additions and 356 deletions

1
doc/.gitignore vendored
View File

@ -1 +0,0 @@
~$*

Binary file not shown.

Binary file not shown.

View File

@ -1,7 +0,0 @@
:: 自动打包为发布格式
:: 准备文件夹
:: rd /s/q ./public
:: md ./public
:: 获取版本
node public.script/index.js

View File

@ -1,31 +0,0 @@
// console.log('\x1B[36m%s\x1B[0m', info); //cyan
// console.log('\x1B[33m%s\x1b[0m:', path); //yellow
var styles = {
'bold' : ['\x1B[1m', '\x1B[22m'],
'italic' : ['\x1B[3m', '\x1B[23m'],
'underline' : ['\x1B[4m', '\x1B[24m'],
'inverse' : ['\x1B[7m', '\x1B[27m'],
'strikethrough' : ['\x1B[9m', '\x1B[29m'],
'white' : ['\x1B[37m', '\x1B[39m'],
'grey' : ['\x1B[90m', '\x1B[39m'],
'black' : ['\x1B[30m', '\x1B[39m'],
'blue' : ['\x1B[34m', '\x1B[39m'],
'cyan' : ['\x1B[36m', '\x1B[39m'],
'green' : ['\x1B[32m', '\x1B[39m'],
'magenta' : ['\x1B[35m', '\x1B[39m'],
'red' : ['\x1B[31m', '\x1B[39m'],
'yellow' : ['\x1B[33m', '\x1B[39m'],
'whiteBG' : ['\x1B[47m', '\x1B[49m'],
'greyBG' : ['\x1B[49;5;8m', '\x1B[49m'],
'blackBG' : ['\x1B[40m', '\x1B[49m'],
'blueBG' : ['\x1B[44m', '\x1B[49m'],
'cyanBG' : ['\x1B[46m', '\x1B[49m'],
'greenBG' : ['\x1B[42m', '\x1B[49m'],
'magentaBG' : ['\x1B[45m', '\x1B[49m'],
'redBG' : ['\x1B[41m', '\x1B[49m'],
'yellowBG' : ['\x1B[43m', '\x1B[49m']
};
module.exports = styles

View File

@ -1,269 +0,0 @@
const l = require("./log")
const os = require("os");
const fs = require('fs');
const path = require('path');
const util = require('util');
const { exec } = require('child_process')
function sync( cmds , options = {}){
if ( options.detached ) {
throw "sync 不支持 detached"
}
options = Object.assign({
// cwd : os.tmpdir(),
encoding: 'buffer'
}, options)
// 支持多命令
let cmd = cmds
// win 乱码问题
let encode = "win32" === os.platform() ? 'cp936' : "utf-8"
return new Promise(function (resolve, reject) {
let process = exec( cmd , options , function (e, stdout, stderr) {
// console.log( e,
// iconv.decode( stdout, 'cp936'),
// iconv.decode( stderr, 'cp936')
// )
if ( e ) {
reject( e )
} else {
resolve( stdout.toString() , stderr.toString() )
// resolve({
// pid : process.pid,
// exitCode : process.exitCode,
// stdout : stdout.toString(),
// stderr : stderr.toString()
// })
}
})
console.log( "process", process.pid )
})
}
var version = ""
const project_path = path.join(__dirname, "../")
const out_path = path.join(project_path, "public")
// 用户文档
const man = "说明.txt"
function prepareDir(){
return new Promise(function (cbok, cberr) {
if ( fs.existsSync( out_path ) ){
l.i("存在旧文件,清空旧文件")
}
sync("rd /s/q .\\public").catch(function (reason) {
// pass
}).finally(function () {
l.i("创建新文件")
fs.mkdirSync( out_path )
fs.mkdirSync( path.join( out_path, "jar" ))
fs.mkdirSync( path.join( out_path, "jar", "dependences"))
// fs.mkdirSync( path.join( out_path, "doc" ))
// fs.mkdirSync( path.join( out_path, "html" ))
// fs.mkdirSync( path.join( out_path, "sample" ))
l.i("目录准备完成")
cbok()
})
})
}
function mvn(){
l.i("调用 maven 打包,可能需要好几分钟。")
return new Promise(function (cbok, cberr) {
sync('mvn package -DskipTests').then(function (value, error) {
if ( error ) {
throw error
}
l.d( value )
if ( value.indexOf("BUILD SUCCESS") < 0 ){
throw new Error("请检查 maven package 命令")
}
// 移动文件到发布目录
fs.renameSync(path.join(project_path, "target", "sydapi4j-jar-with-dependencies.jar")
, path.join(out_path, "jar", "sydapi4j-jar-with-dependencies.jar"))
fs.renameSync(path.join(project_path, "target", "sydapi4j.jar")
, path.join(out_path, "jar", "sydapi4j.jar"))
cbok()
})
})
}
function doc(){
return sync('mvn javadoc:javadoc').then(function (value, error) {
l.d( value )
// if ( value.indexOf("BUILD SUCCESS") < 0 ){
// throw new Error("请检查 maven doc 命令")
// }
}).catch(function (reason) {
l.d("忽略文档生成错误")
})
}
function zipjar(){
return sync("7z a .\\public\\sydapi-"+ version +".zip .\\public\\jar\\").then(function (value, error) {
l.d( value )
if ( value.indexOf("Everything is Ok") < 0 ){
throw new Error("请检查 7z 命令")
}
})
}
function zipsample(){
return sync("7z a .\\public\\sydapi-"+ version +".zip .\\src\\test\\java\\com\\sunyard\\sydapi\\sample").then(function (value, error) {
l.d( value )
if ( value.indexOf("Everything is Ok") < 0 ){
throw new Error("请检查 7z 命令")
}
})
}
function zipdoc(){
return sync("7z a .\\public\\sydapi-"+ version +".zip " + man).then(function (value, error) {
l.d( value )
if ( value.indexOf("Everything is Ok") < 0 ){
throw new Error("请检查 7z 命令")
}
})
}
function dependencies(){
return sync('mvn dependency:copy-dependencies -DincludeScope=runtime -DoutputDirectory=./public/jar/dependences').then(function (value, error) {
l.d( value )
if ( value.indexOf("BUILD SUCCESS") < 0 ){
throw new Error("请检查 maven dependencies 命令")
}
})
}
async function main() {
l.i("项目目录 : " + project_path )
sync('git status').then(function (value, error) {
l.d( value )
if ( value.indexOf("Command failed") > 0 ){
throw new Error("请检查 git 命令")
}
if ( value.indexOf("Changes not staged for commit") > 0){
throw new Error("项目有文件未保存")
}
if ( value.indexOf("Changes to be committed") > 0 ){
throw new Error("项目有文件未提交")
}
// 匹配分支,获取前两位版本
var r = /^On branch dev-(?<version>\S+)$/gm.exec(value)
l.i( r.groups.version )
version = r.groups.version
return sync('git log -1')
}).then(function (value) {
l.d( value )
var r = /^commit\s(?<id>\S+)$/gm.exec(value)
l.i( r.groups.id )
// 缩短 HASH
var short = r.groups.id.substr(0, 6)
version += "." + short
l.i("目前版本: " + version )
return prepareDir()
}).then(function (value) {
return mvn()
}).then(function (value) {
return dependencies()
}).then(function (value) {
var pom = fs.readFileSync("pom.xml", { encoding : "UTF-8" })
var head = pom.indexOf("<dependencies>")
var tail = pom.indexOf("</dependencies>") + 15
var dependencies = pom.substring( head, tail )
fs.writeFileSync( path.join( out_path, "jar", "dependences.xml") , dependencies )
}).then(function (value) {
return zipjar()
}).then(function (value) {
return zipsample()
}).then(function (value) {
return zipdoc()
}).then(function () {
l.i("打包完成!")
sync('cd .\\public && start .')
}).catch(function (reason) {
l.e( reason )
})
}
main()

View File

@ -1,31 +0,0 @@
const style = require("./color")
const info = style.green
const error = style.red
const debug = style.cyan
const l = {
o : console.log,
i : function ( msg ) {
console.log('%s%s%s', info[0], msg , info[1]);
},
d : function ( msg ) {
console.log('%s%s%s', debug[0], msg , debug[1]);
},
e : function ( msg ) {
console.log('%s%s%s', error[0], msg , error[1]);
},
}
l.show = function () {
l.i("info")
l.d("debug")
l.e("error")
}
module.exports = l

View File

@ -1,3 +0,0 @@
7z a ./target/sydapi4j.jar racal.sunyard.main.version
7z a ./target/sydapi4j-sources.jar racal.sunyard.main.version
7z a ./target/sydapi4j-jar-with-dependencies.jar racal.sunyard.main.version

View File

@ -1,5 +0,0 @@
v1.11 版本
- 修正不规范接口 GenerateRandom 返回值更改为 String 类型。老版本为 bool 类型,仅于活性检测。
v1.12 版本
- 新增编押验押接口/人行定制接口。

View File

@ -1,8 +0,0 @@
本次新增以下依赖
bcpkix-jdk15on-1.65.jar - 安全依赖组件
bcprov-jdk15on-1.65.jar - 安全依赖组件
hutool-all-5.8.4.M1.jar - 工具组件
jar/dependences.xml 所有依赖 Maven 格式说明

View File

@ -6,5 +6,8 @@ sydapi1.12 签名验签使用的 jar
- dependences.xml 所有依赖 Maven 格式说明
- dependences 所有依赖
- groovy-all-2.4.15 通信协议支持
- proto-1.0-20220412 通信协议支持
- proto-1.0-20220804 通信协议支持
- alf4j-api-1.7.10 日志接口
- bcpkix-jdk15on-1.65.jar - 安全依赖组件
- bcprov-jdk15on-1.65.jar - 安全依赖组件
- hutool-all-5.8.4.M1.jar - 工具组件