Browse Source

Merge pull request '删除最外层version.log.js文件' (#79) from liwei into develop

Reviewed-on: http://101.201.121.115:3000/leo/LAPP_GAAS_GFrame_WEBFRONT/pulls/79
Reviewed-by: wangxy <xinyao.wang@le-it.com.cn>
pull/80/head
wangxy 3 years ago
parent
commit
987c33578e
3 changed files with 34 additions and 34 deletions
  1. +1
    -0
      public/version.log.js
  2. +33
    -33
      version.js
  3. +0
    -1
      version.log.js

+ 1
- 0
public/version.log.js View File

@ -0,0 +1 @@
const version='git:ddccd3065d4b6cd57d024588e7c92fe086c0f85d;作者:liwei<wei.li@le-it.com.cn>;日期:2021-6-11 17:18';console.log(version);

+ 33
- 33
version.js View File

@ -1,46 +1,46 @@
/**定义模块和变量**/
const execSync = require('child_process').execSync; //同步子进程
const fs = require('fs'); //文件读取模块
const versionPath = 'version.log.js'; //version路径
const buildPath = 'dist'; //打包的路径
const autoPush = false; //写入版本信息之后是否自动提交git上
const commit = execSync('git show -s --format=%H').toString().trim(); //当前提交的版本号
/**程序开始**/
var versionStr = ""; //版本信息字符串
/** 定义模块和变量**/
const execSync = require('child_process').execSync // 同步子进程
const fs = require('fs') // 文件读取模块
const versionPath = 'public/version.log.js' // version路径
const buildPath = 'dist' // 打包的路径
const autoPush = false // 写入版本信息之后是否自动提交git上
const commit = execSync('git show -s --format=%H').toString().trim() // 当前提交的版本号
/** 程序开始**/
var versionStr = '' // 版本信息字符串
// 如果versionPath存在,将先读取里边的版本信息 // 如果versionPath存在,将先读取里边的版本信息
if (fs.existsSync(versionPath)) { if (fs.existsSync(versionPath)) {
versionStr = fs.readFileSync(versionPath).toString() + '\n';
versionStr = fs.readFileSync(versionPath).toString() + '\n'
} }
// 根据版本信息是已存在commit,进行不同处理 // 根据版本信息是已存在commit,进行不同处理
// if (versionStr.indexOf(commit) != -1) { // if (versionStr.indexOf(commit) != -1) {
// console.warn('\x1B[33m%s\x1b[0m', 'warming: 当前的git版本数据已经存在了!\n') // console.warn('\x1B[33m%s\x1b[0m', 'warming: 当前的git版本数据已经存在了!\n')
// } else { // } else {
let name = execSync('git show -s --format=%cn').toString().trim(); //姓名
let email = execSync('git show -s --format=%ce').toString().trim(); //邮箱
let date = new Date(execSync('git show -s --format=%cd').toString()); //日期
versionStr = `const version='git:${commit};作者:${name}<${email}>;日期:${date.getFullYear()+'-'+(date.getMonth()+1)+'-'+date.getDate()+' '+date.getHours()+':'+date.getMinutes()}';console.log(version);`;
fs.writeFileSync(versionPath, versionStr);
// 写入版本信息之后,自动将版本信息提交到当前分支的git上
if (autoPush) {
execSync(`git commit ${versionPath} -m 自动提交版本信息`);
execSync(`git push origin ${execSync('git rev-parse --abbrev-ref HEAD').toString().trim()}`);
}
const name = execSync('git show -s --format=%cn').toString().trim() // 姓名
const email = execSync('git show -s --format=%ce').toString().trim() // 邮箱
const date = new Date(execSync('git show -s --format=%cd').toString()) // 日期
versionStr = `const version='git:${commit};作者:${name}<${email}>;日期:${date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate() + ' ' + date.getHours() + ':' + date.getMinutes()}';console.log(version);`
fs.writeFileSync(versionPath, versionStr)
// 写入版本信息之后,自动将版本信息提交到当前分支的git上
if (autoPush) {
execSync(`git commit ${versionPath} -m 自动提交版本信息`)
execSync(`git push origin ${execSync('git rev-parse --abbrev-ref HEAD').toString().trim()}`)
}
// } // }
// 将version文件移植到打包文件中 // 将version文件移植到打包文件中
if (fs.existsSync(buildPath)) { if (fs.existsSync(buildPath)) {
fs.writeFileSync(`${buildPath}/${versionPath}`, fs.readFileSync(versionPath));
fs.writeFileSync(`${buildPath}/version.log.js`, fs.readFileSync(versionPath))
} }
// 程序执行结束 // 程序执行结束
console.info('\x1B[32m%s\x1b[0m', [ console.info('\x1B[32m%s\x1b[0m', [
"██████╗ ███████╗██████╗ ███████╗ █████╗ ██████╗██╗ ██╗",
"██╔══██╗██╔════╝██╔══██╗██╔════╝██╔══██╗██╔════╝╚██╗ ██╔╝",
"██████╔╝█████╗ ██████╔╝███████╗███████║██║ ███╗╚████╔╝ ",
"██╔═══╝ ██╔══╝ ██╔══██╗╚════██║██╔══██║██║ ██║ ╚██╔╝ ",
"██║ ███████╗██║ ██║███████║██║ ██║╚██████╔╝ ██║ ",
"╚═╝ ╚══════╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚═╝ ",
].join('\n'));
'██████╗ ███████╗██████╗ ███████╗ █████╗ ██████╗██╗ ██╗',
'██╔══██╗██╔════╝██╔══██╗██╔════╝██╔══██╗██╔════╝╚██╗ ██╔╝',
'██████╔╝█████╗ ██████╔╝███████╗███████║██║ ███╗╚████╔╝ ',
'██╔═══╝ ██╔══╝ ██╔══██╗╚════██║██╔══██║██║ ██║ ╚██╔╝ ',
'██║ ███████╗██║ ██║███████║██║ ██║╚██████╔╝ ██║ ',
'╚═╝ ╚══════╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚═╝ '
].join('\n'))

+ 0
- 1
version.log.js View File

@ -1 +0,0 @@
const version='git:bcfaab776d8b2b12d04b8f1e44771cfceba05938;作者:wangxy<xinyao.wang@le-it.com.cn>;日期:2021-6-11 17:6';console.log(version);

Loading…
Cancel
Save