aaden-cli 1.6.54 → 1.6.55
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 +19 -409
- package/index.js +18 -171
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7174,243 +7174,6 @@ exports.hillo = hillo;
|
|
|
7174
7174
|
var _default = hillo;
|
|
7175
7175
|
exports["default"] = _default;
|
|
7176
7176
|
|
|
7177
|
-
/***/ }),
|
|
7178
|
-
|
|
7179
|
-
/***/ 45:
|
|
7180
|
-
/***/ ((module) => {
|
|
7181
|
-
|
|
7182
|
-
const { hasOwnProperty } = Object.prototype
|
|
7183
|
-
|
|
7184
|
-
/* istanbul ignore next */
|
|
7185
|
-
const eol = typeof process !== 'undefined' &&
|
|
7186
|
-
process.platform === 'win32' ? '\r\n' : '\n'
|
|
7187
|
-
|
|
7188
|
-
const encode = (obj, opt) => {
|
|
7189
|
-
const children = []
|
|
7190
|
-
let out = ''
|
|
7191
|
-
|
|
7192
|
-
if (typeof opt === 'string') {
|
|
7193
|
-
opt = {
|
|
7194
|
-
section: opt,
|
|
7195
|
-
whitespace: false,
|
|
7196
|
-
}
|
|
7197
|
-
} else {
|
|
7198
|
-
opt = opt || Object.create(null)
|
|
7199
|
-
opt.whitespace = opt.whitespace === true
|
|
7200
|
-
}
|
|
7201
|
-
|
|
7202
|
-
const separator = opt.whitespace ? ' = ' : '='
|
|
7203
|
-
|
|
7204
|
-
for (const k of Object.keys(obj)) {
|
|
7205
|
-
const val = obj[k]
|
|
7206
|
-
if (val && Array.isArray(val)) {
|
|
7207
|
-
for (const item of val) {
|
|
7208
|
-
out += safe(k + '[]') + separator + safe(item) + eol
|
|
7209
|
-
}
|
|
7210
|
-
} else if (val && typeof val === 'object') {
|
|
7211
|
-
children.push(k)
|
|
7212
|
-
} else {
|
|
7213
|
-
out += safe(k) + separator + safe(val) + eol
|
|
7214
|
-
}
|
|
7215
|
-
}
|
|
7216
|
-
|
|
7217
|
-
if (opt.section && out.length) {
|
|
7218
|
-
out = '[' + safe(opt.section) + ']' + eol + out
|
|
7219
|
-
}
|
|
7220
|
-
|
|
7221
|
-
for (const k of children) {
|
|
7222
|
-
const nk = dotSplit(k).join('\\.')
|
|
7223
|
-
const section = (opt.section ? opt.section + '.' : '') + nk
|
|
7224
|
-
const { whitespace } = opt
|
|
7225
|
-
const child = encode(obj[k], {
|
|
7226
|
-
section,
|
|
7227
|
-
whitespace,
|
|
7228
|
-
})
|
|
7229
|
-
if (out.length && child.length) {
|
|
7230
|
-
out += eol
|
|
7231
|
-
}
|
|
7232
|
-
|
|
7233
|
-
out += child
|
|
7234
|
-
}
|
|
7235
|
-
|
|
7236
|
-
return out
|
|
7237
|
-
}
|
|
7238
|
-
|
|
7239
|
-
const dotSplit = str =>
|
|
7240
|
-
str.replace(/\1/g, '\u0002LITERAL\\1LITERAL\u0002')
|
|
7241
|
-
.replace(/\\\./g, '\u0001')
|
|
7242
|
-
.split(/\./)
|
|
7243
|
-
.map(part =>
|
|
7244
|
-
part.replace(/\1/g, '\\.')
|
|
7245
|
-
.replace(/\2LITERAL\\1LITERAL\2/g, '\u0001'))
|
|
7246
|
-
|
|
7247
|
-
const decode = str => {
|
|
7248
|
-
const out = Object.create(null)
|
|
7249
|
-
let p = out
|
|
7250
|
-
let section = null
|
|
7251
|
-
// section |key = value
|
|
7252
|
-
const re = /^\[([^\]]*)\]$|^([^=]+)(=(.*))?$/i
|
|
7253
|
-
const lines = str.split(/[\r\n]+/g)
|
|
7254
|
-
|
|
7255
|
-
for (const line of lines) {
|
|
7256
|
-
if (!line || line.match(/^\s*[;#]/)) {
|
|
7257
|
-
continue
|
|
7258
|
-
}
|
|
7259
|
-
const match = line.match(re)
|
|
7260
|
-
if (!match) {
|
|
7261
|
-
continue
|
|
7262
|
-
}
|
|
7263
|
-
if (match[1] !== undefined) {
|
|
7264
|
-
section = unsafe(match[1])
|
|
7265
|
-
if (section === '__proto__') {
|
|
7266
|
-
// not allowed
|
|
7267
|
-
// keep parsing the section, but don't attach it.
|
|
7268
|
-
p = Object.create(null)
|
|
7269
|
-
continue
|
|
7270
|
-
}
|
|
7271
|
-
p = out[section] = out[section] || Object.create(null)
|
|
7272
|
-
continue
|
|
7273
|
-
}
|
|
7274
|
-
const keyRaw = unsafe(match[2])
|
|
7275
|
-
const isArray = keyRaw.length > 2 && keyRaw.slice(-2) === '[]'
|
|
7276
|
-
const key = isArray ? keyRaw.slice(0, -2) : keyRaw
|
|
7277
|
-
if (key === '__proto__') {
|
|
7278
|
-
continue
|
|
7279
|
-
}
|
|
7280
|
-
const valueRaw = match[3] ? unsafe(match[4]) : true
|
|
7281
|
-
const value = valueRaw === 'true' ||
|
|
7282
|
-
valueRaw === 'false' ||
|
|
7283
|
-
valueRaw === 'null' ? JSON.parse(valueRaw)
|
|
7284
|
-
: valueRaw
|
|
7285
|
-
|
|
7286
|
-
// Convert keys with '[]' suffix to an array
|
|
7287
|
-
if (isArray) {
|
|
7288
|
-
if (!hasOwnProperty.call(p, key)) {
|
|
7289
|
-
p[key] = []
|
|
7290
|
-
} else if (!Array.isArray(p[key])) {
|
|
7291
|
-
p[key] = [p[key]]
|
|
7292
|
-
}
|
|
7293
|
-
}
|
|
7294
|
-
|
|
7295
|
-
// safeguard against resetting a previously defined
|
|
7296
|
-
// array by accidentally forgetting the brackets
|
|
7297
|
-
if (Array.isArray(p[key])) {
|
|
7298
|
-
p[key].push(value)
|
|
7299
|
-
} else {
|
|
7300
|
-
p[key] = value
|
|
7301
|
-
}
|
|
7302
|
-
}
|
|
7303
|
-
|
|
7304
|
-
// {a:{y:1},"a.b":{x:2}} --> {a:{y:1,b:{x:2}}}
|
|
7305
|
-
// use a filter to return the keys that have to be deleted.
|
|
7306
|
-
const remove = []
|
|
7307
|
-
for (const k of Object.keys(out)) {
|
|
7308
|
-
if (!hasOwnProperty.call(out, k) ||
|
|
7309
|
-
typeof out[k] !== 'object' ||
|
|
7310
|
-
Array.isArray(out[k])) {
|
|
7311
|
-
continue
|
|
7312
|
-
}
|
|
7313
|
-
|
|
7314
|
-
// see if the parent section is also an object.
|
|
7315
|
-
// if so, add it to that, and mark this one for deletion
|
|
7316
|
-
const parts = dotSplit(k)
|
|
7317
|
-
p = out
|
|
7318
|
-
const l = parts.pop()
|
|
7319
|
-
const nl = l.replace(/\\\./g, '.')
|
|
7320
|
-
for (const part of parts) {
|
|
7321
|
-
if (part === '__proto__') {
|
|
7322
|
-
continue
|
|
7323
|
-
}
|
|
7324
|
-
if (!hasOwnProperty.call(p, part) || typeof p[part] !== 'object') {
|
|
7325
|
-
p[part] = Object.create(null)
|
|
7326
|
-
}
|
|
7327
|
-
p = p[part]
|
|
7328
|
-
}
|
|
7329
|
-
if (p === out && nl === l) {
|
|
7330
|
-
continue
|
|
7331
|
-
}
|
|
7332
|
-
|
|
7333
|
-
p[nl] = out[k]
|
|
7334
|
-
remove.push(k)
|
|
7335
|
-
}
|
|
7336
|
-
for (const del of remove) {
|
|
7337
|
-
delete out[del]
|
|
7338
|
-
}
|
|
7339
|
-
|
|
7340
|
-
return out
|
|
7341
|
-
}
|
|
7342
|
-
|
|
7343
|
-
const isQuoted = val => {
|
|
7344
|
-
return (val.startsWith('"') && val.endsWith('"')) ||
|
|
7345
|
-
(val.startsWith("'") && val.endsWith("'"))
|
|
7346
|
-
}
|
|
7347
|
-
|
|
7348
|
-
const safe = val => {
|
|
7349
|
-
if (
|
|
7350
|
-
typeof val !== 'string' ||
|
|
7351
|
-
val.match(/[=\r\n]/) ||
|
|
7352
|
-
val.match(/^\[/) ||
|
|
7353
|
-
(val.length > 1 && isQuoted(val)) ||
|
|
7354
|
-
val !== val.trim()
|
|
7355
|
-
) {
|
|
7356
|
-
return JSON.stringify(val)
|
|
7357
|
-
}
|
|
7358
|
-
return val.split(';').join('\\;').split('#').join('\\#')
|
|
7359
|
-
}
|
|
7360
|
-
|
|
7361
|
-
const unsafe = (val, doUnesc) => {
|
|
7362
|
-
val = (val || '').trim()
|
|
7363
|
-
if (isQuoted(val)) {
|
|
7364
|
-
// remove the single quotes before calling JSON.parse
|
|
7365
|
-
if (val.charAt(0) === "'") {
|
|
7366
|
-
val = val.slice(1, -1)
|
|
7367
|
-
}
|
|
7368
|
-
try {
|
|
7369
|
-
val = JSON.parse(val)
|
|
7370
|
-
} catch {
|
|
7371
|
-
// ignore errors
|
|
7372
|
-
}
|
|
7373
|
-
} else {
|
|
7374
|
-
// walk the val to find the first not-escaped ; character
|
|
7375
|
-
let esc = false
|
|
7376
|
-
let unesc = ''
|
|
7377
|
-
for (let i = 0, l = val.length; i < l; i++) {
|
|
7378
|
-
const c = val.charAt(i)
|
|
7379
|
-
if (esc) {
|
|
7380
|
-
if ('\\;#'.indexOf(c) !== -1) {
|
|
7381
|
-
unesc += c
|
|
7382
|
-
} else {
|
|
7383
|
-
unesc += '\\' + c
|
|
7384
|
-
}
|
|
7385
|
-
|
|
7386
|
-
esc = false
|
|
7387
|
-
} else if (';#'.indexOf(c) !== -1) {
|
|
7388
|
-
break
|
|
7389
|
-
} else if (c === '\\') {
|
|
7390
|
-
esc = true
|
|
7391
|
-
} else {
|
|
7392
|
-
unesc += c
|
|
7393
|
-
}
|
|
7394
|
-
}
|
|
7395
|
-
if (esc) {
|
|
7396
|
-
unesc += '\\'
|
|
7397
|
-
}
|
|
7398
|
-
|
|
7399
|
-
return unesc.trim()
|
|
7400
|
-
}
|
|
7401
|
-
return val
|
|
7402
|
-
}
|
|
7403
|
-
|
|
7404
|
-
module.exports = {
|
|
7405
|
-
parse: decode,
|
|
7406
|
-
decode,
|
|
7407
|
-
stringify: encode,
|
|
7408
|
-
encode,
|
|
7409
|
-
safe,
|
|
7410
|
-
unsafe,
|
|
7411
|
-
}
|
|
7412
|
-
|
|
7413
|
-
|
|
7414
7177
|
/***/ }),
|
|
7415
7178
|
|
|
7416
7179
|
/***/ 741:
|
|
@@ -18686,7 +18449,7 @@ module.exports = JSON.parse('{"name":"axios","version":"0.19.2","description":"P
|
|
|
18686
18449
|
/***/ ((module) => {
|
|
18687
18450
|
|
|
18688
18451
|
"use strict";
|
|
18689
|
-
module.exports = {"i8":"1.6.
|
|
18452
|
+
module.exports = {"i8":"1.6.55"};
|
|
18690
18453
|
|
|
18691
18454
|
/***/ })
|
|
18692
18455
|
|
|
@@ -18798,9 +18561,6 @@ program.command('mount-tse').action(remountTSE)
|
|
|
18798
18561
|
program.command('upgrade').action(upgrade) // auto execute.
|
|
18799
18562
|
program.command('auto-upgrade').action(autoUpgrade) // auto execute.
|
|
18800
18563
|
program.command('load-new-version').action(loadNewVersion) // auto execute.
|
|
18801
|
-
program.command('local-version').action(() => {
|
|
18802
|
-
console.log('storage:' + getStorageBackendFileVersion())
|
|
18803
|
-
})
|
|
18804
18564
|
program.command('backup').action(backup)
|
|
18805
18565
|
program.command('ngrok').action(startNgrokService)
|
|
18806
18566
|
program.command('update-ngrok-config <deviceId>').action(updateNgrokConfig)
|
|
@@ -18809,32 +18569,20 @@ program.command('patch').action(patch)
|
|
|
18809
18569
|
program.command('check-tse').action(checkTse)
|
|
18810
18570
|
program.command('setup-tse').action(enableTSE)
|
|
18811
18571
|
program.command('check-version').action(getBackendVersionOffline)
|
|
18812
|
-
program.command('add-dish').action(addDish)
|
|
18813
18572
|
program.command('full-update').action(fullUpdate)
|
|
18814
|
-
|
|
18573
|
+
|
|
18815
18574
|
program.command('db').action(enterDatabase)
|
|
18816
18575
|
program.command('printer-test').action(testPrinter)
|
|
18817
|
-
program.command('log').action(log)
|
|
18576
|
+
program.command('fail-log').action(log)
|
|
18818
18577
|
program.command('fix-cronjob').action(fixCronJob)
|
|
18819
18578
|
program.command('convert-database').action(convertDataBaseCharset)
|
|
18820
18579
|
program.command('migrate').action(migrate)
|
|
18821
18580
|
|
|
18822
|
-
program.command('enable-resource-track').action(enableResourceTrack)
|
|
18823
|
-
program.command('start-resource-track').action(startResourceTrack)
|
|
18824
|
-
program.command('auto-send-mail').action(editIni)
|
|
18825
|
-
program.command('auto-send-summary').action(autoSendSummaryLastMonth)
|
|
18826
|
-
program.command('set-do-not-send-zbon-when-print-true').action(editConfigIni(setConfig('Email', 'DoNotSendZbonWhenPrint', true)))
|
|
18827
|
-
program.command('set-do-not-send-zbon-when-print-false').action(editConfigIni(setConfig('Email', 'DoNotSendZbonWhenPrint', false)))
|
|
18828
|
-
program.command('set-auto-send-3in1-today-true').action(editConfigIni(setConfig('Email', 'AutoSend3in1Today', true)))
|
|
18829
|
-
program.command('set-auto-send-3in1-today-false').action(editConfigIni(setConfig('Email', 'AutoSend3in1Today', false)))
|
|
18830
|
-
program.command('set-print-change-table-bon-true').action(editConfigIni(setConfig('Bon', 'PrintChangeTableBon', true)))
|
|
18831
|
-
program.command('set-print-change-table-bon-false').action(editConfigIni(setConfig('Bon', 'PrintChangeTableBon', false)))
|
|
18832
|
-
program.command('send-single-bon-without-zip-true').action(editConfigIni(setConfig('Email', 'SendSingleBonWithoutZip', true)))
|
|
18833
|
-
program.command('send-single-bon-without-zip-false').action(editConfigIni(setConfig('Email', 'SendSingleBonWithoutZip', false)))
|
|
18834
18581
|
program.command('auto-write-gdpdu').action(autoWriteGdpdu)
|
|
18835
18582
|
program.command('export-tse').action(exportTse)
|
|
18836
18583
|
program.command('fix-ngrok').action(fixNgrok)
|
|
18837
18584
|
program.command('do-log').action(doLog)
|
|
18585
|
+
program.command('clean-backup-space').action(doCompress)
|
|
18838
18586
|
|
|
18839
18587
|
if (program.debug) {
|
|
18840
18588
|
debugInfo()
|
|
@@ -18926,21 +18674,6 @@ function testPrinter() {
|
|
|
18926
18674
|
cli.executeInShell(command, program.debug)
|
|
18927
18675
|
}
|
|
18928
18676
|
|
|
18929
|
-
function getDatabase() {
|
|
18930
|
-
const command = [
|
|
18931
|
-
`mysqldump -uaaden -pInnerken322. --databases aaden --tables Attribute AttributeGroup BonTemplate Category_AttributeGroup DishWithName Dish_AttributeGroup Dishes DishesString DishesCategory DishesCategoryString> transfer.sql`,
|
|
18932
|
-
'sudo cp transfer.sql /var/www/html'
|
|
18933
|
-
]
|
|
18934
|
-
cli.executeInShell(command, program.debug)
|
|
18935
|
-
}
|
|
18936
|
-
|
|
18937
|
-
function getNewDatabase() {
|
|
18938
|
-
const command = [
|
|
18939
|
-
`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`,
|
|
18940
|
-
'sudo cp transfer.sql /var/www/html'
|
|
18941
|
-
]
|
|
18942
|
-
cli.executeInShell(command, program.debug)
|
|
18943
|
-
}
|
|
18944
18677
|
|
|
18945
18678
|
function debugInfo() {
|
|
18946
18679
|
console.log(program.opts())
|
|
@@ -18991,7 +18724,7 @@ async function patch() {
|
|
|
18991
18724
|
})
|
|
18992
18725
|
|
|
18993
18726
|
if (runList.length > 0) {
|
|
18994
|
-
runMultiple(runList)
|
|
18727
|
+
await runMultiple(runList)
|
|
18995
18728
|
readyList = readyList.concat(runList)
|
|
18996
18729
|
fs.writeFileSync(patchRecordFilePath, JSON.stringify(readyList))
|
|
18997
18730
|
}
|
|
@@ -19077,6 +18810,16 @@ async function startNgrokService() {
|
|
|
19077
18810
|
cli.executeInShell(command, program.debug)
|
|
19078
18811
|
}
|
|
19079
18812
|
|
|
18813
|
+
async function doCompress() {
|
|
18814
|
+
const command = [
|
|
18815
|
+
'aaden-cli backup',
|
|
18816
|
+
'cd',
|
|
18817
|
+
'sudo rm -rf backups'
|
|
18818
|
+
]
|
|
18819
|
+
cli.executeInShell(command, program.debug)
|
|
18820
|
+
|
|
18821
|
+
}
|
|
18822
|
+
|
|
19080
18823
|
async function backup() {
|
|
19081
18824
|
const timeStamp = dayjs().format(InnerKenTimeStampFormat)
|
|
19082
18825
|
const backupHome = 'appendBackup'
|
|
@@ -19091,6 +18834,7 @@ async function backup() {
|
|
|
19091
18834
|
`mysqldump aaden -uaaden -pInnerken322. -c> ${sqlName}`,
|
|
19092
18835
|
'zip -m -r backup.zip ' + sqlName,
|
|
19093
18836
|
'cd',
|
|
18837
|
+
'sudo cp -rf backups/' + timeStamp + '/backup.zip /var/www/html/latest.zip',
|
|
19094
18838
|
'sudo mkdir -p ' + backupHome,
|
|
19095
18839
|
'sudo chmod 777 ' + backupHome,
|
|
19096
18840
|
'cd ' + backupHome,
|
|
@@ -19101,7 +18845,7 @@ async function backup() {
|
|
|
19101
18845
|
|
|
19102
18846
|
}
|
|
19103
18847
|
|
|
19104
|
-
async function updateCheck(
|
|
18848
|
+
async function updateCheck() {
|
|
19105
18849
|
const result = {
|
|
19106
18850
|
version: true,
|
|
19107
18851
|
file: true
|
|
@@ -19135,7 +18879,8 @@ async function migrate() {
|
|
|
19135
18879
|
|
|
19136
18880
|
const command = [
|
|
19137
18881
|
'cd /var/www/html/PHP',
|
|
19138
|
-
'vendor/bin/phinx migrate'
|
|
18882
|
+
'vendor/bin/phinx migrate',
|
|
18883
|
+
'cd'
|
|
19139
18884
|
]
|
|
19140
18885
|
cli.executeInShell(command, program.debug)
|
|
19141
18886
|
|
|
@@ -19307,64 +19052,6 @@ function getBackendVersionOffline() {
|
|
|
19307
19052
|
|
|
19308
19053
|
}
|
|
19309
19054
|
|
|
19310
|
-
async function addDish() {
|
|
19311
|
-
console.log('添加菜品需要以下菜品信息:')
|
|
19312
|
-
const getDishPath = await prompts({
|
|
19313
|
-
type: 'text',
|
|
19314
|
-
name: 'dishPath',
|
|
19315
|
-
message: '请输入菜品的csv路径:'
|
|
19316
|
-
}
|
|
19317
|
-
)
|
|
19318
|
-
const dishPath = getDishPath.dishPath
|
|
19319
|
-
const getImgPath = await prompts({
|
|
19320
|
-
type: 'text',
|
|
19321
|
-
name: 'imgPath',
|
|
19322
|
-
message: '请输入菜品的图片路径:'
|
|
19323
|
-
}
|
|
19324
|
-
)
|
|
19325
|
-
const imgPath = getImgPath.imgPath
|
|
19326
|
-
const judge = await prompts({
|
|
19327
|
-
type: 'toggle',
|
|
19328
|
-
name: 'add',
|
|
19329
|
-
message: '是否有需要添加的菜品属性:',
|
|
19330
|
-
initial: false,
|
|
19331
|
-
active: 'yes',
|
|
19332
|
-
inactive: 'no'
|
|
19333
|
-
})
|
|
19334
|
-
let attrPath = undefined
|
|
19335
|
-
if (judge.add) {
|
|
19336
|
-
const getAttrPath = await prompts({
|
|
19337
|
-
type: 'text',
|
|
19338
|
-
name: 'attrPath',
|
|
19339
|
-
message: '请输入菜品的属性路径:'
|
|
19340
|
-
}
|
|
19341
|
-
)
|
|
19342
|
-
attrPath = getAttrPath.attrPath
|
|
19343
|
-
}
|
|
19344
|
-
console.log('Adding dishes now...')
|
|
19345
|
-
if (dishPath !== undefined && imgPath !== undefined) {
|
|
19346
|
-
if (attrPath !== undefined) {
|
|
19347
|
-
const command = [
|
|
19348
|
-
...getPrivilegeCMD('AadenDeploy/add_dish'),
|
|
19349
|
-
'cd AadenDeploy/dish_app',
|
|
19350
|
-
`sudo python3 app.py -i ${dishPath} -p ${imgPath} -a ${attrPath}`
|
|
19351
|
-
]
|
|
19352
|
-
cli.executeInShell(command, program.debug)
|
|
19353
|
-
console.log('Add Dishes with Attribute success!')
|
|
19354
|
-
} else {
|
|
19355
|
-
const command = [
|
|
19356
|
-
...getPrivilegeCMD('AadenDeploy/add_dish'),
|
|
19357
|
-
'cd AadenDeploy/dish_app',
|
|
19358
|
-
`sudo python3 app.py -i ${dishPath} -p ${imgPath}`
|
|
19359
|
-
]
|
|
19360
|
-
cli.executeInShell(command, program.debug)
|
|
19361
|
-
console.log('Add Dishes without Attribute success!')
|
|
19362
|
-
}
|
|
19363
|
-
} else {
|
|
19364
|
-
console.log('DishPath or ImgPath is required but not valid')
|
|
19365
|
-
}
|
|
19366
|
-
}
|
|
19367
|
-
|
|
19368
19055
|
function findMe() {
|
|
19369
19056
|
return __dirname
|
|
19370
19057
|
}
|
|
@@ -19433,83 +19120,6 @@ async function doLog() {
|
|
|
19433
19120
|
process.exit(0)
|
|
19434
19121
|
}
|
|
19435
19122
|
|
|
19436
|
-
async function enableResourceTrack() {
|
|
19437
|
-
cli.executeInShell([
|
|
19438
|
-
'cd /home/aaden',
|
|
19439
|
-
'mkdir aaden-resource-track',
|
|
19440
|
-
'cd aaden-resource-track',
|
|
19441
|
-
'axel -n 6 http://ik0001.ngrok.aaden.io/resource-track-0.0.1-jar-with-dependencies.jar',
|
|
19442
|
-
'wget http://ik0001.ngrok.aaden.io/serve-resource-track.sh',
|
|
19443
|
-
'wget http://ik0001.ngrok.aaden.io/start-resource-track.sh',
|
|
19444
|
-
'sudo chmod 777 serve-resource-track.sh',
|
|
19445
|
-
'wget http://ik0001.ngrok.aaden.io/aaden-resource-track.sql',
|
|
19446
|
-
'aaden-cli start-resource-track',
|
|
19447
|
-
], program.debug)
|
|
19448
|
-
}
|
|
19449
|
-
|
|
19450
|
-
async function startResourceTrack() {
|
|
19451
|
-
cli.executeInShell([
|
|
19452
|
-
'echo "请输入数据库密码(和开机密码,sudo密码相同)"',
|
|
19453
|
-
'mysql -uaaden -Daaden -p < /home/aaden/aaden-resource-track/aaden-resource-track.sql',
|
|
19454
|
-
'cd /etc/systemd/system',
|
|
19455
|
-
'sudo wget http://ik0001.ngrok.aaden.io/aaden-resource-track.service',
|
|
19456
|
-
'sudo systemctl daemon-reload',
|
|
19457
|
-
'sudo systemctl enable aaden-resource-track.service',
|
|
19458
|
-
'sudo systemctl start aaden-resource-track.service',
|
|
19459
|
-
'sudo service aaden-resource-track start',
|
|
19460
|
-
], program.debug)
|
|
19461
|
-
|
|
19462
|
-
}
|
|
19463
|
-
|
|
19464
|
-
function returnTerminal() {
|
|
19465
|
-
|
|
19466
|
-
}
|
|
19467
|
-
|
|
19468
|
-
function editIni() {
|
|
19469
|
-
cli.executeInShell([
|
|
19470
|
-
'sudo chmod 777 /var/www/html/Resource/config/config.ini',
|
|
19471
|
-
'aaden-cli fix-cronjob',
|
|
19472
|
-
], program.debug)
|
|
19473
|
-
|
|
19474
|
-
editConfigIni(composeMany([
|
|
19475
|
-
setConfig('Email', 'AutoSend3in1LastMonth', true),
|
|
19476
|
-
setConfig('Email', 'DoNotSendZbonWhenPrint', true),
|
|
19477
|
-
setConfig('Email', 'AutoSend3in1Today', false),
|
|
19478
|
-
]))()
|
|
19479
|
-
}
|
|
19480
|
-
|
|
19481
|
-
function autoSendSummaryLastMonth() {
|
|
19482
|
-
cli.executeInShell([
|
|
19483
|
-
'sudo chmod 777 /var/www/html/Resource/config/config.ini',
|
|
19484
|
-
'aaden-cli fix-cronjob',
|
|
19485
|
-
], program.debug)
|
|
19486
|
-
|
|
19487
|
-
editConfigIni(setConfig('Email', 'AutoSendSummaryLastMonth', true))()
|
|
19488
|
-
}
|
|
19489
|
-
|
|
19490
|
-
function editConfigIni(f) {
|
|
19491
|
-
return () => {
|
|
19492
|
-
const ini = __nccwpck_require__(45)
|
|
19493
|
-
const filePath = '/var/www/html/Resource/config/config.ini'
|
|
19494
|
-
const info = ini.parse(fs.readFileSync(filePath, 'utf-8'))
|
|
19495
|
-
f(info)
|
|
19496
|
-
fs.writeFileSync(filePath, ini.stringify(info))
|
|
19497
|
-
}
|
|
19498
|
-
}
|
|
19499
|
-
|
|
19500
|
-
function setConfig(section, key, value) {
|
|
19501
|
-
return file => {
|
|
19502
|
-
if (!file[section]) {
|
|
19503
|
-
file[section] = {}
|
|
19504
|
-
}
|
|
19505
|
-
file[section][key] = value
|
|
19506
|
-
return file
|
|
19507
|
-
}
|
|
19508
|
-
}
|
|
19509
|
-
|
|
19510
|
-
function composeMany(fs) {
|
|
19511
|
-
return fs.reduce((f, g) => x => g(f(x)), x => x)
|
|
19512
|
-
}
|
|
19513
19123
|
|
|
19514
19124
|
function getPrivilegeCMD(path, pri = '+x', relativePath = true) {
|
|
19515
19125
|
const command = []
|
package/index.js
CHANGED
|
@@ -38,9 +38,6 @@ program.command('mount-tse').action(remountTSE)
|
|
|
38
38
|
program.command('upgrade').action(upgrade) // auto execute.
|
|
39
39
|
program.command('auto-upgrade').action(autoUpgrade) // auto execute.
|
|
40
40
|
program.command('load-new-version').action(loadNewVersion) // auto execute.
|
|
41
|
-
program.command('local-version').action(() => {
|
|
42
|
-
console.log('storage:' + getStorageBackendFileVersion())
|
|
43
|
-
})
|
|
44
41
|
program.command('backup').action(backup)
|
|
45
42
|
program.command('ngrok').action(startNgrokService)
|
|
46
43
|
program.command('update-ngrok-config <deviceId>').action(updateNgrokConfig)
|
|
@@ -49,32 +46,20 @@ program.command('patch').action(patch)
|
|
|
49
46
|
program.command('check-tse').action(checkTse)
|
|
50
47
|
program.command('setup-tse').action(enableTSE)
|
|
51
48
|
program.command('check-version').action(getBackendVersionOffline)
|
|
52
|
-
program.command('add-dish').action(addDish)
|
|
53
49
|
program.command('full-update').action(fullUpdate)
|
|
54
|
-
|
|
50
|
+
|
|
55
51
|
program.command('db').action(enterDatabase)
|
|
56
52
|
program.command('printer-test').action(testPrinter)
|
|
57
|
-
program.command('log').action(log)
|
|
53
|
+
program.command('fail-log').action(log)
|
|
58
54
|
program.command('fix-cronjob').action(fixCronJob)
|
|
59
55
|
program.command('convert-database').action(convertDataBaseCharset)
|
|
60
56
|
program.command('migrate').action(migrate)
|
|
61
57
|
|
|
62
|
-
program.command('enable-resource-track').action(enableResourceTrack)
|
|
63
|
-
program.command('start-resource-track').action(startResourceTrack)
|
|
64
|
-
program.command('auto-send-mail').action(editIni)
|
|
65
|
-
program.command('auto-send-summary').action(autoSendSummaryLastMonth)
|
|
66
|
-
program.command('set-do-not-send-zbon-when-print-true').action(editConfigIni(setConfig('Email', 'DoNotSendZbonWhenPrint', true)))
|
|
67
|
-
program.command('set-do-not-send-zbon-when-print-false').action(editConfigIni(setConfig('Email', 'DoNotSendZbonWhenPrint', false)))
|
|
68
|
-
program.command('set-auto-send-3in1-today-true').action(editConfigIni(setConfig('Email', 'AutoSend3in1Today', true)))
|
|
69
|
-
program.command('set-auto-send-3in1-today-false').action(editConfigIni(setConfig('Email', 'AutoSend3in1Today', false)))
|
|
70
|
-
program.command('set-print-change-table-bon-true').action(editConfigIni(setConfig('Bon', 'PrintChangeTableBon', true)))
|
|
71
|
-
program.command('set-print-change-table-bon-false').action(editConfigIni(setConfig('Bon', 'PrintChangeTableBon', false)))
|
|
72
|
-
program.command('send-single-bon-without-zip-true').action(editConfigIni(setConfig('Email', 'SendSingleBonWithoutZip', true)))
|
|
73
|
-
program.command('send-single-bon-without-zip-false').action(editConfigIni(setConfig('Email', 'SendSingleBonWithoutZip', false)))
|
|
74
58
|
program.command('auto-write-gdpdu').action(autoWriteGdpdu)
|
|
75
59
|
program.command('export-tse').action(exportTse)
|
|
76
60
|
program.command('fix-ngrok').action(fixNgrok)
|
|
77
61
|
program.command('do-log').action(doLog)
|
|
62
|
+
program.command('clean-backup-space').action(doCompress)
|
|
78
63
|
|
|
79
64
|
if (program.debug) {
|
|
80
65
|
debugInfo()
|
|
@@ -166,21 +151,6 @@ function testPrinter() {
|
|
|
166
151
|
cli.executeInShell(command, program.debug)
|
|
167
152
|
}
|
|
168
153
|
|
|
169
|
-
function getDatabase() {
|
|
170
|
-
const command = [
|
|
171
|
-
`mysqldump -uaaden -pInnerken322. --databases aaden --tables Attribute AttributeGroup BonTemplate Category_AttributeGroup DishWithName Dish_AttributeGroup Dishes DishesString DishesCategory DishesCategoryString> transfer.sql`,
|
|
172
|
-
'sudo cp transfer.sql /var/www/html'
|
|
173
|
-
]
|
|
174
|
-
cli.executeInShell(command, program.debug)
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
function getNewDatabase() {
|
|
178
|
-
const command = [
|
|
179
|
-
`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`,
|
|
180
|
-
'sudo cp transfer.sql /var/www/html'
|
|
181
|
-
]
|
|
182
|
-
cli.executeInShell(command, program.debug)
|
|
183
|
-
}
|
|
184
154
|
|
|
185
155
|
function debugInfo() {
|
|
186
156
|
console.log(program.opts())
|
|
@@ -231,7 +201,7 @@ async function patch() {
|
|
|
231
201
|
})
|
|
232
202
|
|
|
233
203
|
if (runList.length > 0) {
|
|
234
|
-
runMultiple(runList)
|
|
204
|
+
await runMultiple(runList)
|
|
235
205
|
readyList = readyList.concat(runList)
|
|
236
206
|
fs.writeFileSync(patchRecordFilePath, JSON.stringify(readyList))
|
|
237
207
|
}
|
|
@@ -317,6 +287,16 @@ async function startNgrokService() {
|
|
|
317
287
|
cli.executeInShell(command, program.debug)
|
|
318
288
|
}
|
|
319
289
|
|
|
290
|
+
async function doCompress() {
|
|
291
|
+
const command = [
|
|
292
|
+
'aaden-cli backup',
|
|
293
|
+
'cd',
|
|
294
|
+
'sudo rm -rf backups'
|
|
295
|
+
]
|
|
296
|
+
cli.executeInShell(command, program.debug)
|
|
297
|
+
|
|
298
|
+
}
|
|
299
|
+
|
|
320
300
|
async function backup() {
|
|
321
301
|
const timeStamp = dayjs().format(InnerKenTimeStampFormat)
|
|
322
302
|
const backupHome = 'appendBackup'
|
|
@@ -331,6 +311,7 @@ async function backup() {
|
|
|
331
311
|
`mysqldump aaden -uaaden -pInnerken322. -c> ${sqlName}`,
|
|
332
312
|
'zip -m -r backup.zip ' + sqlName,
|
|
333
313
|
'cd',
|
|
314
|
+
'sudo cp -rf backups/' + timeStamp + '/backup.zip /var/www/html/latest.zip',
|
|
334
315
|
'sudo mkdir -p ' + backupHome,
|
|
335
316
|
'sudo chmod 777 ' + backupHome,
|
|
336
317
|
'cd ' + backupHome,
|
|
@@ -341,7 +322,7 @@ async function backup() {
|
|
|
341
322
|
|
|
342
323
|
}
|
|
343
324
|
|
|
344
|
-
async function updateCheck(
|
|
325
|
+
async function updateCheck() {
|
|
345
326
|
const result = {
|
|
346
327
|
version: true,
|
|
347
328
|
file: true
|
|
@@ -375,7 +356,8 @@ async function migrate() {
|
|
|
375
356
|
|
|
376
357
|
const command = [
|
|
377
358
|
'cd /var/www/html/PHP',
|
|
378
|
-
'vendor/bin/phinx migrate'
|
|
359
|
+
'vendor/bin/phinx migrate',
|
|
360
|
+
'cd'
|
|
379
361
|
]
|
|
380
362
|
cli.executeInShell(command, program.debug)
|
|
381
363
|
|
|
@@ -547,64 +529,6 @@ function getBackendVersionOffline() {
|
|
|
547
529
|
|
|
548
530
|
}
|
|
549
531
|
|
|
550
|
-
async function addDish() {
|
|
551
|
-
console.log('添加菜品需要以下菜品信息:')
|
|
552
|
-
const getDishPath = await prompts({
|
|
553
|
-
type: 'text',
|
|
554
|
-
name: 'dishPath',
|
|
555
|
-
message: '请输入菜品的csv路径:'
|
|
556
|
-
}
|
|
557
|
-
)
|
|
558
|
-
const dishPath = getDishPath.dishPath
|
|
559
|
-
const getImgPath = await prompts({
|
|
560
|
-
type: 'text',
|
|
561
|
-
name: 'imgPath',
|
|
562
|
-
message: '请输入菜品的图片路径:'
|
|
563
|
-
}
|
|
564
|
-
)
|
|
565
|
-
const imgPath = getImgPath.imgPath
|
|
566
|
-
const judge = await prompts({
|
|
567
|
-
type: 'toggle',
|
|
568
|
-
name: 'add',
|
|
569
|
-
message: '是否有需要添加的菜品属性:',
|
|
570
|
-
initial: false,
|
|
571
|
-
active: 'yes',
|
|
572
|
-
inactive: 'no'
|
|
573
|
-
})
|
|
574
|
-
let attrPath = undefined
|
|
575
|
-
if (judge.add) {
|
|
576
|
-
const getAttrPath = await prompts({
|
|
577
|
-
type: 'text',
|
|
578
|
-
name: 'attrPath',
|
|
579
|
-
message: '请输入菜品的属性路径:'
|
|
580
|
-
}
|
|
581
|
-
)
|
|
582
|
-
attrPath = getAttrPath.attrPath
|
|
583
|
-
}
|
|
584
|
-
console.log('Adding dishes now...')
|
|
585
|
-
if (dishPath !== undefined && imgPath !== undefined) {
|
|
586
|
-
if (attrPath !== undefined) {
|
|
587
|
-
const command = [
|
|
588
|
-
...getPrivilegeCMD('AadenDeploy/add_dish'),
|
|
589
|
-
'cd AadenDeploy/dish_app',
|
|
590
|
-
`sudo python3 app.py -i ${dishPath} -p ${imgPath} -a ${attrPath}`
|
|
591
|
-
]
|
|
592
|
-
cli.executeInShell(command, program.debug)
|
|
593
|
-
console.log('Add Dishes with Attribute success!')
|
|
594
|
-
} else {
|
|
595
|
-
const command = [
|
|
596
|
-
...getPrivilegeCMD('AadenDeploy/add_dish'),
|
|
597
|
-
'cd AadenDeploy/dish_app',
|
|
598
|
-
`sudo python3 app.py -i ${dishPath} -p ${imgPath}`
|
|
599
|
-
]
|
|
600
|
-
cli.executeInShell(command, program.debug)
|
|
601
|
-
console.log('Add Dishes without Attribute success!')
|
|
602
|
-
}
|
|
603
|
-
} else {
|
|
604
|
-
console.log('DishPath or ImgPath is required but not valid')
|
|
605
|
-
}
|
|
606
|
-
}
|
|
607
|
-
|
|
608
532
|
function findMe() {
|
|
609
533
|
return __dirname
|
|
610
534
|
}
|
|
@@ -673,83 +597,6 @@ async function doLog() {
|
|
|
673
597
|
process.exit(0)
|
|
674
598
|
}
|
|
675
599
|
|
|
676
|
-
async function enableResourceTrack() {
|
|
677
|
-
cli.executeInShell([
|
|
678
|
-
'cd /home/aaden',
|
|
679
|
-
'mkdir aaden-resource-track',
|
|
680
|
-
'cd aaden-resource-track',
|
|
681
|
-
'axel -n 6 http://ik0001.ngrok.aaden.io/resource-track-0.0.1-jar-with-dependencies.jar',
|
|
682
|
-
'wget http://ik0001.ngrok.aaden.io/serve-resource-track.sh',
|
|
683
|
-
'wget http://ik0001.ngrok.aaden.io/start-resource-track.sh',
|
|
684
|
-
'sudo chmod 777 serve-resource-track.sh',
|
|
685
|
-
'wget http://ik0001.ngrok.aaden.io/aaden-resource-track.sql',
|
|
686
|
-
'aaden-cli start-resource-track',
|
|
687
|
-
], program.debug)
|
|
688
|
-
}
|
|
689
|
-
|
|
690
|
-
async function startResourceTrack() {
|
|
691
|
-
cli.executeInShell([
|
|
692
|
-
'echo "请输入数据库密码(和开机密码,sudo密码相同)"',
|
|
693
|
-
'mysql -uaaden -Daaden -p < /home/aaden/aaden-resource-track/aaden-resource-track.sql',
|
|
694
|
-
'cd /etc/systemd/system',
|
|
695
|
-
'sudo wget http://ik0001.ngrok.aaden.io/aaden-resource-track.service',
|
|
696
|
-
'sudo systemctl daemon-reload',
|
|
697
|
-
'sudo systemctl enable aaden-resource-track.service',
|
|
698
|
-
'sudo systemctl start aaden-resource-track.service',
|
|
699
|
-
'sudo service aaden-resource-track start',
|
|
700
|
-
], program.debug)
|
|
701
|
-
|
|
702
|
-
}
|
|
703
|
-
|
|
704
|
-
function returnTerminal() {
|
|
705
|
-
|
|
706
|
-
}
|
|
707
|
-
|
|
708
|
-
function editIni() {
|
|
709
|
-
cli.executeInShell([
|
|
710
|
-
'sudo chmod 777 /var/www/html/Resource/config/config.ini',
|
|
711
|
-
'aaden-cli fix-cronjob',
|
|
712
|
-
], program.debug)
|
|
713
|
-
|
|
714
|
-
editConfigIni(composeMany([
|
|
715
|
-
setConfig('Email', 'AutoSend3in1LastMonth', true),
|
|
716
|
-
setConfig('Email', 'DoNotSendZbonWhenPrint', true),
|
|
717
|
-
setConfig('Email', 'AutoSend3in1Today', false),
|
|
718
|
-
]))()
|
|
719
|
-
}
|
|
720
|
-
|
|
721
|
-
function autoSendSummaryLastMonth() {
|
|
722
|
-
cli.executeInShell([
|
|
723
|
-
'sudo chmod 777 /var/www/html/Resource/config/config.ini',
|
|
724
|
-
'aaden-cli fix-cronjob',
|
|
725
|
-
], program.debug)
|
|
726
|
-
|
|
727
|
-
editConfigIni(setConfig('Email', 'AutoSendSummaryLastMonth', true))()
|
|
728
|
-
}
|
|
729
|
-
|
|
730
|
-
function editConfigIni(f) {
|
|
731
|
-
return () => {
|
|
732
|
-
const ini = require('ini')
|
|
733
|
-
const filePath = '/var/www/html/Resource/config/config.ini'
|
|
734
|
-
const info = ini.parse(fs.readFileSync(filePath, 'utf-8'))
|
|
735
|
-
f(info)
|
|
736
|
-
fs.writeFileSync(filePath, ini.stringify(info))
|
|
737
|
-
}
|
|
738
|
-
}
|
|
739
|
-
|
|
740
|
-
function setConfig(section, key, value) {
|
|
741
|
-
return file => {
|
|
742
|
-
if (!file[section]) {
|
|
743
|
-
file[section] = {}
|
|
744
|
-
}
|
|
745
|
-
file[section][key] = value
|
|
746
|
-
return file
|
|
747
|
-
}
|
|
748
|
-
}
|
|
749
|
-
|
|
750
|
-
function composeMany(fs) {
|
|
751
|
-
return fs.reduce((f, g) => x => g(f(x)), x => x)
|
|
752
|
-
}
|
|
753
600
|
|
|
754
601
|
function getPrivilegeCMD(path, pri = '+x', relativePath = true) {
|
|
755
602
|
const command = []
|