aaden-cli 1.1.120 → 1.1.121

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
@@ -57462,7 +57462,7 @@ module.exports = JSON.parse('{"name":"axios","version":"0.19.2","description":"P
57462
57462
  /***/ ((module) => {
57463
57463
 
57464
57464
  "use strict";
57465
- module.exports = {"i8":"1.1.119"};
57465
+ module.exports = {"i8":"1.1.120"};
57466
57466
 
57467
57467
  /***/ }),
57468
57468
 
@@ -57719,7 +57719,7 @@ program.command('load-new-version').action(loadNewVersion) // auto execute.
57719
57719
  program.command('local-version').action(() => {
57720
57720
  console.log('storage:' + getStorageBackendFileVersion())
57721
57721
  })
57722
- program.command('backup [full]').action(backup)
57722
+ program.command('backup [upload]').action(backup)
57723
57723
  program.command('ngrok').action(startNgrokService)
57724
57724
  program.command('update-ngrok-config <deviceId>').action(updateNgrokConfig)
57725
57725
  program.command('get-database').action(getDatabase)
@@ -57949,7 +57949,7 @@ async function startNgrokService () {
57949
57949
  cli.executeInShell(command, program.debug)
57950
57950
  }
57951
57951
 
57952
- async function backup (full = true) {
57952
+ async function backup (upload = false) {
57953
57953
  const timeStamp = dayjs().format(InnerKenTimeStampFormat)
57954
57954
  const backupHome = 'appendBackup'
57955
57955
  const command = [
@@ -57959,7 +57959,7 @@ async function backup (full = true) {
57959
57959
  'sudo mkdir -p backups/' + timeStamp,
57960
57960
  'sudo chmod 777 backups/' + timeStamp,
57961
57961
  'cd backups/' + timeStamp,
57962
- `mysqldump aaden -uaaden -pInnerken322. ${full ? '-c' : '-c -t'} > ${timeStamp}@cli.sql`,
57962
+ `mysqldump aaden -uaaden -pInnerken322. -c> ${timeStamp}@cli.sql`,
57963
57963
  'cd',
57964
57964
  'sudo mkdir -p ' + backupHome,
57965
57965
  'sudo chmod 777 ' + backupHome,
@@ -57968,11 +57968,14 @@ async function backup (full = true) {
57968
57968
  ]
57969
57969
 
57970
57970
  cli.executeInShell(command, program.debug)
57971
- setTimeout(() => {
57972
- const homedir = __nccwpck_require__(12087).homedir()
57973
- const fileName = [homedir, 'backups', timeStamp, `${timeStamp}@cli.sql`].join('/')
57974
- uploadFile(fileName)
57975
- }, 8000)
57971
+ if(upload){
57972
+ setTimeout(() => {
57973
+ const homedir = __nccwpck_require__(12087).homedir()
57974
+ const fileName = [homedir, 'backups', timeStamp, `${timeStamp}@cli.sql`].join('/')
57975
+ uploadFile(fileName)
57976
+ }, 8000)
57977
+ }
57978
+
57976
57979
 
57977
57980
 
57978
57981
  }
@@ -0,0 +1,21 @@
1
+ const fs = require('fs')
2
+ const sql = fs.readFileSync('sql/1.sql')
3
+
4
+
5
+ const queries = sql.toString().split(';')
6
+ const res = []
7
+ queries.forEach(q => {
8
+ // console.log(q)
9
+ const lines = q.split('\n')
10
+ // console.log(lines)
11
+ const tableName = lines.find(l => l.includes('INTO'))
12
+ if (tableName) {
13
+ const realTableName = tableName.split('`')[1]
14
+ const ids = lines.filter(l => l.includes('(')).map(l => l.split('(')[1].split(',')[0])
15
+ const query = 'Delete from ' + realTableName + ' where id in (' + ids.join(',') + ');'
16
+ // console.log(query)
17
+ res.push(query)
18
+ }
19
+
20
+ })
21
+ fs.writeFileSync('sql/clean.sql', res.join('\n'))
package/index.js CHANGED
@@ -37,7 +37,7 @@ program.command('load-new-version').action(loadNewVersion) // auto execute.
37
37
  program.command('local-version').action(() => {
38
38
  console.log('storage:' + getStorageBackendFileVersion())
39
39
  })
40
- program.command('backup [full]').action(backup)
40
+ program.command('backup [upload]').action(backup)
41
41
  program.command('ngrok').action(startNgrokService)
42
42
  program.command('update-ngrok-config <deviceId>').action(updateNgrokConfig)
43
43
  program.command('get-database').action(getDatabase)
@@ -267,7 +267,7 @@ async function startNgrokService () {
267
267
  cli.executeInShell(command, program.debug)
268
268
  }
269
269
 
270
- async function backup (full = true) {
270
+ async function backup (upload = false) {
271
271
  const timeStamp = dayjs().format(InnerKenTimeStampFormat)
272
272
  const backupHome = 'appendBackup'
273
273
  const command = [
@@ -277,7 +277,7 @@ async function backup (full = true) {
277
277
  'sudo mkdir -p backups/' + timeStamp,
278
278
  'sudo chmod 777 backups/' + timeStamp,
279
279
  'cd backups/' + timeStamp,
280
- `mysqldump aaden -uaaden -pInnerken322. ${full ? '-c' : '-c -t'} > ${timeStamp}@cli.sql`,
280
+ `mysqldump aaden -uaaden -pInnerken322. -c> ${timeStamp}@cli.sql`,
281
281
  'cd',
282
282
  'sudo mkdir -p ' + backupHome,
283
283
  'sudo chmod 777 ' + backupHome,
@@ -286,11 +286,14 @@ async function backup (full = true) {
286
286
  ]
287
287
 
288
288
  cli.executeInShell(command, program.debug)
289
- setTimeout(() => {
290
- const homedir = require('os').homedir()
291
- const fileName = [homedir, 'backups', timeStamp, `${timeStamp}@cli.sql`].join('/')
292
- uploadFile(fileName)
293
- }, 8000)
289
+ if(upload){
290
+ setTimeout(() => {
291
+ const homedir = require('os').homedir()
292
+ const fileName = [homedir, 'backups', timeStamp, `${timeStamp}@cli.sql`].join('/')
293
+ uploadFile(fileName)
294
+ }, 8000)
295
+ }
296
+
294
297
 
295
298
 
296
299
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aaden-cli",
3
- "version": "1.1.120",
3
+ "version": "1.1.121",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {