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/node_modules
app/js/login/tkn.js app/js/login/tkn.js
app/package-lock.json 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 - cd app
- VERSION=$(cat package.json | grep version | head -1 | awk -F= "{ print $2 }" | sed 's/[version:,\",]//g' | tr -d '[[:space:]]') - VERSION=$(cat package.json | grep version | head -1 | awk -F= "{ print $2 }" | sed 's/[version:,\",]//g' | tr -d '[[:space:]]')
- npm install - npm install
- npm run construct
- if [ "$TRAVIS_OS_NAME" = "osx" ];then electron-builder --mac -p never;else :;fi - 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 electron-builder --linux --x64 -p never;else :;fi
- if [ "$TRAVIS_OS_NAME" = "linux" ];then cd ../build;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) { ipc.on('platform', function (event, args) {
localStorage.setItem("platform", args[0]) localStorage.setItem("platform", args[0])
localStorage.setItem("bit", args[1]) 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) { ipc.on('reload', function (event, arg) {

View File

@ -25,7 +25,7 @@ function tips(mode) {
clearInterval(spotStart); clearInterval(spotStart);
if (mode == "ver") { if (mode == "ver") {
tipsToggle() 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") localStorage.setItem("tips", "ver")
} else if (mode == "clock") { } else if (mode == "clock") {
tipsToggle() tipsToggle()

View File

@ -42,7 +42,12 @@ function system(mainWindow, dir, lang, dirname) {
}); });
//プラットフォーム //プラットフォーム
ipc.on('getPlatform', function (e, arg) { 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) { ipc.on('lang', function (e, arg) {

View File

@ -6,7 +6,7 @@
"main": "main.js", "main": "main.js",
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1", "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", "dev": "electron ./ --dev",
"dist": "build --linux snap", "dist": "build --linux snap",
"build:js": "node build.js", "build:js": "node build.js",

View File

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

View File

@ -1,9 +1,14 @@
const fs = require("fs") const fs = require("fs")
const readlineSync = require('readline-sync'); const readlineSync = require('readline-sync')
let ver = "Usamin (18.8.3)" let ver = "Usamin (18.8.3)"
let input = readlineSync.question('version string [empty: '+ ver +' (default)]? '); const execSync = require('child_process').execSync;
if (input){ let gitHash = execSync("git rev-parse HEAD").toString().trim()
ver = input 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") console.log("Constructing view files " + ver + ": make sure to update package.json")
const langs = ["ja", "en", "ps", "bg", "cs", "de"] const langs = ["ja", "en", "ps", "bg", "cs", "de"]
@ -22,7 +27,7 @@ for (let i = 0; i < samples.length; i++) {
for (let j = 0; j < langs.length; j++) { for (let j = 0; j < langs.length; j++) {
let source = sourceParent let source = sourceParent
let lang = langs[j] let lang = langs[j]
let target = JSON.parse(fs.readFileSync("language/" + lang + "/" + simples[i] + ".json", 'utf8')) let target = JSON.parse(fs.readFileSync("language/" + lang + "/" + simples[i] + ".json", 'utf8'))
Object.keys(target).forEach(function (key) { Object.keys(target).forEach(function (key) {
let str = target[key] let str = target[key]
str = str.replace(/"/g, '\\"') str = str.replace(/"/g, '\\"')
@ -37,6 +42,7 @@ for (let i = 0; i < samples.length; i++) {
source = source.replace(/@@comment-end@@/g, "-->") source = source.replace(/@@comment-end@@/g, "-->")
} }
source = source.replace(/@@versionLetter@@/g, ver) source = source.replace(/@@versionLetter@@/g, ver)
source = source.replace(/@@gitHash@@/g, gitHash)
source = source.replace(/@@lang@@/g, lang) source = source.replace(/@@lang@@/g, lang)
source = source.replace(/@@langlist@@/g, langstr) source = source.replace(/@@langlist@@/g, langstr)
fs.writeFileSync("../" + lang + "/" + pages[i], source) fs.writeFileSync("../" + lang + "/" + pages[i], source)