This repository was archived by the owner on Jan 14, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +58
-0
lines changed Expand file tree Collapse file tree 5 files changed +58
-0
lines changed Original file line number Diff line number Diff line change 1
1
const electron = require ( 'electron' )
2
+ const os = require ( 'os' )
2
3
const BrowserWindow = electron . BrowserWindow
3
4
const dialog = electron . dialog
4
5
6
+ function getAppInfo ( ) {
7
+ const info = `
8
+ Version: ${ process . getVersion ( ) }
9
+ Commit: ${ process . getCommit ( ) }
10
+ Electron: ${ process . versions . electron }
11
+ Chrome: ${ process . versions . chrome }
12
+ Node.js: ${ process . versions . node }
13
+ V8: ${ process . versions . v8 }
14
+ OS: ${ os . type ( ) } ${ os . arch ( ) } ${ os . release ( ) } `
15
+ return info
16
+ }
17
+
5
18
function getMenu ( app , mainWindow ) {
6
19
const macOS = process . platform === 'darwin'
7
20
@@ -99,6 +112,18 @@ function getMenu (app, mainWindow) {
99
112
click ( ) {
100
113
BrowserWindow . getFocusedWindow ( ) . reload ( )
101
114
}
115
+ } ,
116
+ {
117
+ label : 'About' ,
118
+ click ( ) {
119
+ dialog . showMessageBox ( {
120
+ type : 'info' ,
121
+ title : 'Snippet Store' ,
122
+ message : 'Snippet Store' ,
123
+ detail : getAppInfo ( ) ,
124
+ buttons : [ 'OK' ]
125
+ } )
126
+ }
102
127
}
103
128
]
104
129
}
Original file line number Diff line number Diff line change 1
1
function runMainApp ( ) {
2
2
require ( './app/app-main' )
3
3
}
4
+
5
+ process . getCommit = ( ) => {
6
+ if ( process . env . npm_package_gitHead ) return process . env . npm_package_gitHead
7
+ return require ( './product.json' ) . commit
8
+ }
9
+
10
+ process . getVersion = ( ) => {
11
+ if ( process . env . npm_package_version ) return process . env . npm_package_version
12
+ return require ( './product.json' ) . version
13
+ }
14
+
4
15
runMainApp ( )
Original file line number Diff line number Diff line change 8
8
"fix" : " eslint . --fix" ,
9
9
"lint" : " eslint ." ,
10
10
"build" : " node scripts/build.js" ,
11
+ "product" : " node scripts/product.js" ,
11
12
"dist:linux" : " npm run build && rimraf dist/ && electron-builder --linux" ,
12
13
"dist:win" : " npm run build && rimraf dist/ && electron-builder --win" ,
13
14
"dist:mac" : " npm run build && rimraf dist/ && electron-builder --mac" ,
28
29
},
29
30
"files" : [
30
31
" index.js" ,
32
+ " product.json" ,
31
33
" compiled/**/*" ,
32
34
" app/**/*" ,
33
35
" resources/**/*" ,
Original file line number Diff line number Diff line change
1
+ {"version" :" 0.2.10" ,"commit" :" f965b4e453682a27162685d9415f86999116bef5" }
Original file line number Diff line number Diff line change
1
+ const fs = require ( 'fs' )
2
+ const path = require ( 'path' )
3
+
4
+ const pkgPath = path . join ( __dirname , '../package.json' )
5
+ const productPath = path . join ( __dirname , '../product.json' )
6
+ const pkg = require ( pkgPath )
7
+
8
+ function generateProductInfo ( ) {
9
+ const product = {
10
+ version : pkg . version ,
11
+ commit : require ( 'child_process' )
12
+ . execSync ( 'git rev-parse HEAD' )
13
+ . toString ( )
14
+ . trim ( )
15
+ }
16
+ fs . writeFileSync ( productPath , JSON . stringify ( product ) )
17
+ }
18
+
19
+ generateProductInfo ( )
You can’t perform that action at this time.
0 commit comments