aaden-cli 1.6.78 → 1.6.80

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,25 @@
1
+ #!/bin/bash
2
+
3
+ ServiceFileName=/etc/systemd/system/aaden-tee-maker.service
4
+
5
+ sudo touch $ServiceFileName
6
+ sudo chmod 777 $ServiceFileName
7
+ echo -e "
8
+ [Unit]
9
+ Description=Tee Maker Service For Aaden
10
+
11
+ [Service]
12
+ Type=simple
13
+ Restart=always
14
+ RestartSec=1
15
+ User=root
16
+ ExecStart=/usr/bin/php /var/www/html/PHP/autoSendTeaMakerTask.php
17
+
18
+ [Install]
19
+ WantedBy=multi-user.target
20
+ " > $ServiceFileName
21
+
22
+ sudo systemctl start aaden-tee-maker.service
23
+ sudo systemctl enable aaden-tee-maker.service
24
+ echo 'tee maker task auto send start'
25
+ sudo service aaden-tee-maker start
@@ -0,0 +1,130 @@
1
+ #!/bin/bash
2
+
3
+ deviceId=$1
4
+ targetVersion=$2
5
+ tseAdapterDownloadUrl=$3
6
+
7
+ function sendDeviceLog() {
8
+ _deviceId=$1
9
+ _content=$2
10
+ echo "<<< create log: $_content"
11
+ curl --location 'https://cloud-v2.aaden.io/deviceLog/createEvent' \
12
+ --header 'Content-Type: application/json' \
13
+ --data "{
14
+ \"deviceId\": \"$_deviceId\",
15
+ \"content\": \"$_content\",
16
+ \"type\": \"维护状态更新\",
17
+ \"appendUrl\": \"\",
18
+ \"operator\": \"updateAadenTse.sh\"
19
+ }"
20
+ return 0
21
+ }
22
+
23
+ # get tse version via php
24
+ tseVersionCommand=$(cat <<- 'PHP'
25
+ $ini = parse_ini_file('/var/www/html/Resource/config/config.ini', true);
26
+ $tseUrl = $ini['TSE']['TseHost'] ?? 'http://localhost:8014';
27
+ $versionResp = file_get_contents("$tseUrl/adapterVersion");
28
+ $version = json_decode($versionResp, true)['major'] ?? 'null';
29
+ echo $version;
30
+ PHP
31
+ )
32
+ tseVersion=`php -r "$tseVersionCommand"`
33
+
34
+ # exit if no need to update
35
+ if [ $tseVersion != 'null' ]; then
36
+ if [ $targetVersion -le $tseVersion ]; then
37
+ sendDeviceLog $deviceId "no need to update tse, current version is ($tseVersion)"
38
+ exit 1
39
+ fi
40
+ fi
41
+
42
+ # get os version via php
43
+ osCommand=$(cat <<- 'PHP'
44
+ $osVersion = shell_exec('cat /proc/version');
45
+ if (strpos($osVersion, 'microsoft') !== false || strpos($osVersion, 'WSL2') !== false) {
46
+ $os = 'windows';
47
+ } else {
48
+ $os = 'linux';
49
+ }
50
+ echo $os;
51
+ PHP
52
+ )
53
+ os=`php -r "$osCommand"`
54
+
55
+ sendDeviceLog $deviceId "user os is ($os)"
56
+
57
+ # download tse adapter
58
+ wget -O latest-tse-adapter.jar "$tseAdapterDownloadUrl"
59
+
60
+ if [ $os == 'windows' ]; then
61
+ # find tse dir
62
+ tseDirSearchCommand=$(cat <<- 'PHP'
63
+ $arr = scandir('/mnt/c/Users');
64
+ if (in_array('POS', $arr)) {
65
+ $userDir = 'POS';
66
+ } elseif (in_array('inner', $arr)) {
67
+ $userDir = 'inner';
68
+ } else {
69
+ $userDir = null;
70
+ }
71
+
72
+ if ($userDir) {
73
+ echo "/mnt/c/Users/$userDir/Desktop/AadenTseOnWindows";
74
+ } else {
75
+ echo 'null';
76
+ }
77
+ PHP
78
+ )
79
+ tseDir=`php -r "$tseDirSearchCommand"`
80
+
81
+ if [ tseDir == 'null' ]; then
82
+ sendDeviceLog $deviceId "cannot find 'POS' or 'inner' in User directory, abort"
83
+ exit 1
84
+ fi
85
+
86
+ #test tse dir
87
+ testTseDirCommand=$(cat <<- 'PHP'
88
+ $dir = fgets(STDIN);
89
+ $arr = scandir($dir);
90
+ echo $arr !== false ? 'true' : 'false';
91
+ PHP
92
+ )
93
+ testTseDirResult=`echo "$tseDir" | php -r "$testTseDirCommand"`
94
+
95
+ if [ testTseDirResult == 'false' ]; then
96
+ sendDeviceLog $deviceId "cannot find '$tseDir', abort"
97
+ fi
98
+
99
+ # copy and override
100
+ cp -f latest-tse-adapter.jar "$tseDir/tse-0.0.3.jar"
101
+
102
+ # restart service
103
+ $tseDir/AadenTseServiceRegister.exe restart
104
+
105
+ else
106
+ sudo cp -f latest-tse-adapter.jar /var/www/html/TseHost/tse-0.0.2.jar
107
+ sudo service aaden-tse restart
108
+ fi
109
+
110
+ echo "sleep 15s to wait service restart"
111
+ sleep 15s
112
+
113
+ tseVersionCommand2=$(cat <<- 'PHP'
114
+ $ini = parse_ini_file('/var/www/html/Resource/config/config.ini', true);
115
+ $tseUrl = $ini['TSE']['TseHost'] ?? 'http://localhost:8014';
116
+ $versionResp = file_get_contents("$tseUrl/adapterVersion");
117
+ $version = json_decode($versionResp, true)['major'] ?? 'null';
118
+ echo $version;
119
+ PHP
120
+ )
121
+ tseVersion2=`php -r "$tseVersionCommand2"`
122
+
123
+ if [ $tseVersion2 != 'null' ]; then
124
+ if [ $targetVersion -le $tseVersion2 ]; then
125
+ sendDeviceLog $deviceId "tse update done, current version is ($tseVersion2)"
126
+ exit 1
127
+ fi
128
+ fi
129
+
130
+ sendDeviceLog $deviceId "update failed, current version is ($tseVersion2)"
@@ -9,3 +9,5 @@ delete from PaymentLog where 1=1;
9
9
  delete from ZbonCombinedRecord where 1=1;
10
10
  insert into ZbonCombinedRecord (zbonNumber, toTimestamp)
11
11
  values (0, current_timestamp);
12
+ delete from MemberCardRecord where true;
13
+ delete from CashAmountLiteral where true;
package/dist/index.js CHANGED
@@ -18507,7 +18507,7 @@ module.exports = JSON.parse('{"name":"axios","version":"0.19.2","description":"P
18507
18507
  /***/ ((module) => {
18508
18508
 
18509
18509
  "use strict";
18510
- module.exports = {"i8":"1.6.78"};
18510
+ module.exports = {"i8":"1.6.80"};
18511
18511
 
18512
18512
  /***/ })
18513
18513
 
@@ -18624,6 +18624,7 @@ program.command('update-ngrok-config <deviceId>').action(updateNgrokConfig)
18624
18624
  program.command('run <filePath>').action(run)
18625
18625
  program.command('patch').action(patch)
18626
18626
  program.command('check-tse').action(checkTse)
18627
+ program.command('check-win-tse').action(checkWinTse)
18627
18628
  program.command('setup-tse').action(enableTSE)
18628
18629
  program.command('check-version').action(getBackendVersionOffline)
18629
18630
  program.command('full-update').action(fullUpdate)
@@ -18636,6 +18637,7 @@ program.command('convert-database').action(convertDataBaseCharset)
18636
18637
  program.command('migrate').action(migrate)
18637
18638
 
18638
18639
  program.command('auto-write-gdpdu').action(autoWriteGdpdu)
18640
+ program.command('auto-send-tea-maker-task').action(autoSendTeaMakerTask)
18639
18641
  program.command('export-tse').action(exportTse)
18640
18642
  program.command('fix-ngrok').action(fixNgrok)
18641
18643
  program.command('do-log').action(doLog)
@@ -18742,6 +18744,26 @@ function checkTse() {
18742
18744
  cli.executeInShell(['journalctl -f -u aaden-tse.service'], program.debug)
18743
18745
  }
18744
18746
 
18747
+ async function checkWinTse() {
18748
+ if (!fs.existsSync('/mnt/c/Users')) {
18749
+ console.log('此系统不是Windows,请改用 aaden-cli check-tse')
18750
+ return
18751
+ }
18752
+
18753
+ const logPaths = fs.readdirSync('/mnt/c/Users')
18754
+ .map(x => `/mnt/c/Users/${x}/Desktop/AadenTseOnWindows/logs/AadenTseServiceRegister.out.log`)
18755
+ .filter(x => fs.existsSync(x))
18756
+
18757
+ if (logPaths.length === 0) {
18758
+ console.log('未找到Windows TSE日志')
18759
+ return
18760
+ }
18761
+
18762
+ const logPath = logPaths[0]
18763
+
18764
+ cli.executeInShell([`tail -n 100 -f ${logPath}`], program.debug)
18765
+ }
18766
+
18745
18767
  function remountTSE() {
18746
18768
  const files = ['AadenDeploy/mountTSE.sh']
18747
18769
  runMultiple(files)
@@ -19038,7 +19060,7 @@ async function update(channel = '') {
19038
19060
  `./update.sh ${channel}`
19039
19061
  ])
19040
19062
  const {code} = await cli.executeInShell(command, program.debug)
19041
- await logAction("进行了手动更新update",code)
19063
+ await logAction("进行了手动更新update", code)
19042
19064
  } catch (e) {
19043
19065
  console.error(e)
19044
19066
  }
@@ -19196,16 +19218,15 @@ async function doLog() {
19196
19218
  const frontendVersion = list[list.length - 2].replace(/\s+/g, ' ')
19197
19219
  .split(' ')[1]
19198
19220
 
19199
- await deviceEcho({
19200
- frontendVersion,
19201
- cliVersion: version,
19202
- diskUsage: diskUsage[diskUsage.length - 1].replace('\n', ''),
19203
- upTime: getUpTime(),
19204
- ngrokIsNew: ngrokNewestVersion()
19205
- }
19206
- )
19207
- console.log('finish')
19208
-
19221
+ await deviceEcho({
19222
+ frontendVersion,
19223
+ cliVersion: version,
19224
+ diskUsage: diskUsage[diskUsage.length - 1].replace('\n', ''),
19225
+ upTime: getUpTime(),
19226
+ ngrokIsNew: ngrokNewestVersion()
19227
+ }
19228
+ )
19229
+ console.log('finish')
19209
19230
 
19210
19231
 
19211
19232
  process.exit(0)
@@ -19226,6 +19247,11 @@ function autoWriteGdpdu() {
19226
19247
  runMultiple(files)
19227
19248
  }
19228
19249
 
19250
+ function autoSendTeaMakerTask() {
19251
+ const files = ['AadenDeploy/Utils/sendTeaMakerTaskService.sh']
19252
+ runMultiple(files)
19253
+ }
19254
+
19229
19255
  })();
19230
19256
 
19231
19257
  module.exports = __webpack_exports__;
package/index.js CHANGED
@@ -43,6 +43,7 @@ program.command('update-ngrok-config <deviceId>').action(updateNgrokConfig)
43
43
  program.command('run <filePath>').action(run)
44
44
  program.command('patch').action(patch)
45
45
  program.command('check-tse').action(checkTse)
46
+ program.command('check-win-tse').action(checkWinTse)
46
47
  program.command('setup-tse').action(enableTSE)
47
48
  program.command('check-version').action(getBackendVersionOffline)
48
49
  program.command('full-update').action(fullUpdate)
@@ -55,6 +56,7 @@ program.command('convert-database').action(convertDataBaseCharset)
55
56
  program.command('migrate').action(migrate)
56
57
 
57
58
  program.command('auto-write-gdpdu').action(autoWriteGdpdu)
59
+ program.command('auto-send-tea-maker-task').action(autoSendTeaMakerTask)
58
60
  program.command('export-tse').action(exportTse)
59
61
  program.command('fix-ngrok').action(fixNgrok)
60
62
  program.command('do-log').action(doLog)
@@ -161,6 +163,26 @@ function checkTse() {
161
163
  cli.executeInShell(['journalctl -f -u aaden-tse.service'], program.debug)
162
164
  }
163
165
 
166
+ async function checkWinTse() {
167
+ if (!fs.existsSync('/mnt/c/Users')) {
168
+ console.log('此系统不是Windows,请改用 aaden-cli check-tse')
169
+ return
170
+ }
171
+
172
+ const logPaths = fs.readdirSync('/mnt/c/Users')
173
+ .map(x => `/mnt/c/Users/${x}/Desktop/AadenTseOnWindows/logs/AadenTseServiceRegister.out.log`)
174
+ .filter(x => fs.existsSync(x))
175
+
176
+ if (logPaths.length === 0) {
177
+ console.log('未找到Windows TSE日志')
178
+ return
179
+ }
180
+
181
+ const logPath = logPaths[0]
182
+
183
+ cli.executeInShell([`tail -n 100 -f ${logPath}`], program.debug)
184
+ }
185
+
164
186
  function remountTSE() {
165
187
  const files = ['AadenDeploy/mountTSE.sh']
166
188
  runMultiple(files)
@@ -457,7 +479,7 @@ async function update(channel = '') {
457
479
  `./update.sh ${channel}`
458
480
  ])
459
481
  const {code} = await cli.executeInShell(command, program.debug)
460
- await logAction("进行了手动更新update",code)
482
+ await logAction("进行了手动更新update", code)
461
483
  } catch (e) {
462
484
  console.error(e)
463
485
  }
@@ -615,16 +637,15 @@ async function doLog() {
615
637
  const frontendVersion = list[list.length - 2].replace(/\s+/g, ' ')
616
638
  .split(' ')[1]
617
639
 
618
- await deviceEcho({
619
- frontendVersion,
620
- cliVersion: version,
621
- diskUsage: diskUsage[diskUsage.length - 1].replace('\n', ''),
622
- upTime: getUpTime(),
623
- ngrokIsNew: ngrokNewestVersion()
624
- }
625
- )
626
- console.log('finish')
627
-
640
+ await deviceEcho({
641
+ frontendVersion,
642
+ cliVersion: version,
643
+ diskUsage: diskUsage[diskUsage.length - 1].replace('\n', ''),
644
+ upTime: getUpTime(),
645
+ ngrokIsNew: ngrokNewestVersion()
646
+ }
647
+ )
648
+ console.log('finish')
628
649
 
629
650
 
630
651
  process.exit(0)
@@ -644,3 +665,8 @@ function autoWriteGdpdu() {
644
665
  const files = ['AadenDeploy/Utils/writeGdpduService.sh']
645
666
  runMultiple(files)
646
667
  }
668
+
669
+ function autoSendTeaMakerTask() {
670
+ const files = ['AadenDeploy/Utils/sendTeaMakerTaskService.sh']
671
+ runMultiple(files)
672
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aaden-cli",
3
- "version": "1.6.78",
3
+ "version": "1.6.80",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {