From 70e17b4a3d2f2c4bf5e30458ce720708e23826a4 Mon Sep 17 00:00:00 2001 From: Richard Park Date: Wed, 18 Dec 2019 15:57:02 +0900 Subject: [PATCH] package script of daesang real is modified --- electron-builder.json | 19 ++++++++++++++++++- .../services/electron-notification.service.ts | 8 +++++--- .../src/lib/utils/animation-queue.ts | 6 ++++-- .../electron-update-window.service.ts | 3 ++- .../ucap-webmessenger-electron/src/index.ts | 12 +++++++----- .../src/lib/renderer-updater.ts | 15 ++++++++------- .../src/util/root.ts | 2 +- package.json | 2 +- .../src/app/app-translate.module.ts | 2 +- .../native/components/top-bar.component.ts | 8 +++++--- .../environments/environment.daesang.prod.ts | 2 +- 11 files changed, 53 insertions(+), 26 deletions(-) diff --git a/electron-builder.json b/electron-builder.json index 9fd7dffe..62b92fb8 100644 --- a/electron-builder.json +++ b/electron-builder.json @@ -36,5 +36,22 @@ "buildResources": "./dist/ucap-webmessenger-electron/resources/installer/", "output": "./dist/electron/", "app": "." - } + }, + "files": [ + "**/*", + "!**/*.ts", + "!LICENSE.md", + "!package.json", + "!package-lock.json", + "!electron-projects/", + "!projects/", + "!.prettierrc", + "!angular.json", + "!**/.awcache", + "!**/.vscode", + "!config/", + "!docker/", + "!tsconfig.json", + "!tslint.json" + ] } diff --git a/electron-projects/ucap-webmessenger-electron-notification/src/lib/services/electron-notification.service.ts b/electron-projects/ucap-webmessenger-electron-notification/src/lib/services/electron-notification.service.ts index 0fdc8062..79b3b879 100644 --- a/electron-projects/ucap-webmessenger-electron-notification/src/lib/services/electron-notification.service.ts +++ b/electron-projects/ucap-webmessenger-electron-notification/src/lib/services/electron-notification.service.ts @@ -1,6 +1,9 @@ import path from 'path'; import url from 'url'; import fse from 'fs-extra'; +import log from 'electron-log'; + +import { ElectronWebContentsChannel } from '@ucap-webmessenger/electron-core'; import { AnimationQueue } from '../utils/animation-queue'; import { @@ -11,7 +14,6 @@ import { screen, BrowserWindow, ipcMain, IpcMainEvent, shell } from 'electron'; import { ElectronNotification } from '../models/electron-notification'; import { ElectronNotificationEventType } from '../types/event.type'; import { Channel } from '../types/channel.type'; -import { ElectronWebContentsChannel } from '@ucap-webmessenger/electron-core'; const onClickElectronNotification = 'onClickElectronNotification'; const onCloseElectronNotification = 'onCloseElectronNotification'; @@ -220,12 +222,12 @@ export class ElectronNotificationService { slashes: true }); } catch (e) { - console.log( + log.error( 'electron-notify: Could not find template ("' + this.customOptions.templatePath + '").' ); - console.log( + log.error( 'electron-notify: To use a different template you need to correct the config.templatePath or simply adapt config.htmlTemplate' ); } diff --git a/electron-projects/ucap-webmessenger-electron-notification/src/lib/utils/animation-queue.ts b/electron-projects/ucap-webmessenger-electron-notification/src/lib/utils/animation-queue.ts index c421f726..df8cf75b 100644 --- a/electron-projects/ucap-webmessenger-electron-notification/src/lib/utils/animation-queue.ts +++ b/electron-projects/ucap-webmessenger-electron-notification/src/lib/utils/animation-queue.ts @@ -1,3 +1,5 @@ +import log from 'electron-log'; + export interface AnimationQueueObject { context: any; func: (...args: any[]) => Promise; @@ -29,10 +31,10 @@ export class AnimationQueue { } }) .catch(reason => { - console.log(reason); + log.error(reason); }); } catch (e) { - console.log(e); + log.error(e); } } diff --git a/electron-projects/ucap-webmessenger-electron-update-window/src/lib/services/electron-update-window.service.ts b/electron-projects/ucap-webmessenger-electron-update-window/src/lib/services/electron-update-window.service.ts index 127a550f..63fb466e 100644 --- a/electron-projects/ucap-webmessenger-electron-update-window/src/lib/services/electron-update-window.service.ts +++ b/electron-projects/ucap-webmessenger-electron-update-window/src/lib/services/electron-update-window.service.ts @@ -1,6 +1,7 @@ import { BrowserWindow, ipcMain } from 'electron'; import url from 'url'; import fse from 'fs-extra'; +import log from 'electron-log'; import { ElectronUpdateWindowOptions, DefaultElectronUpdateWindowOptions @@ -112,7 +113,7 @@ export class ElectronUpdateWindowService { slashes: true }); } catch (e) { - console.log( + log.error( 'electron-update-window: Could not find template ("' + this.customOptions.templatePath + '").' diff --git a/electron-projects/ucap-webmessenger-electron/src/index.ts b/electron-projects/ucap-webmessenger-electron/src/index.ts index c216f832..4c0193d1 100644 --- a/electron-projects/ucap-webmessenger-electron/src/index.ts +++ b/electron-projects/ucap-webmessenger-electron/src/index.ts @@ -145,7 +145,7 @@ function createWindow() { try { edi.default(extension); } catch (e) { - console.log(e); + log.error(e); } } }); @@ -357,7 +357,7 @@ ipcMain.on( .enable() .then(() => { event.returnValue = true; - console.log('AutoLaunch is enabled'); + log.info('AutoLaunch is enabled'); }) .catch(reason => { event.returnValue = false; @@ -367,7 +367,7 @@ ipcMain.on( .disable() .then(() => { event.returnValue = true; - console.log('AutoLaunch is disabled'); + log.info('AutoLaunch is disabled'); }) .catch(reason => { event.returnValue = false; @@ -409,15 +409,18 @@ ipcMain.on( ); ipcMain.on(FileChannel.ReadFile, (event: IpcMainEvent, ...args: any[]) => { + const filePath = root(args[0]); try { - fse.readFile(root(args[0]), (err, data) => { + fse.readFile(filePath, (err, data) => { if (!!err) { event.returnValue = err; + log.error(`File read failed path[${filePath}] err:`, err); } else { event.returnValue = data; } }); } catch (error) { + log.error(`File read failed path[${filePath}] err:`, error); event.returnValue = null; } }); @@ -539,7 +542,6 @@ ipcMain.on( NotificationChannel.CloseAllNotify, (event: IpcMainEvent, ...args: any[]) => { appWindow.browserWindow.flashFrame(false); - console.log('Channel.closeAllNotify', args); } ); diff --git a/electron-projects/ucap-webmessenger-electron/src/lib/renderer-updater.ts b/electron-projects/ucap-webmessenger-electron/src/lib/renderer-updater.ts index 1474ec94..8cc0ee3f 100644 --- a/electron-projects/ucap-webmessenger-electron/src/lib/renderer-updater.ts +++ b/electron-projects/ucap-webmessenger-electron/src/lib/renderer-updater.ts @@ -12,6 +12,7 @@ import zlib from 'zlib'; import { BrowserWindow, app } from 'electron'; import { UpdaterChannel } from '@ucap-webmessenger/native-electron'; import { startWith } from 'rxjs/operators'; +import log from 'electron-log'; export class RendererUpdater { private checkSubscription: Subscription | undefined; @@ -35,7 +36,7 @@ export class RendererUpdater { startCheck() { if (!semver.valid(this.config.currentVersion)) { - console.log( + log.error( `RendererUpdater::error currentVersion[${this.config.currentVersion}] is not valid` ); return; @@ -49,7 +50,7 @@ export class RendererUpdater { .then(res => { const appVersion = res.data.appVersion; if (!semver.valid(appVersion)) { - console.log( + log.error( `RendererUpdater::error appVersion[${appVersion}] is not valid` ); return; @@ -60,7 +61,7 @@ export class RendererUpdater { } }) .catch(reason => { - console.log('RendererUpdater', reason); + log.error('RendererUpdater', reason); }); }); } @@ -83,14 +84,14 @@ export class RendererUpdater { try { fse.unlinkSync(this.appPath.slice(0, -1)); } catch (error) { - console.log('RendererUpdater::apply', error); + log.error('RendererUpdater::apply', error); return; } try { fse.renameSync(this.unzipPath, this.appPath.slice(0, -1)); } catch (error) { - console.log('RendererUpdater::apply', error); + log.error('RendererUpdater::apply', error); return; } @@ -104,7 +105,7 @@ export class RendererUpdater { .then(res => { fse.writeFile(this.downloadPath, res.data, err => { if (!!err) { - console.log('RendererUpdater::download failed', err); + log.error('RendererUpdater::download failed', err); return; } const updateInfo: UpdateInfo = { @@ -116,7 +117,7 @@ export class RendererUpdater { }); }) .catch(reason => { - console.log('RendererUpdater::download failed', reason); + log.error('RendererUpdater::download failed', reason); }); } } diff --git a/electron-projects/ucap-webmessenger-electron/src/util/root.ts b/electron-projects/ucap-webmessenger-electron/src/util/root.ts index f5611558..32fdd3f6 100644 --- a/electron-projects/ucap-webmessenger-electron/src/util/root.ts +++ b/electron-projects/ucap-webmessenger-electron/src/util/root.ts @@ -3,7 +3,7 @@ import * as path from 'path'; // tslint:disable-next-line: variable-name const _root = __DEV__ ? path.resolve(__dirname, '..', '..') - : path.resolve(__dirname); + : path.resolve(__dirname, '..', '..'); export function root(...paths: string[]) { const args = Array.prototype.slice.call(paths, 0); diff --git a/package.json b/package.json index dcdfb80d..fbb1744d 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "build:main:development": "cross-env NODE_ENV=development TS_NODE_PROJECT='./config/tsconfig.webpack.json' parallel-webpack --config=config/main.webpack.config.ts", "build:main:production": "cross-env NODE_ENV=production TS_NODE_PROJECT='./config/tsconfig.webpack.json' NODE_OPTIONS='--max_old_space_size=4096' parallel-webpack --config=config/main.webpack.config.ts", "build:daesang": "npm-run-all -p build:daesang:renderer build:daesang:main:production", - "build:daesang:renderer": "cross-env NODE_ENV=production ng build -c renderer-daesang-development --base-href ./", + "build:daesang:renderer": "cross-env NODE_ENV=production ng build -c renderer-daesang-production --base-href ./", "build:daesang:main:development": "cross-env NODE_ENV=development TS_NODE_PROJECT='./config/tsconfig.webpack.json' parallel-webpack --config=config/main.webpack.config.ts", "build:daesang:main:production": "cross-env NODE_ENV=production TS_NODE_PROJECT='./config/tsconfig.webpack.json' NODE_OPTIONS='--max_old_space_size=4096' parallel-webpack --config=config/main.webpack.config.ts", "run:daesang": "npm-run-all -p run:daesang:renderer run:daesang:main", diff --git a/projects/ucap-webmessenger-app/src/app/app-translate.module.ts b/projects/ucap-webmessenger-app/src/app/app-translate.module.ts index b1518a9a..04aba0ea 100644 --- a/projects/ucap-webmessenger-app/src/app/app-translate.module.ts +++ b/projects/ucap-webmessenger-app/src/app/app-translate.module.ts @@ -9,7 +9,7 @@ import { environment } from '../environments/environment'; export function createTranslateLoader(nativeService: NativeService) { const translateLoader = nativeService.getTranslateLoader( environment.production - ? './assets/i18n/' + ? '/dist/ucap-webmessenger-app/assets/i18n/' : '/projects/ucap-webmessenger-app/src/assets/i18n/', '.json' ); diff --git a/projects/ucap-webmessenger-app/src/app/layouts/native/components/top-bar.component.ts b/projects/ucap-webmessenger-app/src/app/layouts/native/components/top-bar.component.ts index 0ff1b622..1681bb6b 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/native/components/top-bar.component.ts +++ b/projects/ucap-webmessenger-app/src/app/layouts/native/components/top-bar.component.ts @@ -34,6 +34,7 @@ import { import { AppUserInfo, KEY_APP_USER_INFO } from '@app/types/app-user-info.type'; import { environment } from '../../../../environments/environment'; import { DaesangApiService } from '@ucap-webmessenger/daesang'; +import { NGXLogger } from 'ngx-logger'; @Component({ selector: 'app-layout-native-top-bar', @@ -60,7 +61,8 @@ export class TopBarComponent implements OnInit, OnDestroy { @Inject(UCAP_NATIVE_SERVICE) private nativeService: NativeService, private localStorageService: LocalStorageService, private sessionStorageService: SessionStorageService, - private daesangApiService: DaesangApiService + private daesangApiService: DaesangApiService, + private logger: NGXLogger ) {} ngOnInit() { @@ -144,7 +146,7 @@ export class TopBarComponent implements OnInit, OnDestroy { .pipe( take(1), map(res => (this.webLinkBadgeMail = res.count)), - catchError(error => of(console.log(error))) + catchError(error => of(this.logger.log(error))) ) .subscribe(); } @@ -179,7 +181,7 @@ export class TopBarComponent implements OnInit, OnDestroy { map(res => { this.webLinkBadgePayment = res.count; }), - catchError(error => of(console.log(error))) + catchError(error => of(this.logger.log(error))) ) .subscribe(); } diff --git a/projects/ucap-webmessenger-app/src/environments/environment.daesang.prod.ts b/projects/ucap-webmessenger-app/src/environments/environment.daesang.prod.ts index 1d1e4261..8e6780c3 100644 --- a/projects/ucap-webmessenger-app/src/environments/environment.daesang.prod.ts +++ b/projects/ucap-webmessenger-app/src/environments/environment.daesang.prod.ts @@ -12,7 +12,7 @@ import { import { DeviceType } from '@ucap-webmessenger/core'; export const environment: Environment = { - production: false, + production: true, title: `DS Talk`, companyConfig: {