Add: git hash

This commit is contained in:
Cutls 2019-08-26 00:09:01 +09:00
parent 5694cbd945
commit 5007b70683
8 changed files with 30 additions and 10 deletions

7
.gitignore vendored
View File

@ -13,3 +13,10 @@ app/.tkn
app/node_modules
app/js/login/tkn.js
app/package-lock.json
app/view/en
app/view/ja
app/view/de
app/view/bg
app/view/cs
app/view/ps
app/git

View File

@ -11,6 +11,7 @@ before_deploy:
- cd app
- VERSION=$(cat package.json | grep version | head -1 | awk -F= "{ print $2 }" | sed 's/[version:,\",]//g' | tr -d '[[:space:]]')
- npm install
- npm run construct
- if [ "$TRAVIS_OS_NAME" = "osx" ];then electron-builder --mac -p never;else :;fi
- if [ "$TRAVIS_OS_NAME" = "linux" ];then electron-builder --linux --x64 -p never;else :;fi
- if [ "$TRAVIS_OS_NAME" = "linux" ];then cd ../build;else :;fi

View File

@ -60,7 +60,7 @@ ipc.send("getPlatform", "")
ipc.on('platform', function (event, args) {
localStorage.setItem("platform", args[0])
localStorage.setItem("bit", args[1])
localStorage.setItem("about", JSON.stringify([args[2], args[3], args[4]]))
localStorage.setItem("about", JSON.stringify([args[2], args[3], args[4], args[5]]))
})
ipc.on('reload', function (event, arg) {

View File

@ -25,7 +25,7 @@ function tips(mode) {
clearInterval(spotStart);
if (mode == "ver") {
tipsToggle()
$("#tips-text").html('<img src="../../img/desk.png" width="20" onclick="todo(\'!TheDesk! It\\\'s a nice client!\')"><span style="font-size:20px">TheDesk</span> ' + localStorage.getItem("ver") + '[<i class="material-icons" style="font-size:1.2rem;top: 3px;position: relative;">supervisor_account</i><span id="persons">1+</span>]')
$("#tips-text").html('<img src="../../img/desk.png" width="20" onclick="todo(\'TheDesk is a nice client!: TheDesk ' + localStorage.getItem("ver") + ' git: '+ gitHash +'\')"><span style="font-size:20px">TheDesk</span> <span title="git: '+ gitHash +'">' + localStorage.getItem("ver") + '</span>[<i class="material-icons" style="font-size:1.2rem;top: 3px;position: relative;">supervisor_account</i><span id="persons">1+</span>]')
localStorage.setItem("tips", "ver")
} else if (mode == "clock") {
tipsToggle()

View File

@ -42,7 +42,12 @@ function system(mainWindow, dir, lang, dirname) {
});
//プラットフォーム
ipc.on('getPlatform', function (e, arg) {
e.sender.webContents.send('platform', [process.platform, process.arch, process.version, process.versions.chrome, process.versions.electron]);
try {
var gitHash = fs.readFileSync("git", 'utf8')
} catch{
var gitHash = null
}
e.sender.webContents.send('platform', [process.platform, process.arch, process.version, process.versions.chrome, process.versions.electron, gitHash]);
})
//言語
ipc.on('lang', function (e, arg) {

View File

@ -6,7 +6,7 @@
"main": "main.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"construct": "cd view/make && node make",
"construct": "cd view/make && node make --automatic && cd ../../",
"dev": "electron ./ --dev",
"dist": "build --linux snap",
"build:js": "node build.js",

View File

@ -25,6 +25,7 @@
<body>
<script>
var ver = "@@versionLetter@@";
var gitHash = "@@gitHash@@"
//betaを入れるとバージョンチェックしない
//GitHubに上げるときはindex.htmlをちゃんとする。(index.start.html)
//var ver="beta";

View File

@ -1,10 +1,15 @@
const fs = require("fs")
const readlineSync = require('readline-sync');
const readlineSync = require('readline-sync')
let ver = "Usamin (18.8.3)"
const execSync = require('child_process').execSync;
let gitHash = execSync("git rev-parse HEAD").toString().trim()
fs.writeFileSync("../../git", gitHash)
if (process.argv.indexOf("--automatic") === -1) {
let input = readlineSync.question('version string [empty: ' + ver + ' (default)]? ');
if (input) {
ver = input
}
}
console.log("Constructing view files " + ver + ": make sure to update package.json")
const langs = ["ja", "en", "ps", "bg", "cs", "de"]
const langsh = ["日本語", "English", "Crowdin translate system(beta)", "български", "Česky", "Deutsch"]
@ -37,6 +42,7 @@ for (let i = 0; i < samples.length; i++) {
source = source.replace(/@@comment-end@@/g, "-->")
}
source = source.replace(/@@versionLetter@@/g, ver)
source = source.replace(/@@gitHash@@/g, gitHash)
source = source.replace(/@@lang@@/g, lang)
source = source.replace(/@@langlist@@/g, langstr)
fs.writeFileSync("../" + lang + "/" + pages[i], source)