diff options
author | 2022-04-22 15:04:21 -0500 | |
---|---|---|
committer | 2022-04-22 20:04:21 +0000 | |
commit | 759d93dc198a3cc8c5265245c0144efa5435682b (patch) | |
tree | 53e963a085d3d12af5a2efa2f1ab6f3e5574edc7 /src/api/server | |
parent | Added build scripts for linux, macos and windows to help new contributors get... (diff) | |
download | ferdium-app-759d93dc198a3cc8c5265245c0144efa5435682b.tar.gz ferdium-app-759d93dc198a3cc8c5265245c0144efa5435682b.tar.zst ferdium-app-759d93dc198a3cc8c5265245c0144efa5435682b.zip |
Turn off usage of 'debug' npm package using with electron-16 (fixes #17)
Diffstat (limited to 'src/api/server')
-rw-r--r-- | src/api/server/LocalApi.ts | 9 | ||||
-rw-r--r-- | src/api/server/ServerApi.ts | 61 |
2 files changed, 36 insertions, 34 deletions
diff --git a/src/api/server/LocalApi.ts b/src/api/server/LocalApi.ts index 5e205cbe4..28028bf80 100644 --- a/src/api/server/LocalApi.ts +++ b/src/api/server/LocalApi.ts | |||
@@ -4,14 +4,15 @@ import fastFolderSize from 'fast-folder-size'; | |||
4 | 4 | ||
5 | import { getServicePartitionsDirectory } from '../../helpers/service-helpers'; | 5 | import { getServicePartitionsDirectory } from '../../helpers/service-helpers'; |
6 | 6 | ||
7 | const debug = require('debug')('Ferdium:LocalApi'); | 7 | // TODO: Go back to 'debug' from 'console.log' when https://github.com/electron/electron/issues/31689 is fixed |
8 | // const debug = require('debug')('Ferdium:LocalApi'); | ||
8 | 9 | ||
9 | export default class LocalApi { | 10 | export default class LocalApi { |
10 | // Settings | 11 | // Settings |
11 | getAppSettings(type: string) { | 12 | getAppSettings(type: string) { |
12 | return new Promise(resolve => { | 13 | return new Promise(resolve => { |
13 | ipcRenderer.once('appSettings', (_event, resp) => { | 14 | ipcRenderer.once('appSettings', (_event, resp) => { |
14 | debug('LocalApi::getAppSettings resolves', resp.type, resp.data); | 15 | console.log('LocalApi::getAppSettings resolves', resp.type, resp.data); |
15 | resolve(resp); | 16 | resolve(resp); |
16 | }); | 17 | }); |
17 | 18 | ||
@@ -20,7 +21,7 @@ export default class LocalApi { | |||
20 | } | 21 | } |
21 | 22 | ||
22 | async updateAppSettings(type: string, data: any) { | 23 | async updateAppSettings(type: string, data: any) { |
23 | debug('LocalApi::updateAppSettings resolves', type, data); | 24 | console.log('LocalApi::updateAppSettings resolves', type, data); |
24 | ipcRenderer.send('updateAppSettings', { | 25 | ipcRenderer.send('updateAppSettings', { |
25 | type, | 26 | type, |
26 | data, | 27 | data, |
@@ -39,7 +40,7 @@ export default class LocalApi { | |||
39 | reject(err); | 40 | reject(err); |
40 | } | 41 | } |
41 | 42 | ||
42 | debug('LocalApi::getAppCacheSize resolves', bytes); | 43 | console.log('LocalApi::getAppCacheSize resolves', bytes); |
43 | resolve(bytes); | 44 | resolve(bytes); |
44 | }, | 45 | }, |
45 | ); | 46 | ); |
diff --git a/src/api/server/ServerApi.ts b/src/api/server/ServerApi.ts index 9dc3a9a0e..dc29c7b89 100644 --- a/src/api/server/ServerApi.ts +++ b/src/api/server/ServerApi.ts | |||
@@ -35,7 +35,8 @@ import { | |||
35 | 35 | ||
36 | import { removeServicePartitionDirectory } from '../../helpers/service-helpers'; | 36 | import { removeServicePartitionDirectory } from '../../helpers/service-helpers'; |
37 | 37 | ||
38 | const debug = require('debug')('Ferdium:ServerApi'); | 38 | // TODO: Go back to 'debug' from 'console.log' when https://github.com/electron/electron/issues/31689 is fixed |
39 | // const debug = require('debug')('Ferdium:ServerApi'); | ||
39 | 40 | ||
40 | module.paths.unshift(getDevRecipeDirectory(), getRecipeDirectory()); | 41 | module.paths.unshift(getDevRecipeDirectory(), getRecipeDirectory()); |
41 | 42 | ||
@@ -61,7 +62,7 @@ export default class ServerApi { | |||
61 | } | 62 | } |
62 | const u = await request.json(); | 63 | const u = await request.json(); |
63 | 64 | ||
64 | debug('ServerApi::login resolves', u); | 65 | console.log('ServerApi::login resolves', u); |
65 | return u.token; | 66 | return u.token; |
66 | } | 67 | } |
67 | 68 | ||
@@ -79,7 +80,7 @@ export default class ServerApi { | |||
79 | } | 80 | } |
80 | const u = await request.json(); | 81 | const u = await request.json(); |
81 | 82 | ||
82 | debug('ServerApi::signup resolves', u); | 83 | console.log('ServerApi::signup resolves', u); |
83 | return u.token; | 84 | return u.token; |
84 | } | 85 | } |
85 | 86 | ||
@@ -92,7 +93,7 @@ export default class ServerApi { | |||
92 | throw new Error(request.statusText); | 93 | throw new Error(request.statusText); |
93 | } | 94 | } |
94 | 95 | ||
95 | debug('ServerApi::inviteUser'); | 96 | console.log('ServerApi::inviteUser'); |
96 | return true; | 97 | return true; |
97 | } | 98 | } |
98 | 99 | ||
@@ -112,7 +113,7 @@ export default class ServerApi { | |||
112 | } | 113 | } |
113 | const r = await request.json(); | 114 | const r = await request.json(); |
114 | 115 | ||
115 | debug('ServerApi::retrievePassword'); | 116 | console.log('ServerApi::retrievePassword'); |
116 | return r; | 117 | return r; |
117 | } | 118 | } |
118 | 119 | ||
@@ -128,7 +129,7 @@ export default class ServerApi { | |||
128 | const data = await request.json(); | 129 | const data = await request.json(); |
129 | 130 | ||
130 | const user = new UserModel(data); | 131 | const user = new UserModel(data); |
131 | debug('ServerApi::userInfo resolves', user); | 132 | console.log('ServerApi::userInfo resolves', user); |
132 | 133 | ||
133 | return user; | 134 | return user; |
134 | } | 135 | } |
@@ -146,7 +147,7 @@ export default class ServerApi { | |||
146 | const user = Object.assign(updatedData, { | 147 | const user = Object.assign(updatedData, { |
147 | data: new UserModel(updatedData.data), | 148 | data: new UserModel(updatedData.data), |
148 | }); | 149 | }); |
149 | debug('ServerApi::updateUserInfo resolves', user); | 150 | console.log('ServerApi::updateUserInfo resolves', user); |
150 | return user; | 151 | return user; |
151 | } | 152 | } |
152 | 153 | ||
@@ -159,7 +160,7 @@ export default class ServerApi { | |||
159 | } | 160 | } |
160 | const data = await request.json(); | 161 | const data = await request.json(); |
161 | 162 | ||
162 | debug('ServerApi::deleteAccount resolves', data); | 163 | console.log('ServerApi::deleteAccount resolves', data); |
163 | return data; | 164 | return data; |
164 | } | 165 | } |
165 | 166 | ||
@@ -177,7 +178,7 @@ export default class ServerApi { | |||
177 | 178 | ||
178 | const services = await this._mapServiceModels(data); | 179 | const services = await this._mapServiceModels(data); |
179 | const filteredServices = services.filter(service => !!service); | 180 | const filteredServices = services.filter(service => !!service); |
180 | debug('ServerApi::getServices resolves', filteredServices); | 181 | console.log('ServerApi::getServices resolves', filteredServices); |
181 | return filteredServices; | 182 | return filteredServices; |
182 | } | 183 | } |
183 | 184 | ||
@@ -204,7 +205,7 @@ export default class ServerApi { | |||
204 | data: await this._prepareServiceModel(serviceData.data), | 205 | data: await this._prepareServiceModel(serviceData.data), |
205 | }); | 206 | }); |
206 | 207 | ||
207 | debug('ServerApi::createService resolves', service); | 208 | console.log('ServerApi::createService resolves', service); |
208 | return service; | 209 | return service; |
209 | } | 210 | } |
210 | 211 | ||
@@ -230,7 +231,7 @@ export default class ServerApi { | |||
230 | data: await this._prepareServiceModel(serviceData.data), | 231 | data: await this._prepareServiceModel(serviceData.data), |
231 | }); | 232 | }); |
232 | 233 | ||
233 | debug('ServerApi::updateService resolves', service); | 234 | console.log('ServerApi::updateService resolves', service); |
234 | return service; | 235 | return service; |
235 | } | 236 | } |
236 | 237 | ||
@@ -270,7 +271,7 @@ export default class ServerApi { | |||
270 | throw new Error(request.statusText); | 271 | throw new Error(request.statusText); |
271 | } | 272 | } |
272 | const serviceData = await request.json(); | 273 | const serviceData = await request.json(); |
273 | debug('ServerApi::reorderService resolves', serviceData); | 274 | console.log('ServerApi::reorderService resolves', serviceData); |
274 | return serviceData; | 275 | return serviceData; |
275 | } | 276 | } |
276 | 277 | ||
@@ -285,7 +286,7 @@ export default class ServerApi { | |||
285 | 286 | ||
286 | removeServicePartitionDirectory(id, true); | 287 | removeServicePartitionDirectory(id, true); |
287 | 288 | ||
288 | debug('ServerApi::deleteService resolves', data); | 289 | console.log('ServerApi::deleteService resolves', data); |
289 | return data; | 290 | return data; |
290 | } | 291 | } |
291 | 292 | ||
@@ -298,7 +299,7 @@ export default class ServerApi { | |||
298 | const data = await request.json(); | 299 | const data = await request.json(); |
299 | 300 | ||
300 | const features = data; | 301 | const features = data; |
301 | debug('ServerApi::getDefaultFeatures resolves', features); | 302 | console.log('ServerApi::getDefaultFeatures resolves', features); |
302 | return features; | 303 | return features; |
303 | } | 304 | } |
304 | 305 | ||
@@ -314,7 +315,7 @@ export default class ServerApi { | |||
314 | const data = await request.json(); | 315 | const data = await request.json(); |
315 | 316 | ||
316 | const features = data; | 317 | const features = data; |
317 | debug('ServerApi::getFeatures resolves', features); | 318 | console.log('ServerApi::getFeatures resolves', features); |
318 | return features; | 319 | return features; |
319 | } | 320 | } |
320 | 321 | ||
@@ -339,7 +340,7 @@ export default class ServerApi { | |||
339 | // eslint-disable-next-line unicorn/prefer-spread | 340 | // eslint-disable-next-line unicorn/prefer-spread |
340 | this.recipes = this.recipes.concat(this._getDevRecipes()); | 341 | this.recipes = this.recipes.concat(this._getDevRecipes()); |
341 | 342 | ||
342 | debug('StubServerApi::getInstalledRecipes resolves', this.recipes); | 343 | console.log('StubServerApi::getInstalledRecipes resolves', this.recipes); |
343 | return this.recipes; | 344 | return this.recipes; |
344 | } | 345 | } |
345 | 346 | ||
@@ -352,7 +353,7 @@ export default class ServerApi { | |||
352 | throw new Error(request.statusText); | 353 | throw new Error(request.statusText); |
353 | } | 354 | } |
354 | const recipes = await request.json(); | 355 | const recipes = await request.json(); |
355 | debug('ServerApi::getRecipeUpdates resolves', recipes); | 356 | console.log('ServerApi::getRecipeUpdates resolves', recipes); |
356 | return recipes; | 357 | return recipes; |
357 | } | 358 | } |
358 | 359 | ||
@@ -362,7 +363,7 @@ export default class ServerApi { | |||
362 | if (!request.ok) throw new Error(request.statusText); | 363 | if (!request.ok) throw new Error(request.statusText); |
363 | const data = await request.json(); | 364 | const data = await request.json(); |
364 | const recipePreviews = this._mapRecipePreviewModel(data); | 365 | const recipePreviews = this._mapRecipePreviewModel(data); |
365 | debug('ServerApi::getRecipes resolves', recipePreviews); | 366 | console.log('ServerApi::getRecipes resolves', recipePreviews); |
366 | return recipePreviews; | 367 | return recipePreviews; |
367 | } | 368 | } |
368 | 369 | ||
@@ -374,7 +375,7 @@ export default class ServerApi { | |||
374 | // data = this._addLocalRecipesToPreviews(data); | 375 | // data = this._addLocalRecipesToPreviews(data); |
375 | 376 | ||
376 | const recipePreviews = this._mapRecipePreviewModel(data); | 377 | const recipePreviews = this._mapRecipePreviewModel(data); |
377 | debug('ServerApi::getFeaturedRecipes resolves', recipePreviews); | 378 | console.log('ServerApi::getFeaturedRecipes resolves', recipePreviews); |
378 | return recipePreviews; | 379 | return recipePreviews; |
379 | } | 380 | } |
380 | 381 | ||
@@ -385,7 +386,7 @@ export default class ServerApi { | |||
385 | 386 | ||
386 | const data = await request.json(); | 387 | const data = await request.json(); |
387 | const recipePreviews = this._mapRecipePreviewModel(data); | 388 | const recipePreviews = this._mapRecipePreviewModel(data); |
388 | debug('ServerApi::searchRecipePreviews resolves', recipePreviews); | 389 | console.log('ServerApi::searchRecipePreviews resolves', recipePreviews); |
389 | return recipePreviews; | 390 | return recipePreviews; |
390 | } | 391 | } |
391 | 392 | ||
@@ -401,21 +402,21 @@ export default class ServerApi { | |||
401 | let archivePath: PathOrFileDescriptor; | 402 | let archivePath: PathOrFileDescriptor; |
402 | 403 | ||
403 | if (pathExistsSync(internalRecipeFile)) { | 404 | if (pathExistsSync(internalRecipeFile)) { |
404 | debug('[ServerApi::getRecipePackage] Using internal recipe file'); | 405 | console.log('[ServerApi::getRecipePackage] Using internal recipe file'); |
405 | archivePath = internalRecipeFile; | 406 | archivePath = internalRecipeFile; |
406 | } else { | 407 | } else { |
407 | debug('[ServerApi::getRecipePackage] Downloading recipe from server'); | 408 | console.log('[ServerApi::getRecipePackage] Downloading recipe from server'); |
408 | archivePath = tempArchivePath; | 409 | archivePath = tempArchivePath; |
409 | 410 | ||
410 | const packageUrl = `${apiBase()}/recipes/download/${recipeId}`; | 411 | const packageUrl = `${apiBase()}/recipes/download/${recipeId}`; |
411 | 412 | ||
412 | const res = await window.fetch(packageUrl); | 413 | const res = await window.fetch(packageUrl); |
413 | debug('Recipe downloaded', recipeId); | 414 | console.log('Recipe downloaded', recipeId); |
414 | const blob = await res.blob(); | 415 | const blob = await res.blob(); |
415 | const buffer = await blob.arrayBuffer(); | 416 | const buffer = await blob.arrayBuffer(); |
416 | writeFileSync(tempArchivePath, Buffer.from(buffer)); | 417 | writeFileSync(tempArchivePath, Buffer.from(buffer)); |
417 | } | 418 | } |
418 | debug(archivePath); | 419 | console.log(archivePath); |
419 | 420 | ||
420 | await sleep(10); | 421 | await sleep(10); |
421 | 422 | ||
@@ -426,7 +427,7 @@ export default class ServerApi { | |||
426 | preservePaths: true, | 427 | preservePaths: true, |
427 | unlink: true, | 428 | unlink: true, |
428 | preserveOwner: false, | 429 | preserveOwner: false, |
429 | onwarn: x => debug('warn', recipeId, x), | 430 | onwarn: x => console.log('warn', recipeId, x), |
430 | }); | 431 | }); |
431 | 432 | ||
432 | await sleep(10); | 433 | await sleep(10); |
@@ -456,7 +457,7 @@ export default class ServerApi { | |||
456 | if (!request.ok) { | 457 | if (!request.ok) { |
457 | throw new Error(request.statusText); | 458 | throw new Error(request.statusText); |
458 | } | 459 | } |
459 | debug('ServerApi::healthCheck resolves'); | 460 | console.log('ServerApi::healthCheck resolves'); |
460 | } | 461 | } |
461 | 462 | ||
462 | async getLegacyServices() { | 463 | async getLegacyServices() { |
@@ -483,7 +484,7 @@ export default class ServerApi { | |||
483 | }), | 484 | }), |
484 | ); | 485 | ); |
485 | 486 | ||
486 | debug('ServerApi::getLegacyServices resolves', services); | 487 | console.log('ServerApi::getLegacyServices resolves', services); |
487 | return services; | 488 | return services; |
488 | } | 489 | } |
489 | } catch { | 490 | } catch { |
@@ -516,7 +517,7 @@ export default class ServerApi { | |||
516 | 517 | ||
517 | return new ServiceModel(service, recipe); | 518 | return new ServiceModel(service, recipe); |
518 | } catch (error) { | 519 | } catch (error) { |
519 | debug(error); | 520 | console.log(error); |
520 | return null; | 521 | return null; |
521 | } | 522 | } |
522 | } | 523 | } |
@@ -539,7 +540,7 @@ export default class ServerApi { | |||
539 | 540 | ||
540 | await this.getRecipePackage(recipeId); | 541 | await this.getRecipePackage(recipeId); |
541 | 542 | ||
542 | debug('Rerun ServerAPI::getInstalledRecipes'); | 543 | console.log('Rerun ServerAPI::getInstalledRecipes'); |
543 | await this.getInstalledRecipes(); | 544 | await this.getInstalledRecipes(); |
544 | 545 | ||
545 | recipe = this.recipes.find(r => r.id === recipeId); | 546 | recipe = this.recipes.find(r => r.id === recipeId); |
@@ -604,7 +605,7 @@ export default class ServerApi { | |||
604 | 605 | ||
605 | return recipes; | 606 | return recipes; |
606 | } catch { | 607 | } catch { |
607 | debug('Could not load dev recipes'); | 608 | console.log('Could not load dev recipes'); |
608 | return false; | 609 | return false; |
609 | } | 610 | } |
610 | } | 611 | } |