@cyklang/cli 0.5.3 → 0.5.5

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.
@@ -7,7 +7,7 @@ import path from "path"
7
7
  import mime from 'mime-types'
8
8
  import inquirer from 'inquirer'
9
9
  // import readline from 'readline'
10
- import { DBAsset, DBExecuteRequest, DBManager, ObjectData, parseXML, PrimitiveData } from "@cyklang/core"
10
+ import { DBAsset, DBExecuteRequest, DBManager, DBRemote, ObjectData, parseXML, PrimitiveData } from "@cyklang/core"
11
11
  import FormData from 'form-data'
12
12
 
13
13
  const logger = getLogger('AssetCommand.ts')
@@ -112,7 +112,7 @@ class AssetDelete extends Cmd {
112
112
 
113
113
  try {
114
114
  await this.prologue(options)
115
- if (! this.dbManager) throw 'dbManager undefined'
115
+ if (!this.dbManager) throw 'dbManager undefined'
116
116
  const dbClient = new DBClient(this.dbManager)
117
117
  const list = await dbClient.selectFromTable('Assets to delete', 'cyk_asset',
118
118
  {
@@ -121,9 +121,9 @@ class AssetDelete extends Cmd {
121
121
  }
122
122
 
123
123
  );
124
- const reply = await inquirer.prompt({type: 'confirm', name: 'confirm', message: 'Do you want to delete these ' + list.length + ' file(s)'})
124
+ const reply = await inquirer.prompt({ type: 'confirm', name: 'confirm', message: 'Do you want to delete these ' + list.length + ' file(s)' })
125
125
  if (reply.confirm) {
126
- for(let ind = 0; ind < list.length; ind++) {
126
+ for (let ind = 0; ind < list.length; ind++) {
127
127
  const asset = list[ind]
128
128
  logger.info('delete ' + asset.asset_route)
129
129
  const url = '/api/admin/assets/' + asset.asset_id
@@ -168,7 +168,7 @@ class AssetList extends Cmd {
168
168
  }
169
169
  }
170
170
 
171
- interface FileDescriptor {
171
+ export interface FileDescriptor {
172
172
  path: string
173
173
  mtime: Date
174
174
  id?: number
@@ -193,16 +193,7 @@ class AssetU extends Cmd {
193
193
  })
194
194
  }
195
195
 
196
- mimetypeLookup(filename: string): string | false {
197
- let result: string | false
198
- if (path.extname(filename) === '.cyk') {
199
- result = 'application/xml'
200
- }
201
- else {
202
- result = mime.lookup(filename)
203
- }
204
- return result
205
- }
196
+
206
197
 
207
198
  /**
208
199
  * method commandU
@@ -271,7 +262,7 @@ class AssetU extends Cmd {
271
262
  if (dest.substring(dest.length - 1) !== '/') dest = dest + '/'
272
263
 
273
264
  if (options.clean) {
274
- await this.cleanDestination(dest)
265
+ await cleanDestination(dest, this.dbManager, this.dbRemote)
275
266
  }
276
267
 
277
268
  for (let ind = 0; ind < sources.length; ind++) {
@@ -279,12 +270,12 @@ class AssetU extends Cmd {
279
270
  if (fs.existsSync(source) === false) throw 'source ' + source + ' does not exist'
280
271
  const filestat = fs.lstatSync(source)
281
272
  if (filestat.isDirectory() === true) {
282
- await this.uploadDirectory(source, dest, options)
273
+ await uploadDirectory(source, dest, options, this.dbManager, this.dbRemote)
283
274
  }
284
275
  else if (filestat.isFile() === true) {
285
276
  const base = path.parse(source).base
286
277
  logger.debug('upload file ' + source + ' to ' + dest + base)
287
- await this.uploadAsset({ path: source, mtime: filestat.mtime }, dest + base, options.auth)
278
+ await uploadAsset({ path: source, mtime: filestat.mtime }, dest + base, this.dbManager, this.dbRemote, options.auth)
288
279
  }
289
280
  }
290
281
  }
@@ -292,212 +283,236 @@ class AssetU extends Cmd {
292
283
  logger.error(err)
293
284
  }
294
285
  }
286
+ }
295
287
 
296
- //----------------------------------------------------------------------------------------------
297
- // cleanDestination
298
- //----------------------------------------------------------------------------------------------
299
-
300
- async cleanDestination(dest: string) {
301
-
302
- const remoteList = await scanAssets(this.dbManager)
303
- for (let ind = 0; ind < remoteList.length; ind++) {
304
- const fd = remoteList[ind]
305
- if (fd.path.startsWith(dest)) {
306
- const url = '/api/admin/assets/' + fd.id
307
- await this.dbRemote?.apiServer.delete(url)
308
- }
288
+ /**
289
+ * function cleanDestination
290
+ * @param dest
291
+ * @param dbManager
292
+ * @param dbRemote
293
+ */
294
+ async function cleanDestination(dest: string, dbManager: DBManager | undefined, dbRemote: DBRemote | undefined) {
295
+
296
+ const remoteList = await scanAssets(dbManager)
297
+ for (let ind = 0; ind < remoteList.length; ind++) {
298
+ const fd = remoteList[ind]
299
+ if (fd.path.startsWith(dest)) {
300
+ const url = '/api/admin/assets/' + fd.id
301
+ await dbRemote?.apiServer.delete(url)
309
302
  }
310
303
  }
304
+ }
305
+ /**
306
+ * function uploadDirectory
307
+ * @param source
308
+ * @param dest
309
+ * @param options {yes: no confirmation, auth: basic/token/cookie/undefined}
310
+ * @param dbManager
311
+ * @param dbRemote
312
+ */
313
+ export async function uploadDirectory(source: string, dest: string, options: any,
314
+ dbManager: DBManager | undefined, dbRemote: DBRemote | undefined) {
315
+
316
+ const localList: FileDescriptor[] = []
317
+ let dirName: string
318
+ if (source.substring(source.length - 1) === '/') {
319
+ // trailing directory separator
320
+ dirName = source
321
+ }
322
+ else {
323
+ dirName = source + '/'
324
+ }
311
325
 
312
- //----------------------------------------------------------------------------------------------
313
- // uploadDirectory
314
- //----------------------------------------------------------------------------------------------
315
-
316
- async uploadDirectory(source: string, dest: string, options: any) {
317
-
318
- const localList: FileDescriptor[] = []
319
- let dirName: string
320
- if (source.substring(source.length - 1) === '/') {
321
- // trailing directory separator
322
- dirName = source
323
- }
324
- else {
325
- dirName = source + '/'
326
- }
327
-
328
- // logger.debug('options', options)
329
-
330
- this.scanDir(dirName, localList)
331
-
332
- const remoteList = await scanAssets(this.dbManager)
333
-
334
- const uploadList = this.buildUploadList(dirName, dest, localList, remoteList)
326
+ // logger.debug('options', options)
335
327
 
336
- // logger.info(fileNames.join('\n'))
337
- if (uploadList.length === 0) throw 'None file to upload'
328
+ scanDir(dirName, localList)
338
329
 
339
- let uploadConfirmed = (options.yes !== undefined)
330
+ const remoteList = await scanAssets(dbManager)
340
331
 
341
- if (uploadConfirmed === false) {
342
- const reply = await inquirer.prompt({ type: 'confirm', name: 'confirm', message: 'Do you want to upload this(these) ' + uploadList.length + ' file(s) ?' })
343
- if (reply.confirm === true) uploadConfirmed = true
344
- }
332
+ const uploadList = buildUploadList(dirName, dest, localList, remoteList)
345
333
 
346
- if (uploadConfirmed === true) {
347
- await this.uploadFiles(dirName, uploadList, dest, options.auth)
348
- }
334
+ // logger.info(fileNames.join('\n'))
335
+ if (uploadList.length === 0) throw 'None file to upload'
349
336
 
350
- // const rl = readline.createInterface(process.stdin, process.stdout)
351
- // rl.question('Do you want to upload this(these) ' + uploadList.length + ' file(s) (Y/N/y/n) ?', async (reply) => {
352
- // rl.close()
353
- // if (reply !== 'Y' && reply !== 'y') {
354
- // logger.info('upload cancelled')
355
- // return
356
- // }
337
+ let uploadConfirmed = (options.yes !== undefined)
357
338
 
358
- // await this.uploadFiles(dirName, uploadList, dest)
359
- // })
339
+ if (uploadConfirmed === false) {
340
+ const reply = await inquirer.prompt({ type: 'confirm', name: 'confirm', message: 'Do you want to upload this(these) ' + uploadList.length + ' file(s) ?' })
341
+ if (reply.confirm === true) uploadConfirmed = true
360
342
  }
361
343
 
362
- //----------------------------------------------------------------------------------------------
363
- // buildUploadList
364
- //----------------------------------------------------------------------------------------------
365
-
366
- buildUploadList(dirName: string, dest: string, localList: FileDescriptor[], remoteList: FileDescriptor[]): FileDescriptor[] {
367
- const result: FileDescriptor[] = []
368
- const remoteMap = new Map<string, FileDescriptor>()
369
- for (let ind = 0; ind < remoteList.length; ind++) {
370
- const remote = remoteList[ind]
371
- remoteMap.set(remote.path, remote)
372
- }
373
- for (let ind = 0; ind < localList.length; ind++) {
374
- const localDesc = localList[ind]
375
- const route = dest + localDesc.path.substring(dirName.length)
376
- const remoteDesc = remoteMap.get(route)
377
-
378
- if (remoteDesc === undefined || remoteDesc.mtime.getTime() + 1000 < localDesc.mtime.getTime()) {
379
- if (remoteDesc === undefined) logger.debug('remoteDesc undefined')
380
- else logger.debug('remoteDesc.mtime ' + remoteDesc.mtime.getTime(), 'localDesc.mtime ' + localDesc.mtime.getTime())
381
- logger.info(localDesc.path)
382
- result.push(localDesc)
383
- }
344
+ if (uploadConfirmed === true) {
345
+ await uploadFiles(dirName, uploadList, dest, dbManager, dbRemote, options.auth)
346
+ }
347
+ }
348
+ /**
349
+ * function buildUploadList
350
+ * @param dirName
351
+ * @param dest
352
+ * @param localList
353
+ * @param remoteList
354
+ * @returns
355
+ */
356
+ function buildUploadList(dirName: string, dest: string, localList: FileDescriptor[], remoteList: FileDescriptor[]): FileDescriptor[] {
357
+ const result: FileDescriptor[] = []
358
+ const remoteMap = new Map<string, FileDescriptor>()
359
+ for (let ind = 0; ind < remoteList.length; ind++) {
360
+ const remote = remoteList[ind]
361
+ remoteMap.set(remote.path, remote)
362
+ }
363
+ for (let ind = 0; ind < localList.length; ind++) {
364
+ const localDesc = localList[ind]
365
+ const route = dest + localDesc.path.substring(dirName.length)
366
+ const remoteDesc = remoteMap.get(route)
367
+
368
+ if (remoteDesc === undefined || remoteDesc.mtime.getTime() + 1000 < localDesc.mtime.getTime()) {
369
+ if (remoteDesc === undefined) logger.debug('remoteDesc undefined')
370
+ else logger.debug('remoteDesc.mtime ' + remoteDesc.mtime.getTime(), 'localDesc.mtime ' + localDesc.mtime.getTime())
371
+ logger.info(localDesc.path)
372
+ result.push(localDesc)
384
373
  }
385
- return result
386
374
  }
387
-
388
- //----------------------------------------------------------------------------------------------
389
- // scanDir
390
- //----------------------------------------------------------------------------------------------
391
-
392
- scanDir(dirName: string, result: FileDescriptor[]) {
393
- const files = fs.readdirSync(dirName)
394
- for (let ind = 0; ind < files.length; ind++) {
395
- const fileName = files[ind]
396
- if (this.file2exclude(fileName) === true) continue
397
- const fstat = fs.statSync(dirName + fileName)
398
- if (fstat.isDirectory() === true) {
399
- this.scanDir(dirName + fileName + '/', result)
400
- }
401
- else {
402
- if (this.mimetypeLookup(fileName) === false) {
403
- logger.info(fileName + ' file extension is unknown and will not be uploaded')
404
- continue
405
- }
406
- //const dbAssetExist = this.dbManager?.dbAssetExist()
407
- result.push({ path: dirName + fileName, mtime: fstat.mtime })
408
- // logger.debug(dirName + '/' + fileName)
375
+ return result
376
+ }
377
+ /**
378
+ * function scanDir
379
+ * @param dirName
380
+ * @param result
381
+ */
382
+ function scanDir(dirName: string, result: FileDescriptor[]) {
383
+ const files = fs.readdirSync(dirName)
384
+ for (let ind = 0; ind < files.length; ind++) {
385
+ const fileName = files[ind]
386
+ if (file2exclude(fileName) === true) continue
387
+ const fstat = fs.statSync(dirName + fileName)
388
+ if (fstat.isDirectory() === true) {
389
+ scanDir(dirName + fileName + '/', result)
390
+ }
391
+ else {
392
+ if (mimetypeLookup(fileName) === false) {
393
+ logger.info(fileName + ' file extension is unknown and will not be uploaded')
394
+ continue
409
395
  }
396
+ //const dbAssetExist = this.dbManager?.dbAssetExist()
397
+ result.push({ path: dirName + fileName, mtime: fstat.mtime })
398
+ // logger.debug(dirName + '/' + fileName)
410
399
  }
411
400
  }
401
+ }
412
402
 
413
- //----------------------------------------------------------------------------------------------
414
- // file2exclude
415
- //----------------------------------------------------------------------------------------------
416
-
417
- ignorePatterns = ['.git', 'node_modules']
418
-
419
- file2exclude(fileName: string): boolean {
420
- let result = false
421
- this.ignorePatterns.forEach((pattern) => {
422
- if (fileName === pattern) result = true
423
- })
424
- return result
403
+ const ignorePatterns = ['.git', 'node_modules']
404
+ /**
405
+ * function file2exclude
406
+ * @param fileName
407
+ * @returns
408
+ */
409
+ function file2exclude(fileName: string): boolean {
410
+ let result = false
411
+ ignorePatterns.forEach((pattern) => {
412
+ if (fileName === pattern) result = true
413
+ })
414
+ return result
415
+ }
416
+ /**
417
+ * function uploadFiles
418
+ * @param dirName
419
+ * @param uploadList
420
+ * @param dest
421
+ * @param dbManager
422
+ * @param dbRemote
423
+ * @param auth
424
+ */
425
+ async function uploadFiles(dirName: string, uploadList: FileDescriptor[], dest: string, dbManager: DBManager | undefined, dbRemote: DBRemote | undefined, auth: string | undefined) {
426
+ for (let ind = 0; ind < uploadList.length; ind++) {
427
+ const upload = uploadList[ind]
428
+ const route = dest + upload.path.substring(dirName.length)
429
+ logger.debug('upload ' + upload.path + ' to ' + route)
430
+ await uploadAsset(upload, route, dbManager, dbRemote, auth)
425
431
  }
432
+ }
426
433
 
427
- //----------------------------------------------------------------------------------------------
428
- // uploadFiles
429
- //----------------------------------------------------------------------------------------------
434
+ /**
435
+ * function uploadAsset
436
+ * @param upload
437
+ * @param route
438
+ * @param dbManager
439
+ * @param dbRemote
440
+ * @param auth
441
+ */
442
+ export async function uploadAsset(upload: FileDescriptor, route: string, dbManager: DBManager | undefined, dbRemote: DBRemote | undefined, auth?: string) {
443
+ // logger.debug('uploadAsset ' + upload.path + ' to route ' + route + ' with mimetype ' + this.mimetypeLookup(upload.path) + ', auth : ' + auth)
430
444
 
431
- async uploadFiles(dirName: string, uploadList: FileDescriptor[], dest: string, auth: string | undefined) {
432
- for (let ind = 0; ind < uploadList.length; ind++) {
433
- const upload = uploadList[ind]
434
- const route = dest + upload.path.substring(dirName.length)
435
- logger.debug('upload ' + upload.path + ' to ' + route)
436
- await this.uploadAsset(upload, route, auth)
445
+ try {
446
+ let dbAsset: DBAsset | undefined = await dbManager?.dbAssetExist(route)
447
+ if (dbAsset === undefined) {
448
+ dbAsset = new DBAsset()
437
449
  }
438
- }
439
-
440
- //----------------------------------------------------------------------------------------------
441
- // uploadAsset
442
- //----------------------------------------------------------------------------------------------
443
-
444
- async uploadAsset(upload: FileDescriptor, route: string, auth?: string) {
445
- // logger.debug('uploadAsset ' + upload.path + ' to route ' + route + ' with mimetype ' + this.mimetypeLookup(upload.path) + ', auth : ' + auth)
446
-
447
- try {
448
- let dbAsset: DBAsset | undefined = await this.dbManager?.dbAssetExist(route)
449
- if (dbAsset === undefined) {
450
- dbAsset = new DBAsset()
451
- }
452
- const mimetype = this.mimetypeLookup(upload.path)
453
- if (mimetype === false) throw 'mimetype false for ' + upload
454
- dbAsset.mimetype = mimetype
455
- dbAsset.route = route
456
- dbAsset.auth = auth
457
- if (dbAsset.auth === 'none') dbAsset.auth = undefined
458
-
459
- // const fstat = fs.statSync(fileName)
460
- dbAsset.last_update = upload.mtime
461
-
462
- // const contentBuffer = fs.readFileSync(fileName)
463
- // dbAsset.content = contentBuffer
464
- // logger.debug('dbAsset.content length ' + dbAsset.content.length)
465
-
466
- if (dbAsset.id === undefined) {
467
- dbAsset.id = await this.dbManager?.dbAssetInsert(dbAsset)
468
- logger.info('inserted asset ' + dbAsset.id + ' route ' + dbAsset.route)
469
- }
470
- else {
471
- await this.dbManager?.dbAssetUpdate(dbAsset)
472
- logger.info('updated asset ' + dbAsset.route)
473
- }
474
-
475
- await this.uploadAssetContent(dbAsset, upload.path)
450
+ const mimetype = mimetypeLookup(upload.path)
451
+ if (mimetype === false) throw 'mimetype false for ' + upload
452
+ dbAsset.mimetype = mimetype
453
+ dbAsset.route = route
454
+ dbAsset.auth = auth
455
+ if (dbAsset.auth === 'none') dbAsset.auth = undefined
456
+
457
+ // const fstat = fs.statSync(fileName)
458
+ dbAsset.last_update = upload.mtime
459
+
460
+ // const contentBuffer = fs.readFileSync(fileName)
461
+ // dbAsset.content = contentBuffer
462
+ // logger.debug('dbAsset.content length ' + dbAsset.content.length)
463
+
464
+ if (dbAsset.id === undefined) {
465
+ dbAsset.id = await dbManager?.dbAssetInsert(dbAsset)
466
+ logger.info('inserted asset ' + dbAsset.id + ' route ' + dbAsset.route)
476
467
  }
477
- catch (err) {
478
- logger.error(err)
468
+ else {
469
+ await dbManager?.dbAssetUpdate(dbAsset)
470
+ logger.info('updated asset ' + dbAsset.route)
479
471
  }
472
+
473
+ await uploadAssetContent(dbAsset, upload.path, dbRemote)
474
+ }
475
+ catch (err) {
476
+ logger.error(err)
480
477
  }
478
+ }
481
479
 
482
- //----------------------------------------------------------------------------------------------
483
- // uploadAssetContent
484
- //----------------------------------------------------------------------------------------------
480
+ /**
481
+ * function mimetypeLookup
482
+ * @param filename
483
+ * @returns
484
+ */
485
+ function mimetypeLookup(filename: string): string | false {
486
+ let result: string | false
487
+ if (path.extname(filename) === '.cyk') {
488
+ result = 'application/xml'
489
+ }
490
+ else {
491
+ result = mime.lookup(filename)
492
+ }
493
+ return result
494
+ }
485
495
 
486
- async uploadAssetContent(dbAsset: DBAsset, fileName: string) {
487
- logger.debug('uploadAssetContent file ' + fileName + ' to path ' + path)
488
- try {
489
- const file = fs.createReadStream(fileName)
490
- const form = new FormData()
491
- form.append('uploadFile', file)
492
-
493
- const route = '/api/upload/cyk_asset/asset_content?asset_id=' + dbAsset.id
494
- const resp = await this.dbRemote?.apiServer.post(route, form)
495
- if (resp.status === 200) {
496
- logger.info(fileName + ' uploaded')
497
- }
498
- }
499
- catch (err) {
500
- logger.error(err)
496
+ /**
497
+ * function uploadAssetContent
498
+ * @param dbAsset
499
+ * @param fileName
500
+ * @param dbRemote
501
+ */
502
+ async function uploadAssetContent(dbAsset: DBAsset, fileName: string, dbRemote: DBRemote | undefined) {
503
+ logger.debug('uploadAssetContent file ' + fileName + ' to path ' + path)
504
+ try {
505
+ const file = fs.createReadStream(fileName)
506
+ const form = new FormData()
507
+ form.append('uploadFile', file)
508
+
509
+ const route = '/api/upload/cyk_asset/asset_content?asset_id=' + dbAsset.id
510
+ const resp = await dbRemote?.apiServer.post(route, form)
511
+ if (resp.status === 200) {
512
+ logger.info(fileName + ' uploaded')
501
513
  }
502
514
  }
515
+ catch (err) {
516
+ logger.error(err)
517
+ }
503
518
  }
package/src/Cmd.ts CHANGED
@@ -5,7 +5,8 @@ import loglevel from 'loglevel'
5
5
  import { NodeCrypto } from "./NodeCrypto";
6
6
  import { DBClient } from "./DBClient";
7
7
  import { exec, spawn } from 'child_process';
8
- import {red, green, bold} from 'kolorist'
8
+ import { red, green, bold } from 'kolorist'
9
+ import * as fs from 'fs'
9
10
 
10
11
  const logger = loglevel.getLogger('Cmd.ts')
11
12
  logger.setLevel('debug')
@@ -115,44 +116,64 @@ export class Cmd extends Command {
115
116
  });
116
117
  }
117
118
 
118
- /**
119
- * method runShellCommand
120
- * @param command
121
- */
122
- async runShellCommand(command: string, args: string[]) {
123
- try {
124
- await this.spawnCommand(command, args)
125
- // console.log(command)
126
- // const result = await this.executeCommand(command);
127
- // console.log(result.stdout);
128
- // if (result.stderr && result.stderr.trim() !== '')
129
- // console.error(result.stderr);
130
- } catch (error) {
131
- console.error('Error running "' + command + '":', error);
132
- throw error
133
- }
134
- }
135
119
 
136
- /**
137
- *
138
- * @param command
139
- * @param args
140
- * @returns
141
- */
142
- spawnCommand(command: string, args: string[]): Promise<void> {
143
- console.log()
144
- console.log([command, ...args, '...'].join(' '))
145
- const child_process = spawn(command, args, { stdio: 'inherit' })
146
- return new Promise((resolve, reject) => {
147
- child_process.on('close', (code) => {
148
- if (code === 0) {
149
- console.log(green('*') + ' ' + [command, ...args].join(' '))
150
- resolve()
151
- }
152
- else {
153
- reject(new Error([command, ...args].join(' ') + ' --> Error ' + code))
154
- }
155
- })
120
+
121
+ }
122
+
123
+
124
+ /**
125
+ * method runShellCommand
126
+ * @param command
127
+ */
128
+ export async function runShellCommand(command: string, args: string[]) {
129
+ try {
130
+ await spawnCommand(command, args)
131
+ // console.log(command)
132
+ // const result = await this.executeCommand(command);
133
+ // console.log(result.stdout);
134
+ // if (result.stderr && result.stderr.trim() !== '')
135
+ // console.error(result.stderr);
136
+ } catch (error) {
137
+ console.error('Error running "' + command + '":', error);
138
+ throw error
139
+ }
140
+ }
141
+
142
+ /**
143
+ * function spawnCommand
144
+ * @param command
145
+ * @param args
146
+ * @returns
147
+ */
148
+ export function spawnCommand(command: string, args: string[]): Promise<void> {
149
+ console.log()
150
+ console.log([command, ...args, '...'].join(' '))
151
+ const child_process = spawn(command, args, { stdio: 'inherit' })
152
+ return new Promise((resolve, reject) => {
153
+ child_process.on('close', (code) => {
154
+ if (code === 0) {
155
+ console.log(green('*') + ' ' + [command, ...args].join(' '))
156
+ resolve()
157
+ }
158
+ else {
159
+ reject(new Error([command, ...args].join(' ') + ' --> Error ' + code))
160
+ }
156
161
  })
162
+ })
163
+ }
164
+
165
+ /**
166
+ * function readPackageJson
167
+ * @returns
168
+ */
169
+ export async function readPackageJson(): Promise<any> {
170
+ try {
171
+ if (!fs.existsSync("package.json")) throw 'package.json not found'
172
+ const fileContent = fs.readFileSync("package.json")
173
+ return JSON.parse(fileContent.toString())
174
+ }
175
+ catch (err) {
176
+ console.error(err)
177
+ throw err
157
178
  }
158
179
  }
package/src/DBClient.ts CHANGED
@@ -135,6 +135,7 @@ export class DBClient {
135
135
  throw ('Module ' + dbname + ' not found')
136
136
  }
137
137
  await this.dbManager.dbModuleDelete(dbModule)
138
+ logger.info('module ' + dbname + ' (id ' + dbModule.id + ' deleted)')
138
139
  }
139
140
  catch (err) {
140
141
  logger.error(err)