init
This commit is contained in:
commit
a2dafcc3a8
8
.idea/.gitignore
vendored
Normal file
8
.idea/.gitignore
vendored
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# Editor-based HTTP Client requests
|
||||||
|
/httpRequests/
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/dataSources/
|
||||||
|
/dataSources.local.xml
|
||||||
6
.idea/misc.xml
Normal file
6
.idea/misc.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectRootManager">
|
||||||
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
8
.idea/modules.xml
Normal file
8
.idea/modules.xml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/sydmark.iml" filepath="$PROJECT_DIR$/sydmark.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
6
Readme.md
Normal file
6
Readme.md
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
# sydmark
|
||||||
|
|
||||||
|
## 功能
|
||||||
|
- 获取 git hash
|
||||||
|
- 获取目标文件 md5
|
||||||
|
- [feature] 从文件中读取自动分析,默认为当前路径下的 sydmark.txt
|
||||||
11
package.json
Normal file
11
package.json
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"name": "sydmark",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC"
|
||||||
|
}
|
||||||
71
src/Config.js
Normal file
71
src/Config.js
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
/**
|
||||||
|
* 配置项
|
||||||
|
* windows 默认存储在用户 home 目录的 AppData\Local 下的 sydmark 目录
|
||||||
|
* linux 默认存贮在用户 home 目录的 .sydmark 目录
|
||||||
|
*/
|
||||||
|
|
||||||
|
const os = require('os');
|
||||||
|
const path = require('path');
|
||||||
|
const fs = require('fs');
|
||||||
|
|
||||||
|
|
||||||
|
// 默认配置
|
||||||
|
let configMap = {
|
||||||
|
gitAuth : "qian.huang%40sunyard.com:qian.huang",
|
||||||
|
docAuth : ""
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取操作系统的名称
|
||||||
|
const platform = os.platform();
|
||||||
|
let baseDir = undefined
|
||||||
|
const userHomeDir = os.homedir();
|
||||||
|
|
||||||
|
// 检查操作系统类型
|
||||||
|
if (platform === 'win32') {
|
||||||
|
console.log('操作系统是 Windows');
|
||||||
|
baseDir = path.resolve(userHomeDir, "AppData/Local/sydmark")
|
||||||
|
} else if (platform === 'linux') {
|
||||||
|
console.log('操作系统是 Linux');
|
||||||
|
baseDir = path.resolve(userHomeDir, ".sydmark")
|
||||||
|
} else {
|
||||||
|
console.log('暂不支持操作系统 ' + platform );
|
||||||
|
process.exit(-1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查目录是否存在
|
||||||
|
// 如果目录不存在创建目录
|
||||||
|
if (!fs.existsSync(baseDir)) {
|
||||||
|
// 使用递归创建目录
|
||||||
|
fs.mkdirSync(baseDir, { recursive: true });
|
||||||
|
console.log(`目录 ${resolvedPath} 创建成功`);
|
||||||
|
} else {
|
||||||
|
console.log(`目录 ${resolvedPath} 已存在,无需创建`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const configFile = path.resolve(baseDir, "config.json");
|
||||||
|
// 判断文件是否存在
|
||||||
|
// 如果存在读取
|
||||||
|
try {
|
||||||
|
if ( fs.existsSync( configFile ) ) {
|
||||||
|
let json = fs.readFileSync(configFile, "UTF-8")
|
||||||
|
configMap = JSON.parse(json);
|
||||||
|
} else {
|
||||||
|
throw "unexists"
|
||||||
|
}
|
||||||
|
} catch ( e ) {
|
||||||
|
// 如果 不存在/读取异常 用默认值填充
|
||||||
|
fs.writeFileSync(configFile, JSON.stringify( configMap, null, 4 ))
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
|
||||||
|
getConfig(key) {
|
||||||
|
return configMap[key]
|
||||||
|
},
|
||||||
|
|
||||||
|
setConfig(key, value) {
|
||||||
|
configMap[key] = value
|
||||||
|
fs.writeFileSync(configFile, JSON.stringify( configMap, null, 4 ))
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
37
src/GitUtil.js
Normal file
37
src/GitUtil.js
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
const regex = /^(http:\/\/.+\)[.+]$/gm; // 使用 'm' 标志启用多行匹配
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
findGits : function (txt) {
|
||||||
|
const gits = []
|
||||||
|
|
||||||
|
// 执行正则匹配
|
||||||
|
const matches = txt.match(regex);
|
||||||
|
if (matches) {
|
||||||
|
matches.forEach((match, index) => {
|
||||||
|
let ms = regex.exec(match)
|
||||||
|
gits.push({
|
||||||
|
url : ms[1],
|
||||||
|
branch : ms[2]
|
||||||
|
})
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
return gits
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
, getHash : function (url, branch, auth){
|
||||||
|
let pos = 0;
|
||||||
|
if ( url.startsWith("http://") ) {
|
||||||
|
pos = 7
|
||||||
|
} else if ( url.startsWith("https://") ) {
|
||||||
|
pos = 8
|
||||||
|
} else if ( url.startsWith("git://") ) {
|
||||||
|
pos = 6
|
||||||
|
}
|
||||||
|
|
||||||
|
git ls-remote --heads http://qian.huang%40sunyard.com:qian.huang@172.1.4.32:3000/SSP/CollaborativeComputingFuture dev-1.2
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
32
src/index.js
Normal file
32
src/index.js
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
const fs = require('fs');
|
||||||
|
const GitUtil= require("./GitUtil")
|
||||||
|
|
||||||
|
let filePath = "./sydmark.txt"
|
||||||
|
|
||||||
|
// 提取命令行参数
|
||||||
|
const args = process.argv.slice(2); // 忽略前两个参数
|
||||||
|
if( args.length !== 0 ) {
|
||||||
|
filePath = args[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
// 确认文件是否存在
|
||||||
|
if ( ! fs.existsSync(filePath) ) {
|
||||||
|
console.error("输入文件不存在 " + filePath)
|
||||||
|
process.exit(-1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 读取文件内容
|
||||||
|
const txt = fs.readFileSync(filePath, "utf-8")
|
||||||
|
|
||||||
|
// 分析 git 和分支
|
||||||
|
const gits = GitUtil.findGits(txt)
|
||||||
|
// 获取 git 指定分支的随后一个 hash
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 分析 doc 文件路径, 以 Sunyard/ 开头
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
8
sydmark.iml
Normal file
8
sydmark.iml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="GENERAL_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||||
|
<exclude-output />
|
||||||
|
<content url="file://$MODULE_DIR$" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
32
test/sydmark.txt
Normal file
32
test/sydmark.txt
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
【服务端】
|
||||||
|
http://172.1.4.32:3000/SSP/CollaborativeComputingFuture.git[dev-1.2]
|
||||||
|
|
||||||
|
|
||||||
|
【java 客户端】
|
||||||
|
http://172.1.4.32:3000/SSP/CollaborativeComputing[dev-dm]
|
||||||
|
|
||||||
|
|
||||||
|
【CIPS 客户端】
|
||||||
|
http://172.1.4.32:3000/SSP/coapi[dev-1.0]
|
||||||
|
|
||||||
|
|
||||||
|
【Linux 客户端】
|
||||||
|
|
||||||
|
【Windows 客户端】
|
||||||
|
|
||||||
|
|
||||||
|
【Android 客户端 - SKF 】
|
||||||
|
http://172.1.4.32:3000/SSP/skftest.git[skf_bld_1.00]d5f3cf7941
|
||||||
|
|
||||||
|
【Android 客户端 - 期货 】
|
||||||
|
http://172.1.4.32:3000/SSP/gatewaysoltest.git[gatewaysoltest_bld_1.00]e044206d60
|
||||||
|
|
||||||
|
【iOS 客户端】
|
||||||
|
http://172.1.4.32:3000/SSP/SunyardSKF_iOS.git[SunyardSKF_iOS_bld_1.00]5a691e2440
|
||||||
|
|
||||||
|
【Android 客户端】
|
||||||
|
Sunyard/Dev/产品/信息安全产品/交付项目/协同签名验签服务器(国密版)/03 软件发布/SDK包/android/skf_test_1.00.apk
|
||||||
|
|
||||||
|
|
||||||
|
【iOS 客户端】
|
||||||
|
Sunyard/Dev/产品/信息安全产品/交付项目/协同签名验签服务器(国密版)/03 软件发布/01 目标代码/iOS/SunardSKFAndBusiness_1.0.0.ipa (目标代码无意义,每3 天过期)
|
||||||
Loading…
Reference in New Issue
Block a user