aaden-cli 1.2.26 → 1.2.29

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.
package/dist/index.js CHANGED
@@ -58161,7 +58161,7 @@ module.exports = JSON.parse('{"name":"axios","version":"0.19.2","description":"P
58161
58161
  /***/ ((module) => {
58162
58162
 
58163
58163
  "use strict";
58164
- module.exports = {"i8":"1.2.25"};
58164
+ module.exports = {"i8":"1.2.28"};
58165
58165
 
58166
58166
  /***/ }),
58167
58167
 
@@ -58402,24 +58402,24 @@ program.version(version)
58402
58402
  hillo.initial('http://innerken.com/iplogger/')
58403
58403
 
58404
58404
  console.log(
58405
- '*******************************************************\n' +
58406
- 'Aaden CLI'.bgCyan + ' Version:' + version.bgRed + '\n' +
58407
- 'Made with ' + '❤'.red + ' and InnerKen \n' +
58408
- '*******************************************************'
58405
+ '*******************************************************\n' +
58406
+ 'Aaden CLI'.bgCyan + ' Version:' + version.bgRed + '\n' +
58407
+ 'Made with ' + '❤'.red + ' and InnerKen \n' +
58408
+ '*******************************************************'
58409
58409
  )
58410
58410
  program
58411
- .option('-d, --debug', 'use Debug Out put')
58411
+ .option('-d, --debug', 'use Debug Out put')
58412
58412
  program.command('update [channel]').action(update)
58413
58413
  program
58414
- .command('install <deviceId>')
58415
- .action(install)
58414
+ .command('install <deviceId>')
58415
+ .action(install)
58416
58416
  program.command('remove-all-data').action(removeAllData)
58417
58417
  program.command('mount-tse').action(remountTSE)
58418
58418
  program.command('upgrade').action(upgrade) // auto execute.
58419
58419
  program.command('auto-upgrade').action(autoUpgrade) // auto execute.
58420
58420
  program.command('load-new-version').action(loadNewVersion) // auto execute.
58421
58421
  program.command('local-version').action(() => {
58422
- console.log('storage:' + getStorageBackendFileVersion())
58422
+ console.log('storage:' + getStorageBackendFileVersion())
58423
58423
  })
58424
58424
  program.command('backup [noUpload]').action(backup)
58425
58425
  program.command('ngrok').action(startNgrokService)
@@ -58442,514 +58442,522 @@ program.command('enable-mile-pay').action(enableMilePay)
58442
58442
  program.command('start-mile-pay').action(startService)
58443
58443
  program.command('convert-database').action(convertDataBaseCharset)
58444
58444
  program.command('mile-pay-option')
58445
- .option('-k, --access-key <accessKey>')
58446
- .option('-s, --access-secret <accessSecret>')
58447
- .option('-m, --merchant-no <merchantNo>')
58448
- .action(milePayOption)
58445
+ .option('-k, --access-key <accessKey>')
58446
+ .option('-s, --access-secret <accessSecret>')
58447
+ .option('-m, --merchant-no <merchantNo>')
58448
+ .action(milePayOption)
58449
58449
  program.command('enable-resource-track').action(enableResourceTrack)
58450
58450
  program.command('start-resource-track').action(startResourceTrack)
58451
58451
  program.command('auto-send-mail').action(editIni)
58452
58452
  program.command('auto-send-summary').action(autoSendSummaryLastMonth)
58453
- program.command('set-do-not-send-zbon-when-print-true').
58454
- action(editConfigIni(setConfig('Email', 'DoNotSendZbonWhenPrint', true)))
58455
- program.command('set-do-not-send-zbon-when-print-false').
58456
- action(editConfigIni(setConfig('Email', 'DoNotSendZbonWhenPrint', false)))
58457
- program.command('set-auto-send-3in1-today-true').
58458
- action(editConfigIni(setConfig('Email', 'AutoSend3in1Today', true)))
58459
- program.command('set-auto-send-3in1-today-false').
58460
- action(editConfigIni(setConfig('Email', 'AutoSend3in1Today', false)))
58453
+ program.command('set-do-not-send-zbon-when-print-true').action(editConfigIni(setConfig('Email', 'DoNotSendZbonWhenPrint', true)))
58454
+ program.command('set-do-not-send-zbon-when-print-false').action(editConfigIni(setConfig('Email', 'DoNotSendZbonWhenPrint', false)))
58455
+ program.command('set-auto-send-3in1-today-true').action(editConfigIni(setConfig('Email', 'AutoSend3in1Today', true)))
58456
+ program.command('set-auto-send-3in1-today-false').action(editConfigIni(setConfig('Email', 'AutoSend3in1Today', false)))
58461
58457
  program.command('auto-write-gdpdu').action(autoWriteGdpdu)
58462
58458
 
58463
58459
  if (program.debug) {
58464
- debugInfo()
58465
- console.log(process.argv)
58460
+ debugInfo()
58461
+ console.log(process.argv)
58466
58462
  }
58467
58463
  basicInfo()
58468
58464
 
58469
58465
  if (process.argv[2] === undefined) {
58470
- selectOption()
58466
+ selectOption()
58471
58467
  } else {
58472
- program.parse(process.argv)
58473
- }
58474
-
58475
- function basicInfo () {
58476
- console.log('本设备DeviceId:' + getMyDeviceId().toString().bgYellow)
58477
- console.log('本设备当前后台版本:' + getBackendVersionOffline().bgYellow)
58478
- console.log('开始执行命令:' + process.argv.join(' ').cyan)
58479
- console.log('...')
58480
- }
58481
-
58482
- async function selectOption () {
58483
- const select = await prompts({
58484
- type: 'autocomplete',
58485
- name: 'option',
58486
- message: 'Select what you want to do next? ' +
58487
- '请选择下一步要进行的操作',
58488
- choices: [
58489
- {title: 'Upgrade Aaden-cli 手动更新Aaden-cli到最新版本', description: '', value: 'upgrade'},
58490
- {title: 'Backup all backend data 备份后端数据库数据', description: '操作数据库数据前请先备份', value: 'backup'},
58491
- {title: 'Full update 全更新', description: '更新前请先备份', value: 'full-update'},
58492
- {title: 'Check Tse 检查Tse设备', description: '', value: 'check-tse'},
58493
- {title: 'Start Ngrok 打开Ngrok服务', description: '', value: 'ngrok'},
58494
- {title: 'Install Aaden Kasse 安装最新版Aaden Kasse', value: `install ${GlobalDeviceId}`},
58495
- {title: 'Add Dishes 执行上菜脚本app.py', description: '-p ImgPath -i DishCSVPath -a AttrPath', value: 'add-dish'},
58496
- {title: 'Check version 检查后端版本号', description: '', value: 'check-version'},
58497
- {title: 'Patch 打补丁', description: '请勿手动执行', value: 'patch'},
58498
- {title: 'Remove all data 删除所有数据', description: '谨慎操作'.red, value: 'remove-all-data'},
58499
- {title: 'Setup Tse 安装Tse', description: '谨慎操作'.red + ' 每个设备只能安装一次TSE', value: 'setup-tse'},
58500
- {
58501
- title: 'Mount Tse 永久挂载Tse设备', description: '谨慎操作'.red + ' ' +
58502
- '进行此操作会导致TSE重新自检,使用前请先检查是否已经正确插入Tse设备(Tse设备是否正常亮灯)', value: 'mount-tse'
58503
- },
58504
- {
58505
- title: 'Update Ngrok 更新Ngrok配置',
58506
- description: '输入本设备的DeviceId,更新Ngrok配置',
58507
- value: `update-ngrok-config ${GlobalDeviceId}`
58508
- },
58509
- {title: 'Exit 退出', description: 'return to terminal', value: 'return-terminal'}
58510
- ],
58511
- initial: 1
58512
- })
58513
-
58514
- if (select.option) {
58515
- console.log(select.option)
58516
- process.argv = [...process.argv, ...select.option.split(' ')]
58517
58468
  program.parse(process.argv)
58518
- }
58519
58469
  }
58520
58470
 
58521
- function log(){
58522
- cli.executeInShell(['tail -f /var/www/html/Resource/failLog.log'])
58471
+ function basicInfo() {
58472
+ console.log('本设备DeviceId:' + getMyDeviceId().toString().bgYellow)
58473
+ console.log('本设备当前后台版本:' + getBackendVersionOffline().bgYellow)
58474
+ console.log('开始执行命令:' + process.argv.join(' ').cyan)
58475
+ console.log('...')
58523
58476
  }
58524
58477
 
58525
- function enterDatabase () {
58526
- const command = [
58527
- `mysql -uaaden -pInnerken322. -Daaden`
58528
- ]
58529
- cli.executeInShell(command, program.debug)
58478
+ async function selectOption() {
58479
+ const select = await prompts({
58480
+ type: 'autocomplete',
58481
+ name: 'option',
58482
+ message: 'Select what you want to do next? ' +
58483
+ '请选择下一步要进行的操作',
58484
+ choices: [
58485
+ {title: 'Upgrade Aaden-cli 手动更新Aaden-cli到最新版本', description: '', value: 'upgrade'},
58486
+ {
58487
+ title: 'Backup all backend data 备份后端数据库数据',
58488
+ description: '操作数据库数据前请先备份',
58489
+ value: 'backup'
58490
+ },
58491
+ {title: 'Full update 全更新', description: '更新前请先备份', value: 'full-update'},
58492
+ {title: 'Check Tse 检查Tse设备', description: '', value: 'check-tse'},
58493
+ {title: 'Start Ngrok 打开Ngrok服务', description: '', value: 'ngrok'},
58494
+ {title: 'Install Aaden Kasse 安装最新版Aaden Kasse', value: `install ${GlobalDeviceId}`},
58495
+ {
58496
+ title: 'Add Dishes 执行上菜脚本app.py',
58497
+ description: '-p ImgPath -i DishCSVPath -a AttrPath',
58498
+ value: 'add-dish'
58499
+ },
58500
+ {title: 'Check version 检查后端版本号', description: '', value: 'check-version'},
58501
+ {title: 'Patch 打补丁', description: '请勿手动执行', value: 'patch'},
58502
+ {title: 'Remove all data 删除所有数据', description: '谨慎操作'.red, value: 'remove-all-data'},
58503
+ {title: 'Setup Tse 安装Tse', description: '谨慎操作'.red + ' 每个设备只能安装一次TSE', value: 'setup-tse'},
58504
+ {
58505
+ title: 'Mount Tse 永久挂载Tse设备',
58506
+ description: '谨慎操作'.red + ' ' +
58507
+ '进行此操作会导致TSE重新自检,使用前请先检查是否已经正确插入Tse设备(Tse设备是否正常亮灯)',
58508
+ value: 'mount-tse'
58509
+ },
58510
+ {
58511
+ title: 'Update Ngrok 更新Ngrok配置',
58512
+ description: '输入本设备的DeviceId,更新Ngrok配置',
58513
+ value: `update-ngrok-config ${GlobalDeviceId}`
58514
+ },
58515
+ {title: 'Exit 退出', description: 'return to terminal', value: 'return-terminal'}
58516
+ ],
58517
+ initial: 1
58518
+ })
58519
+
58520
+ if (select.option) {
58521
+ console.log(select.option)
58522
+ process.argv = [...process.argv, ...select.option.split(' ')]
58523
+ program.parse(process.argv)
58524
+ }
58530
58525
  }
58531
58526
 
58532
- function testPrinter () {
58533
- const command = [
58534
- `wget localhost/PHP/Complex.php?op=testAllPrinter`
58535
- ]
58536
- cli.executeInShell(command, program.debug)
58527
+ function log() {
58528
+ cli.executeInShell(['tail -f /var/www/html/Resource/failLog.log'])
58537
58529
  }
58538
58530
 
58539
- function getDatabase () {
58540
- const command = [
58541
- `mysqldump -uaaden -pInnerken322. --databases aaden --tables Attribute AttributeGroup BonTemplate Category_AttributeGroup DishWithName Dish_AttributeGroup Dishes DishesString DishesCategory DishesCategoryString> transfer.sql`,
58542
- 'sudo cp transfer.sql /var/www/html'
58543
- ]
58544
- cli.executeInShell(command, program.debug)
58531
+ function enterDatabase() {
58532
+ const command = [
58533
+ `mysql -uaaden -pInnerken322. -Daaden`
58534
+ ]
58535
+ cli.executeInShell(command, program.debug)
58545
58536
  }
58546
58537
 
58547
- function getNewDatabase () {
58548
- const command = [
58549
- `mysqldump -uaaden -pInnerken322. --databases aaden --tables Attribute AttributeGroup BonTemplate Category_AttributeGroup DishWithName Dish_AttributeGroup Dishes DishesString DishesCategory DishesCategoryString DishesCategoryType DishesCategoryTypeString ConsumeType_Dishes_Free ConsumeType_Dishes_Show> transfer.sql`,
58550
- 'sudo cp transfer.sql /var/www/html'
58551
- ]
58552
- cli.executeInShell(command, program.debug)
58538
+ function testPrinter() {
58539
+ const command = [
58540
+ `wget localhost/PHP/Complex.php?op=testAllPrinter`
58541
+ ]
58542
+ cli.executeInShell(command, program.debug)
58553
58543
  }
58554
58544
 
58555
- function debugInfo () {
58556
- console.log(program.opts())
58557
- console.log('')
58545
+ function getDatabase() {
58546
+ const command = [
58547
+ `mysqldump -uaaden -pInnerken322. --databases aaden --tables Attribute AttributeGroup BonTemplate Category_AttributeGroup DishWithName Dish_AttributeGroup Dishes DishesString DishesCategory DishesCategoryString> transfer.sql`,
58548
+ 'sudo cp transfer.sql /var/www/html'
58549
+ ]
58550
+ cli.executeInShell(command, program.debug)
58558
58551
  }
58559
58552
 
58560
- function checkTse () {
58561
- cli.executeInShell(['journalctl -f -u aaden-tse.service'], program.debug)
58553
+ function getNewDatabase() {
58554
+ const command = [
58555
+ `mysqldump -uaaden -pInnerken322. --databases aaden --tables Attribute AttributeGroup BonTemplate Category_AttributeGroup DishWithName Dish_AttributeGroup Dishes DishesString DishesCategory DishesCategoryString DishesCategoryType DishesCategoryTypeString ConsumeType_Dishes_Free ConsumeType_Dishes_Show> transfer.sql`,
58556
+ 'sudo cp transfer.sql /var/www/html'
58557
+ ]
58558
+ cli.executeInShell(command, program.debug)
58562
58559
  }
58563
58560
 
58564
- function remountTSE () {
58565
- const files = ['AadenDeploy/mountTSE.sh']
58566
- runMultiple(files)
58561
+ function debugInfo() {
58562
+ console.log(program.opts())
58563
+ console.log('')
58567
58564
  }
58568
58565
 
58569
- function enableTSE () {
58570
- const files = ['AadenDeploy/mountTSE.sh', 'AadenDeploy/Utils/tseReady.sh']
58571
- runMultiple(files)
58566
+ function checkTse() {
58567
+ cli.executeInShell(['journalctl -f -u aaden-tse.service'], program.debug)
58572
58568
  }
58573
58569
 
58574
- function fixCronJob(){
58575
- const files = ['AadenDeploy/Utils/fixCronJob.sh']
58576
- runMultiple(files)
58570
+ function remountTSE() {
58571
+ const files = ['AadenDeploy/mountTSE.sh']
58572
+ runMultiple(files)
58577
58573
  }
58578
58574
 
58575
+ function enableTSE() {
58576
+ const files = ['AadenDeploy/mountTSE.sh', 'AadenDeploy/Utils/tseReady.sh']
58577
+ runMultiple(files)
58578
+ }
58579
58579
 
58580
+ function fixCronJob() {
58581
+ const files = ['AadenDeploy/Utils/fixCronJob.sh']
58582
+ runMultiple(files)
58583
+ }
58580
58584
 
58581
- async function patch () {
58582
- const configRoot = '/etc/aaden/config'
58583
- const rootPath = __nccwpck_require__.ab + "patch"
58584
- const patchRecordFilePath = configRoot + '/patchLog.json'
58585
- const pathList = fs.readdirSync(__nccwpck_require__.ab + "patch")
58586
58585
 
58587
- let readyList = []
58588
- try {
58589
- readyList = JSON.parse(fs.readFileSync(patchRecordFilePath))
58590
- } catch (e) {
58591
- console.error(e)
58592
- console.log('Create Patch Log File in :-->>' + patchRecordFilePath)
58593
- fs.openSync(patchRecordFilePath, 'w+')
58594
- }
58595
- const runList = pathList.map(p => 'patch/' + p).filter(p => {
58596
- return !readyList.includes(p)
58597
- })
58586
+ async function patch() {
58587
+ const configRoot = '/etc/aaden/config'
58588
+ const rootPath = __nccwpck_require__.ab + "patch"
58589
+ const patchRecordFilePath = configRoot + '/patchLog.json'
58590
+ const pathList = fs.readdirSync(__nccwpck_require__.ab + "patch")
58598
58591
 
58599
- if (runList.length > 0) {
58600
- runMultiple(runList)
58601
- readyList = readyList.concat(runList)
58602
- fs.writeFileSync(patchRecordFilePath, JSON.stringify(readyList))
58603
- }
58592
+ let readyList = []
58593
+ try {
58594
+ readyList = JSON.parse(fs.readFileSync(patchRecordFilePath))
58595
+ } catch (e) {
58596
+ console.error(e)
58597
+ console.log('Create Patch Log File in :-->>' + patchRecordFilePath)
58598
+ fs.openSync(patchRecordFilePath, 'w+')
58599
+ }
58600
+ const runList = pathList.map(p => 'patch/' + p).filter(p => {
58601
+ return !readyList.includes(p)
58602
+ })
58603
+
58604
+ if (runList.length > 0) {
58605
+ runMultiple(runList)
58606
+ readyList = readyList.concat(runList)
58607
+ fs.writeFileSync(patchRecordFilePath, JSON.stringify(readyList))
58608
+ }
58604
58609
 
58605
58610
  }
58606
58611
 
58607
- async function runMultiple (files) {
58608
- const command = files.reduce((arr, f) => {
58609
- arr.push(...getPrivilegeCMD(f))
58610
- arr.push('./' + f)
58611
- return arr
58612
- }, [])
58613
- cli.executeInShell(command, program.debug)
58612
+ async function runMultiple(files) {
58613
+ const command = files.reduce((arr, f) => {
58614
+ arr.push(...getPrivilegeCMD(f))
58615
+ arr.push('./' + f)
58616
+ return arr
58617
+ }, [])
58618
+ cli.executeInShell(command, program.debug)
58614
58619
  }
58615
58620
 
58616
- async function run (filePath) {
58617
- const command = [
58618
- ...getPrivilegeCMD(filePath),
58619
- './' + filePath
58620
- ]
58621
- cli.executeInShell(command, program.debug)
58621
+ async function run(filePath) {
58622
+ const command = [
58623
+ ...getPrivilegeCMD(filePath),
58624
+ './' + filePath
58625
+ ]
58626
+ cli.executeInShell(command, program.debug)
58622
58627
  }
58623
58628
 
58624
- function fullUpdate () {
58625
- const command = [
58626
- 'aaden-cli backup',
58627
- 'sudo npm update aaden-cli -g',
58628
- 'aaden-cli upgrade',
58629
- 'aaden-cli update',
58630
- 'aaden-cli backup'
58631
- ]
58632
- cli.executeInShell(command, program.debug)
58629
+ function fullUpdate() {
58630
+ const command = [
58631
+ 'aaden-cli backup',
58632
+ 'sudo npm update aaden-cli -g',
58633
+ 'aaden-cli upgrade',
58634
+ 'aaden-cli update',
58635
+ 'aaden-cli backup'
58636
+ ]
58637
+ cli.executeInShell(command, program.debug)
58633
58638
  }
58634
58639
 
58635
- async function updateNgrokConfig (deviceId) {
58636
- console.log(deviceId)
58637
- if (!deviceId || deviceId === 'notset') {
58638
- const getDeviceId = await prompts({
58639
- type: 'number',
58640
- name: 'id',
58641
- message: '请输入要配置ngrok的设备Id:'
58642
- })
58643
- deviceId = getDeviceId.id
58644
- }
58640
+ async function updateNgrokConfig(deviceId) {
58641
+ console.log(deviceId)
58642
+ if (!deviceId || deviceId === 'notset') {
58643
+ const getDeviceId = await prompts({
58644
+ type: 'number',
58645
+ name: 'id',
58646
+ message: '请输入要配置ngrok的设备Id:'
58647
+ })
58648
+ deviceId = getDeviceId.id
58649
+ }
58645
58650
 
58646
- console.log('Start to config Ngrok service')
58647
- console.log('开始配置' + deviceId + '设备的Ngrok服务')
58651
+ console.log('Start to config Ngrok service')
58652
+ console.log('开始配置' + deviceId + '设备的Ngrok服务')
58648
58653
 
58649
- const command = [
58650
- 'cd /etc',
58651
- 'sudo mkdir -p aaden',
58652
- 'cd aaden',
58653
- 'sudo touch ngrok-config.yml',
58654
- 'sudo chmod 777 ngrok-config.yml',
58655
- `echo "
58654
+ const command = [
58655
+ 'cd /etc',
58656
+ 'sudo mkdir -p aaden',
58657
+ 'cd aaden',
58658
+ 'sudo touch ngrok-config.yml',
58659
+ 'sudo chmod 777 ngrok-config.yml',
58660
+ `echo "
58656
58661
  server_addr: ngrok.aaden.io:4443
58657
58662
  trust_host_root_certs: true
58658
58663
  tunnels:
58659
58664
  web:
58660
58665
  proto:
58661
- http: 80
58666
+ https: 80
58662
58667
  subdomain: ik${String(deviceId).padStart(4, '0')}
58668
+ http:
58669
+ proto:
58670
+ http: 80
58671
+ subdomain: ik${String(deviceId).padStart(4, '0')}
58663
58672
  ssh:
58664
58673
  proto:
58665
58674
  tcp: 22
58666
58675
  remote_port: ${parseInt(deviceId) + 10000}" > ngrok-config.yml`
58667
- ]
58668
- cli.executeInShell(command, program.debug)
58676
+ ]
58677
+ cli.executeInShell(command, program.debug)
58669
58678
  }
58670
58679
 
58671
- async function startNgrokService () {
58672
- const command = [
58673
- ...getPrivilegeCMD('AadenDeploy/ngrok/ngrok'),
58674
- 'cd AadenDeploy/ngrok',
58675
- './ngrok -config=/etc/aaden/ngrok-config.yml start web ssh'
58676
- ]
58677
- cli.executeInShell(command, program.debug)
58678
- }
58679
-
58680
- async function backup (noUpload = false) {
58681
- const timeStamp = dayjs().format(InnerKenTimeStampFormat)
58682
- const backupHome = 'appendBackup'
58683
- const command = [
58684
- 'cd',
58685
- 'sudo mkdir -p backups',
58686
- 'sudo chmod 777 backups',
58687
- 'sudo mkdir -p backups/' + timeStamp,
58688
- 'sudo chmod 777 backups/' + timeStamp,
58689
- 'cd backups/' + timeStamp,
58690
- `mysqldump aaden -uaaden -pInnerken322. -c> ${timeStamp}@cli.sql`,
58691
- 'cd',
58692
- 'sudo mkdir -p ' + backupHome,
58693
- 'sudo chmod 777 ' + backupHome,
58694
- 'cd ' + backupHome,
58695
- 'sudo rsync -av --delete /var/www/html/ .'
58696
- ]
58680
+ async function startNgrokService() {
58681
+ const command = [
58682
+ ...getPrivilegeCMD('AadenDeploy/ngrok/ngrok'),
58683
+ 'cd AadenDeploy/ngrok',
58684
+ './ngrok -config=/etc/aaden/ngrok-config.yml start-all'
58685
+ ]
58686
+ cli.executeInShell(command, program.debug)
58687
+ }
58697
58688
 
58698
- cli.executeInShell(command, program.debug)
58699
- if(!noUpload){
58700
- setTimeout(() => {
58701
- const homedir = __nccwpck_require__(12087).homedir()
58702
- const fileName = [homedir, 'backups', timeStamp, `${timeStamp}@cli.sql`].join('/')
58703
- uploadFile(fileName)
58704
- }, 8000)
58705
- }
58689
+ async function backup(noUpload = false) {
58690
+ const timeStamp = dayjs().format(InnerKenTimeStampFormat)
58691
+ const backupHome = 'appendBackup'
58692
+ const command = [
58693
+ 'cd',
58694
+ 'sudo mkdir -p backups',
58695
+ 'sudo chmod 777 backups',
58696
+ 'sudo mkdir -p backups/' + timeStamp,
58697
+ 'sudo chmod 777 backups/' + timeStamp,
58698
+ 'cd backups/' + timeStamp,
58699
+ `mysqldump aaden -uaaden -pInnerken322. -c> ${timeStamp}@cli.sql`,
58700
+ 'cd',
58701
+ 'sudo mkdir -p ' + backupHome,
58702
+ 'sudo chmod 777 ' + backupHome,
58703
+ 'cd ' + backupHome,
58704
+ 'sudo rsync -av --delete /var/www/html/ .'
58705
+ ]
58706
58706
 
58707
+ cli.executeInShell(command, program.debug)
58708
+ if (!noUpload) {
58709
+ setTimeout(() => {
58710
+ const homedir = __nccwpck_require__(12087).homedir()
58711
+ const fileName = [homedir, 'backups', timeStamp, `${timeStamp}@cli.sql`].join('/')
58712
+ uploadFile(fileName)
58713
+ }, 8000)
58714
+ }
58707
58715
 
58708
58716
 
58709
58717
  }
58710
58718
 
58711
- async function updateCheck (channel = '') {
58712
- const result = {
58713
- version: true,
58714
- file: true
58715
- }
58716
- console.log('正在检查是否有必要进行后台更新..'.bgYellow)
58717
- const localVersion = getBackendVersionOffline()
58718
- console.log('本机版本:' + localVersion.bgRed)
58719
- const remoteVersion = (await hillo.get('https://aaden-backend.s3.eu-central-1.amazonaws.com/raw/package.json')).version
58720
- console.log('服务器最新版本:' + remoteVersion.bgMagenta)
58721
- const localStorageVersion = getStorageBackendFileVersion()
58722
- console.log('本地最新文件版本' + localStorageVersion)
58723
- if (remoteVersion === localVersion) {
58724
- console.log('你已经在使用最新版本,无需更新'.red)
58725
- result.file = true
58726
- } else {
58727
- result.version = false
58728
- if (remoteVersion === localStorageVersion) {
58729
- console.log('文件已经就绪,可以直接更新:' + remoteVersion + '------>' + localVersion.bgRed)
58730
-
58731
- } else {
58732
- console.log('缓存文件比较老,需要进行更新:' + remoteVersion + '------>' + localVersion.bgRed)
58733
- result.file = false
58719
+ async function updateCheck(channel = '') {
58720
+ const result = {
58721
+ version: true,
58722
+ file: true
58734
58723
  }
58724
+ console.log('正在检查是否有必要进行后台更新..'.bgYellow)
58725
+ const localVersion = getBackendVersionOffline()
58726
+ console.log('本机版本:' + localVersion.bgRed)
58727
+ const remoteVersion = (await hillo.get('https://aaden-backend.s3.eu-central-1.amazonaws.com/raw/package.json')).version
58728
+ console.log('服务器最新版本:' + remoteVersion.bgMagenta)
58729
+ const localStorageVersion = getStorageBackendFileVersion()
58730
+ console.log('本地最新文件版本' + localStorageVersion)
58731
+ if (remoteVersion === localVersion) {
58732
+ console.log('你已经在使用最新版本,无需更新'.red)
58733
+ result.file = true
58734
+ } else {
58735
+ result.version = false
58736
+ if (remoteVersion === localStorageVersion) {
58737
+ console.log('文件已经就绪,可以直接更新:' + remoteVersion + '------>' + localVersion.bgRed)
58735
58738
 
58736
- }
58737
- return result
58738
- }
58739
+ } else {
58740
+ console.log('缓存文件比较老,需要进行更新:' + remoteVersion + '------>' + localVersion.bgRed)
58741
+ result.file = false
58742
+ }
58739
58743
 
58740
- async function convertDataBaseCharset () {
58741
- try {
58742
- const result = await updateCheck()
58743
- if (result.version) {
58744
- return
58745
58744
  }
58746
- if (!result.file) {
58747
- const command = [
58748
- ...getPrivilegeCMD('AadenDeploy/Utils/updateDataBaseCharSet.sh'),
58749
- 'cd AadenDeploy/Utils',
58750
- `./updateDataBaseCharSet.sh`
58751
- ]
58752
- cli.executeInShell(command, program.debug)
58753
- } else {
58754
- console.log('已经转换完成')
58745
+ return result
58746
+ }
58747
+
58748
+ async function convertDataBaseCharset() {
58749
+ try {
58750
+ const result = await updateCheck()
58751
+ if (result.version) {
58752
+ return
58753
+ }
58754
+ if (!result.file) {
58755
+ const command = [
58756
+ ...getPrivilegeCMD('AadenDeploy/Utils/updateDataBaseCharSet.sh'),
58757
+ 'cd AadenDeploy/Utils',
58758
+ `./updateDataBaseCharSet.sh`
58759
+ ]
58760
+ cli.executeInShell(command, program.debug)
58761
+ } else {
58762
+ console.log('已经转换完成')
58763
+ }
58764
+ } catch (e) {
58765
+ console.error(e)
58755
58766
  }
58756
- } catch (e) {
58757
- console.error(e)
58758
- }
58759
58767
 
58760
58768
  }
58761
58769
 
58762
58770
 
58763
- async function loadNewVersion () {
58764
- try {
58765
- const result = await updateCheck()
58766
- if (result.version) {
58767
- return
58768
- }
58769
- if (!result.file) {
58770
- const command = [
58771
- ...getPrivilegeCMD('AadenDeploy/files/getFile.sh'),
58772
- 'cd AadenDeploy/files',
58773
- `./getFile.sh`
58774
- ]
58775
- cli.executeInShell(command, program.debug)
58776
- } else {
58777
- console.log('后端文件已经是最新')
58771
+ async function loadNewVersion() {
58772
+ try {
58773
+ const result = await updateCheck()
58774
+ if (result.version) {
58775
+ return
58776
+ }
58777
+ if (!result.file) {
58778
+ const command = [
58779
+ ...getPrivilegeCMD('AadenDeploy/files/getFile.sh'),
58780
+ 'cd AadenDeploy/files',
58781
+ `./getFile.sh`
58782
+ ]
58783
+ cli.executeInShell(command, program.debug)
58784
+ } else {
58785
+ console.log('后端文件已经是最新')
58786
+ }
58787
+ } catch (e) {
58788
+ console.error(e)
58778
58789
  }
58779
- } catch (e) {
58780
- console.error(e)
58781
- }
58782
58790
 
58783
58791
  }
58784
58792
 
58785
- async function update (channel = '') {
58786
- if (channel !== '') {
58787
- channel += '/'
58788
- }
58789
- try {
58790
- const result = await updateCheck(channel)
58791
- const command = []
58792
- if (result.version) {
58793
- return
58793
+ async function update(channel = '') {
58794
+ if (channel !== '') {
58795
+ channel += '/'
58794
58796
  }
58795
- if (!result.file) {
58796
- command.push('aaden-cli load-new-version')
58797
+ try {
58798
+ const result = await updateCheck(channel)
58799
+ const command = []
58800
+ if (result.version) {
58801
+ return
58802
+ }
58803
+ if (!result.file) {
58804
+ command.push('aaden-cli load-new-version')
58805
+ }
58806
+ command.push(...[
58807
+ ...getPrivilegeCMD('AadenDeploy/update.sh'),
58808
+ 'cd AadenDeploy',
58809
+ `./update.sh ${channel}`
58810
+ ])
58811
+ cli.executeInShell(command, program.debug)
58812
+ } catch (e) {
58813
+ console.error(e)
58797
58814
  }
58798
- command.push(...[
58799
- ...getPrivilegeCMD('AadenDeploy/update.sh'),
58800
- 'cd AadenDeploy',
58801
- `./update.sh ${channel}`
58802
- ])
58803
- cli.executeInShell(command, program.debug)
58804
- } catch (e) {
58805
- console.error(e)
58806
- }
58807
58815
 
58808
58816
  }
58809
58817
 
58810
- async function install (deviceId) {
58811
- const channel = 'stable'
58812
- const installApp = true
58813
- if (!deviceId || deviceId === 'notset') {
58814
- const getId = await prompts({
58815
- type: 'number',
58816
- name: 'deviceId',
58817
- message: '请输入需要安装的设备号:'
58818
- }
58819
- )
58820
- deviceId = getId.deviceId
58821
- }
58822
- if (deviceId) {
58823
- const command = [
58824
- ...getPrivilegeCMD('AadenDeploy/aadensetup.sh'),
58825
- 'cd AadenDeploy',
58826
- `./aadensetup.sh ${deviceId} ${channel}` + (installApp ? ' b' : '')
58827
- ]
58828
- cli.executeInShell(command, program.debug)
58829
- } else {
58830
- console.log('Device Id is invalid.')
58831
- }
58818
+ async function install(deviceId) {
58819
+ const channel = 'stable'
58820
+ const installApp = true
58821
+ if (!deviceId || deviceId === 'notset') {
58822
+ const getId = await prompts({
58823
+ type: 'number',
58824
+ name: 'deviceId',
58825
+ message: '请输入需要安装的设备号:'
58826
+ }
58827
+ )
58828
+ deviceId = getId.deviceId
58829
+ }
58830
+ if (deviceId) {
58831
+ const command = [
58832
+ ...getPrivilegeCMD('AadenDeploy/aadensetup.sh'),
58833
+ 'cd AadenDeploy',
58834
+ `./aadensetup.sh ${deviceId} ${channel}` + (installApp ? ' b' : '')
58835
+ ]
58836
+ cli.executeInShell(command, program.debug)
58837
+ } else {
58838
+ console.log('Device Id is invalid.')
58839
+ }
58832
58840
  }
58833
58841
 
58834
- function getMyDeviceId () {
58835
- const loadIniFile = __nccwpck_require__(89264)
58836
- try {
58837
- return loadIniFile.sync('/var/www/html/Resource/config/config.ini').Device.DeviceId
58838
- } catch (e) {
58839
- return -1
58840
- }
58842
+ function getMyDeviceId() {
58843
+ const loadIniFile = __nccwpck_require__(89264)
58844
+ try {
58845
+ return loadIniFile.sync('/var/www/html/Resource/config/config.ini').Device.DeviceId
58846
+ } catch (e) {
58847
+ return -1
58848
+ }
58841
58849
 
58842
58850
  }
58843
58851
 
58844
- async function autoUpgrade () {
58845
- upgrade()
58852
+ async function autoUpgrade() {
58853
+ upgrade()
58846
58854
  }
58847
58855
 
58848
- function upgrade () {
58849
- const command = [
58850
- ...getPrivilegeCMD('AadenDeploy/upgrade.sh'),
58851
- 'cd AadenDeploy',
58852
- `./upgrade.sh`
58853
- ]
58854
- cli.executeInShell(command, program.debug)
58856
+ function upgrade() {
58857
+ const command = [
58858
+ ...getPrivilegeCMD('AadenDeploy/upgrade.sh'),
58859
+ 'cd AadenDeploy',
58860
+ `./upgrade.sh`
58861
+ ]
58862
+ cli.executeInShell(command, program.debug)
58855
58863
  }
58856
58864
 
58857
- function getStorageBackendFileVersion () {
58858
- const jsonFilePath = '/etc/aaden/updateFiles/backendFiles/package.json'
58859
- let frontVersion
58860
- try {
58861
- frontVersion = __nccwpck_require__(65578).version
58862
- } catch (e) {
58863
- console.log(e)
58864
- frontVersion = '0.0.0'
58865
- }
58866
- return frontVersion
58865
+ function getStorageBackendFileVersion() {
58866
+ const jsonFilePath = '/etc/aaden/updateFiles/backendFiles/package.json'
58867
+ let frontVersion
58868
+ try {
58869
+ frontVersion = __nccwpck_require__(65578).version
58870
+ } catch (e) {
58871
+ console.log(e)
58872
+ frontVersion = '0.0.0'
58873
+ }
58874
+ return frontVersion
58867
58875
 
58868
58876
  }
58869
58877
 
58870
- function getBackendVersionOffline () {
58871
- const jsonFilePath = '/var/www/html/package.json'
58872
- let frontVersion
58873
- try {
58874
- frontVersion = __nccwpck_require__(63164).version
58875
- } catch (e) {
58876
- frontVersion = '0.0.0'
58877
- }
58878
- return frontVersion
58879
-
58880
- }
58881
-
58882
- async function addDish () {
58883
- console.log('添加菜品需要以下菜品信息:')
58884
- const getDishPath = await prompts({
58885
- type: 'text',
58886
- name: 'dishPath',
58887
- message: '请输入菜品的csv路径:'
58888
- }
58889
- )
58890
- const dishPath = getDishPath.dishPath
58891
- const getImgPath = await prompts({
58892
- type: 'text',
58893
- name: 'imgPath',
58894
- message: '请输入菜品的图片路径:'
58895
- }
58896
- )
58897
- const imgPath = getImgPath.imgPath
58898
- const judge = await prompts({
58899
- type: 'toggle',
58900
- name: 'add',
58901
- message: '是否有需要添加的菜品属性:',
58902
- initial: false,
58903
- active: 'yes',
58904
- inactive: 'no'
58905
- })
58906
- let attrPath = undefined
58907
- if (judge.add) {
58908
- const getAttrPath = await prompts({
58909
- type: 'text',
58910
- name: 'attrPath',
58911
- message: '请输入菜品的属性路径:'
58912
- }
58878
+ function getBackendVersionOffline() {
58879
+ const jsonFilePath = '/var/www/html/package.json'
58880
+ let frontVersion
58881
+ try {
58882
+ frontVersion = __nccwpck_require__(63164).version
58883
+ } catch (e) {
58884
+ frontVersion = '0.0.0'
58885
+ }
58886
+ return frontVersion
58887
+
58888
+ }
58889
+
58890
+ async function addDish() {
58891
+ console.log('添加菜品需要以下菜品信息:')
58892
+ const getDishPath = await prompts({
58893
+ type: 'text',
58894
+ name: 'dishPath',
58895
+ message: '请输入菜品的csv路径:'
58896
+ }
58913
58897
  )
58914
- attrPath = getAttrPath.attrPath
58915
- }
58916
- console.log('Adding dishes now...')
58917
- if (dishPath !== undefined && imgPath !== undefined) {
58918
- if (attrPath !== undefined) {
58919
- const command = [
58920
- ...getPrivilegeCMD('AadenDeploy/add_dish'),
58921
- 'cd AadenDeploy/dish_app',
58922
- `sudo python3 app.py -i ${dishPath} -p ${imgPath} -a ${attrPath}`
58923
- ]
58924
- cli.executeInShell(command, program.debug)
58925
- console.log('Add Dishes with Attribute success!')
58898
+ const dishPath = getDishPath.dishPath
58899
+ const getImgPath = await prompts({
58900
+ type: 'text',
58901
+ name: 'imgPath',
58902
+ message: '请输入菜品的图片路径:'
58903
+ }
58904
+ )
58905
+ const imgPath = getImgPath.imgPath
58906
+ const judge = await prompts({
58907
+ type: 'toggle',
58908
+ name: 'add',
58909
+ message: '是否有需要添加的菜品属性:',
58910
+ initial: false,
58911
+ active: 'yes',
58912
+ inactive: 'no'
58913
+ })
58914
+ let attrPath = undefined
58915
+ if (judge.add) {
58916
+ const getAttrPath = await prompts({
58917
+ type: 'text',
58918
+ name: 'attrPath',
58919
+ message: '请输入菜品的属性路径:'
58920
+ }
58921
+ )
58922
+ attrPath = getAttrPath.attrPath
58923
+ }
58924
+ console.log('Adding dishes now...')
58925
+ if (dishPath !== undefined && imgPath !== undefined) {
58926
+ if (attrPath !== undefined) {
58927
+ const command = [
58928
+ ...getPrivilegeCMD('AadenDeploy/add_dish'),
58929
+ 'cd AadenDeploy/dish_app',
58930
+ `sudo python3 app.py -i ${dishPath} -p ${imgPath} -a ${attrPath}`
58931
+ ]
58932
+ cli.executeInShell(command, program.debug)
58933
+ console.log('Add Dishes with Attribute success!')
58934
+ } else {
58935
+ const command = [
58936
+ ...getPrivilegeCMD('AadenDeploy/add_dish'),
58937
+ 'cd AadenDeploy/dish_app',
58938
+ `sudo python3 app.py -i ${dishPath} -p ${imgPath}`
58939
+ ]
58940
+ cli.executeInShell(command, program.debug)
58941
+ console.log('Add Dishes without Attribute success!')
58942
+ }
58926
58943
  } else {
58927
- const command = [
58928
- ...getPrivilegeCMD('AadenDeploy/add_dish'),
58929
- 'cd AadenDeploy/dish_app',
58930
- `sudo python3 app.py -i ${dishPath} -p ${imgPath}`
58931
- ]
58932
- cli.executeInShell(command, program.debug)
58933
- console.log('Add Dishes without Attribute success!')
58944
+ console.log('DishPath or ImgPath is required but not valid')
58934
58945
  }
58935
- } else {
58936
- console.log('DishPath or ImgPath is required but not valid')
58937
- }
58938
58946
  }
58939
58947
 
58940
- function findMe () {
58941
- return __dirname
58948
+ function findMe() {
58949
+ return __dirname
58942
58950
  }
58943
58951
 
58944
- function goIntoRootDir () {
58945
- return 'cd ' + findMe() + '&& cd ..'
58952
+ function goIntoRootDir() {
58953
+ return 'cd ' + findMe() + '&& cd ..'
58946
58954
  }
58947
58955
 
58948
- async function removeAllData () {
58949
- const start = await prompts({
58950
- type: 'toggle',
58951
- name: 'ok',
58952
- message: `Are your sure you want to remove all data of this customer?
58956
+ async function removeAllData() {
58957
+ const start = await prompts({
58958
+ type: 'toggle',
58959
+ name: 'ok',
58960
+ message: `Are your sure you want to remove all data of this customer?
58953
58961
  你确定你要删除这个用户的所有数据吗?
58954
58962
  このユーザーのすべてのデータを削除してもよろしいですか?
58955
58963
  Möchten Sie wirklich alle Daten dieses Benutzers löschen?
@@ -58958,184 +58966,184 @@ async function removeAllData () {
58958
58966
  Êtes-vous sûr de vouloir supprimer toutes les données de cet utilisateur?
58959
58967
  确定?Are you Sure?
58960
58968
  `,
58961
- initial: false,
58962
- active: 'yes(我确定)',
58963
- inactive: 'no(不,我后悔了)'
58964
- })
58965
- if (!start.ok) {
58966
- return
58967
- }
58968
- console.log('你的行为将会被记录在公司服务器上,请谨慎操作。'.bgRed)
58969
+ initial: false,
58970
+ active: 'yes(我确定)',
58971
+ inactive: 'no(不,我后悔了)'
58972
+ })
58973
+ if (!start.ok) {
58974
+ return
58975
+ }
58976
+ console.log('你的行为将会被记录在公司服务器上,请谨慎操作。'.bgRed)
58969
58977
 
58970
- const response = await prompts({
58971
- type: 'password',
58972
- name: 'value',
58973
- message: '请输入易能科技人员认证密码:'
58974
- })
58975
- const correctPassword = ['yjn.2081214', '728339jhq']
58976
- if (!correctPassword.includes(response.value)) {
58977
- console.log('>密码错误,未认证用户。'.bgYellow)
58978
- return
58979
- }
58980
- console.log('欢迎进入新版AadenCli系统,您的身份已经获得认证'.bgYellow)
58981
- console.log('>现在开始清除用户数据...')
58982
- const command = [
58983
- 'aaden-cli backup',
58984
- goIntoRootDir(),
58985
- 'echo "请输入数据库密码(和开机密码,sudo密码相同)"',
58986
- 'mysql -u aaden -p < AadenDeploy/purge.sql'
58987
- ]
58988
- cli.executeInShell(command, program.debug)
58989
- }
58990
-
58991
- async function enableMilePay () {
58992
- cli.executeInShell([
58993
- 'cd /home/aaden',
58994
- 'mkdir biomace',
58995
- 'cd biomace',
58996
- 'wget https://innerken.com/biomace/biomace.sh',
58997
- 'wget https://innerken.com/biomace/logback-spring-biomace.xml',
58998
- 'wget https://innerken.com/biomace/application.yml',
58999
- 'axel -n 6 https://innerken.com/biomace/biomace-0.0.1-SNAPSHOT.jar',
59000
- 'wget https://innerken.com/biomace/mile-pay-pay-method.sql',
59001
- 'mkdir log',
59002
- 'cd /etc/systemd/system',
59003
- 'sudo wget https://innerken.com/biomace/biomace.service',
59004
- 'aaden-cli start-mile-pay'
59005
- ], program.debug)
59006
- }
59007
-
59008
- async function startService () {
59009
- const deviceId = getMyDeviceId()
59010
- if (deviceId === -1) return
59011
- const filePath = '/home/aaden/biomace/application.yml'
59012
- const res = fs.readFileSync(filePath).toString()
59013
- const out = res.replace('identifier: IK0001', 'identifier: IK' + deviceId)
59014
- fs.writeFileSync(filePath, out)
59015
-
59016
- cli.executeInShell([
59017
- 'sudo systemctl start biomace.service',
59018
- 'sudo systemctl enable biomace.service',
59019
- 'sudo service biomace start',
59020
- 'echo "请输入数据库密码(和开机密码,sudo密码相同)"',
59021
- 'mysql -uaaden -Daaden -p < /home/aaden/biomace/mile-pay-pay-method.sql'
59022
- ], program.debug)
59023
- }
59024
-
59025
- async function milePayOption (options) {
59026
- const operations = {
59027
- accessKey: (accessKey, res) => res.replace(/access-key: +[a-zA-Z0-9]+/g, 'access-key: ' + accessKey),
59028
- accessSecret: (accessSecret, res) => res.replace(/access-secret: +[a-zA-Z0-9]+/g, 'access-secret: ' + accessSecret),
59029
- merchantNo: (merchantNo, res) => res.replace(/merchant-no: +\d+/g, 'merchant-no: ' + merchantNo)
59030
- }
59031
-
59032
- Object.entries(operations).forEach(entry => {
59033
- const [key, value] = entry
59034
- const newValue = options[key]
59035
- if (newValue !== undefined) {
59036
- editMilePaySettings(newValue, value)
59037
- console.log(`${key} 已变更为 ${newValue}`)
58978
+ const response = await prompts({
58979
+ type: 'password',
58980
+ name: 'value',
58981
+ message: '请输入易能科技人员认证密码:'
58982
+ })
58983
+ const correctPassword = ['yjn.2081214', '728339jhq']
58984
+ if (!correctPassword.includes(response.value)) {
58985
+ console.log('>密码错误,未认证用户。'.bgYellow)
58986
+ return
59038
58987
  }
59039
- })
58988
+ console.log('欢迎进入新版AadenCli系统,您的身份已经获得认证'.bgYellow)
58989
+ console.log('>现在开始清除用户数据...')
58990
+ const command = [
58991
+ 'aaden-cli backup',
58992
+ goIntoRootDir(),
58993
+ 'echo "请输入数据库密码(和开机密码,sudo密码相同)"',
58994
+ 'mysql -u aaden -p < AadenDeploy/purge.sql'
58995
+ ]
58996
+ cli.executeInShell(command, program.debug)
59040
58997
  }
59041
58998
 
59042
- function editMilePaySettings (newValue, transform) {
59043
- const filePath = '/home/aaden/biomace/application.yml'
59044
- const res = fs.readFileSync(filePath).toString()
59045
- const out = transform(newValue, res)
59046
- fs.writeFileSync(filePath, out)
58999
+ async function enableMilePay() {
59000
+ cli.executeInShell([
59001
+ 'cd /home/aaden',
59002
+ 'mkdir biomace',
59003
+ 'cd biomace',
59004
+ 'wget https://innerken.com/biomace/biomace.sh',
59005
+ 'wget https://innerken.com/biomace/logback-spring-biomace.xml',
59006
+ 'wget https://innerken.com/biomace/application.yml',
59007
+ 'axel -n 6 https://innerken.com/biomace/biomace-0.0.1-SNAPSHOT.jar',
59008
+ 'wget https://innerken.com/biomace/mile-pay-pay-method.sql',
59009
+ 'mkdir log',
59010
+ 'cd /etc/systemd/system',
59011
+ 'sudo wget https://innerken.com/biomace/biomace.service',
59012
+ 'aaden-cli start-mile-pay'
59013
+ ], program.debug)
59014
+ }
59015
+
59016
+ async function startService() {
59017
+ const deviceId = getMyDeviceId()
59018
+ if (deviceId === -1) return
59019
+ const filePath = '/home/aaden/biomace/application.yml'
59020
+ const res = fs.readFileSync(filePath).toString()
59021
+ const out = res.replace('identifier: IK0001', 'identifier: IK' + deviceId)
59022
+ fs.writeFileSync(filePath, out)
59023
+
59024
+ cli.executeInShell([
59025
+ 'sudo systemctl start biomace.service',
59026
+ 'sudo systemctl enable biomace.service',
59027
+ 'sudo service biomace start',
59028
+ 'echo "请输入数据库密码(和开机密码,sudo密码相同)"',
59029
+ 'mysql -uaaden -Daaden -p < /home/aaden/biomace/mile-pay-pay-method.sql'
59030
+ ], program.debug)
59031
+ }
59032
+
59033
+ async function milePayOption(options) {
59034
+ const operations = {
59035
+ accessKey: (accessKey, res) => res.replace(/access-key: +[a-zA-Z0-9]+/g, 'access-key: ' + accessKey),
59036
+ accessSecret: (accessSecret, res) => res.replace(/access-secret: +[a-zA-Z0-9]+/g, 'access-secret: ' + accessSecret),
59037
+ merchantNo: (merchantNo, res) => res.replace(/merchant-no: +\d+/g, 'merchant-no: ' + merchantNo)
59038
+ }
59039
+
59040
+ Object.entries(operations).forEach(entry => {
59041
+ const [key, value] = entry
59042
+ const newValue = options[key]
59043
+ if (newValue !== undefined) {
59044
+ editMilePaySettings(newValue, value)
59045
+ console.log(`${key} 已变更为 ${newValue}`)
59046
+ }
59047
+ })
59047
59048
  }
59048
59049
 
59049
- async function enableResourceTrack () {
59050
- cli.executeInShell([
59051
- 'cd /home/aaden',
59052
- 'mkdir aaden-resource-track',
59053
- 'cd aaden-resource-track',
59054
- 'axel -n 6 http://ik0001.ngrok.aaden.io/resource-track-0.0.1-jar-with-dependencies.jar',
59055
- 'wget http://ik0001.ngrok.aaden.io/serve-resource-track.sh',
59056
- 'wget http://ik0001.ngrok.aaden.io/start-resource-track.sh',
59057
- 'sudo chmod 777 serve-resource-track.sh',
59058
- 'wget http://ik0001.ngrok.aaden.io/aaden-resource-track.sql',
59059
- 'aaden-cli start-resource-track',
59060
- ],program.debug)
59050
+ function editMilePaySettings(newValue, transform) {
59051
+ const filePath = '/home/aaden/biomace/application.yml'
59052
+ const res = fs.readFileSync(filePath).toString()
59053
+ const out = transform(newValue, res)
59054
+ fs.writeFileSync(filePath, out)
59055
+ }
59056
+
59057
+ async function enableResourceTrack() {
59058
+ cli.executeInShell([
59059
+ 'cd /home/aaden',
59060
+ 'mkdir aaden-resource-track',
59061
+ 'cd aaden-resource-track',
59062
+ 'axel -n 6 http://ik0001.ngrok.aaden.io/resource-track-0.0.1-jar-with-dependencies.jar',
59063
+ 'wget http://ik0001.ngrok.aaden.io/serve-resource-track.sh',
59064
+ 'wget http://ik0001.ngrok.aaden.io/start-resource-track.sh',
59065
+ 'sudo chmod 777 serve-resource-track.sh',
59066
+ 'wget http://ik0001.ngrok.aaden.io/aaden-resource-track.sql',
59067
+ 'aaden-cli start-resource-track',
59068
+ ], program.debug)
59061
59069
  }
59062
59070
 
59063
59071
  async function startResourceTrack() {
59064
- cli.executeInShell([
59065
- 'echo "请输入数据库密码(和开机密码,sudo密码相同)"',
59066
- 'mysql -uaaden -Daaden -p < /home/aaden/aaden-resource-track/aaden-resource-track.sql',
59067
- 'cd /etc/systemd/system',
59068
- 'sudo wget http://ik0001.ngrok.aaden.io/aaden-resource-track.service',
59069
- 'sudo systemctl daemon-reload',
59070
- 'sudo systemctl enable aaden-resource-track.service',
59071
- 'sudo systemctl start aaden-resource-track.service',
59072
- 'sudo service aaden-resource-track start',
59073
- ],program.debug)
59072
+ cli.executeInShell([
59073
+ 'echo "请输入数据库密码(和开机密码,sudo密码相同)"',
59074
+ 'mysql -uaaden -Daaden -p < /home/aaden/aaden-resource-track/aaden-resource-track.sql',
59075
+ 'cd /etc/systemd/system',
59076
+ 'sudo wget http://ik0001.ngrok.aaden.io/aaden-resource-track.service',
59077
+ 'sudo systemctl daemon-reload',
59078
+ 'sudo systemctl enable aaden-resource-track.service',
59079
+ 'sudo systemctl start aaden-resource-track.service',
59080
+ 'sudo service aaden-resource-track start',
59081
+ ], program.debug)
59074
59082
 
59075
59083
  }
59076
59084
 
59077
- function returnTerminal () {
59085
+ function returnTerminal() {
59078
59086
 
59079
59087
  }
59080
59088
 
59081
- function editIni () {
59082
- cli.executeInShell([
59083
- 'sudo chmod 777 /var/www/html/Resource/config/config.ini',
59084
- 'aaden-cli fix-cronjob',
59085
- ], program.debug)
59089
+ function editIni() {
59090
+ cli.executeInShell([
59091
+ 'sudo chmod 777 /var/www/html/Resource/config/config.ini',
59092
+ 'aaden-cli fix-cronjob',
59093
+ ], program.debug)
59086
59094
 
59087
- editConfigIni(composeMany([
59088
- setConfig('Email', 'AutoSend3in1LastMonth', true),
59089
- setConfig('Email', 'DoNotSendZbonWhenPrint', true),
59090
- setConfig('Email', 'AutoSend3in1Today', false),
59091
- ]))()
59095
+ editConfigIni(composeMany([
59096
+ setConfig('Email', 'AutoSend3in1LastMonth', true),
59097
+ setConfig('Email', 'DoNotSendZbonWhenPrint', true),
59098
+ setConfig('Email', 'AutoSend3in1Today', false),
59099
+ ]))()
59092
59100
  }
59093
59101
 
59094
- function autoSendSummaryLastMonth () {
59095
- cli.executeInShell([
59096
- 'sudo chmod 777 /var/www/html/Resource/config/config.ini',
59097
- 'aaden-cli fix-cronjob',
59098
- ], program.debug)
59102
+ function autoSendSummaryLastMonth() {
59103
+ cli.executeInShell([
59104
+ 'sudo chmod 777 /var/www/html/Resource/config/config.ini',
59105
+ 'aaden-cli fix-cronjob',
59106
+ ], program.debug)
59099
59107
 
59100
- editConfigIni(setConfig('Email', 'AutoSendSummaryLastMonth', true))()
59108
+ editConfigIni(setConfig('Email', 'AutoSendSummaryLastMonth', true))()
59101
59109
  }
59102
59110
 
59103
- function editConfigIni (f) {
59104
- return () => {
59105
- const ini = __nccwpck_require__(80045)
59106
- const filePath = '/var/www/html/Resource/config/config.ini'
59107
- const info = ini.parse(fs.readFileSync(filePath, 'utf-8'))
59108
- f(info)
59109
- fs.writeFileSync(filePath, ini.stringify(info))
59110
- }
59111
+ function editConfigIni(f) {
59112
+ return () => {
59113
+ const ini = __nccwpck_require__(80045)
59114
+ const filePath = '/var/www/html/Resource/config/config.ini'
59115
+ const info = ini.parse(fs.readFileSync(filePath, 'utf-8'))
59116
+ f(info)
59117
+ fs.writeFileSync(filePath, ini.stringify(info))
59118
+ }
59111
59119
  }
59112
59120
 
59113
- function setConfig (section, key, value) {
59114
- return file => {
59115
- if (!file[section]) {
59116
- file[section] = {}
59121
+ function setConfig(section, key, value) {
59122
+ return file => {
59123
+ if (!file[section]) {
59124
+ file[section] = {}
59125
+ }
59126
+ file[section][key] = value
59127
+ return file
59117
59128
  }
59118
- file[section][key] = value
59119
- return file
59120
- }
59121
59129
  }
59122
59130
 
59123
- function composeMany (fs) {
59124
- return fs.reduce((f, g) => x => g(f(x)), x => x)
59131
+ function composeMany(fs) {
59132
+ return fs.reduce((f, g) => x => g(f(x)), x => x)
59125
59133
  }
59126
59134
 
59127
- function getPrivilegeCMD (path, pri = '+x', relativePath = true) {
59128
- const command = []
59129
- if (relativePath) {
59130
- command.push(goIntoRootDir())
59131
- }
59132
- command.push(`echo "Innerken322." | sudo -S chmod ${pri} ${path}`)
59133
- return command
59135
+ function getPrivilegeCMD(path, pri = '+x', relativePath = true) {
59136
+ const command = []
59137
+ if (relativePath) {
59138
+ command.push(goIntoRootDir())
59139
+ }
59140
+ command.push(`echo "Innerken322." | sudo -S chmod ${pri} ${path}`)
59141
+ return command
59134
59142
  }
59135
59143
 
59136
- function autoWriteGdpdu () {
59137
- const files = ['AadenDeploy/Utils/writeGdpduService.sh']
59138
- runMultiple(files)
59144
+ function autoWriteGdpdu() {
59145
+ const files = ['AadenDeploy/Utils/writeGdpduService.sh']
59146
+ runMultiple(files)
59139
59147
  }
59140
59148
 
59141
59149
  })();