From b89b4b0c91f4b3bf38f81aa1382fd1aa5c773617 Mon Sep 17 00:00:00 2001 From: Nicolas Constant Date: Fri, 25 Jun 2021 18:46:53 -0400 Subject: [PATCH 01/12] added logs --- main.ts | 52 +++++++++------ src/app/core/services/domain.service.ts | 74 ++++++++++++--------- src/app/core/services/filesystem.service.ts | 9 ++- 3 files changed, 81 insertions(+), 54 deletions(-) diff --git a/main.ts b/main.ts index 20a8dab..acf47bb 100644 --- a/main.ts +++ b/main.ts @@ -81,38 +81,50 @@ try { ipcMain.on('download-item', (event, info) => { (async () => { - info.properties.onProgress = status => event.sender.send("download-progress", { packageId: info.packageId, status: status}); - - const win = BrowserWindow.getFocusedWindow(); - await download(win, info.url, info.properties) - .then(dl => event.sender.send('download-success', dl.getSavePath())); + try { + info.properties.onProgress = status => event.sender.send("download-progress", { packageId: info.packageId, status: status }); + + const win = BrowserWindow.getFocusedWindow(); + await download(win, info.url, info.properties) + .then(dl => event.sender.send('download-success', dl.getSavePath())); + } catch (err) { + event.sender.send('log-error', err); + }; })(); }); ipcMain.on('extract-item', (event, info) => { (async () => { - const pro = new Promise((resolve, reject) => { - const zip = new AdmZip(info.filePath); - zip.extractAllToAsync(info.extractFolder, true, (err) => { - if (err) reject(); - resolve(); + try { + const pro = new Promise((resolve, reject) => { + const zip = new AdmZip(info.filePath); + zip.extractAllToAsync(info.extractFolder, true, (err) => { + if (err) reject(); + resolve(); + }); }); - }); - await pro; - event.sender.send('extract-success', info); + await pro; + event.sender.send('extract-success', info); + } catch (err) { + event.sender.send('log-error', err); + }; })(); }); ipcMain.on('copy-folder', (event, info) => { (async () => { - const pro = new Promise((resolve, reject) => { - fse.copy(info.source, info.target, { overwrite: true }, (err) => { - if (err) reject(err); - resolve(); + try { + const pro = new Promise((resolve, reject) => { + fse.copy(info.source, info.target, { overwrite: true }, (err) => { + if (err) reject(err); + resolve(); + }); }); - }); - await pro; - event.sender.send('copy-folder-success', info); + await pro; + event.sender.send('copy-folder-success', info); + } catch (err) { + event.sender.send('log-error', err); + }; })(); }); }); diff --git a/src/app/core/services/domain.service.ts b/src/app/core/services/domain.service.ts index f577d4d..f1da805 100644 --- a/src/app/core/services/domain.service.ts +++ b/src/app/core/services/domain.service.ts @@ -57,13 +57,13 @@ export class DomainService { .catch(err => { console.error(err); error = err; - x.state = InstallStatusEnum.error; + x.state = InstallStatusEnum.error; }); }); }); pipeline = pipeline.then(() => { - if(error){ - throw(error); + if (error) { + throw (error); } }); return pipeline; @@ -124,44 +124,52 @@ export class DomainService { } async processExtractedFolder(r: FileExtractedInfo): Promise { - const extractedFolder = r.extractFolder; - const addinFolderPath = await this.filesystemService.findAddinFolder(extractedFolder); + try { + const extractedFolder = r.extractFolder; + const addinFolderPath = await this.filesystemService.findAddinFolder(extractedFolder); - if (!addinFolderPath) return; + if (!addinFolderPath) return; - const p = this.packages.find(x => x.id === r.packageId); + const p = this.packages.find(x => x.id === r.packageId); - const communityDir = this.settingsService.getSettings().communityPath; - const folderPath = `${communityDir}\\${p.folderName}`; + const communityDir = this.settingsService.getSettings().communityPath; + const folderPath = `${communityDir}\\${p.folderName}`; - p.state = InstallStatusEnum.installing; - this.app.tick(); + p.state = InstallStatusEnum.installing; + this.app.tick(); - // Clean up - await this.filesystemService.deleteFolder(folderPath); + // Clean up + await this.filesystemService.deleteFolder(folderPath); - if (p.oldFolderNames && p.oldFolderNames.length > 0) { - p.oldFolderNames.forEach(o => { - (async () => { - const oldFolderPath = `${communityDir}\\${o}`; - await this.filesystemService.deleteFolder(oldFolderPath); - })(); - }); - } + if (p.oldFolderNames && p.oldFolderNames.length > 0) { + p.oldFolderNames.forEach(o => { + (async () => { + const oldFolderPath = `${communityDir}\\${o}`; + await this.filesystemService.deleteFolder(oldFolderPath); + })(); + }); + } - this.filesystemService.copyToCommunity(p.id, addinFolderPath, p.folderName); + this.filesystemService.copyToCommunity(p.id, addinFolderPath, p.folderName); + } catch (err) { + console.error(err); + } } processCopiedFolder(r: CopyFolderInfo): void { - const p = this.packages.find(x => x.id === r.packageId); - if (p.tempWorkingDir) { - this.filesystemService.deleteFolder(p.tempWorkingDir); - p.tempWorkingDir = null; + try { + const p = this.packages.find(x => x.id === r.packageId); + if (p.tempWorkingDir) { + this.filesystemService.deleteFolder(p.tempWorkingDir); + p.tempWorkingDir = null; + } + this.filesystemService.writeVersionFile(r.target, p.availableVersion); + p.localVersion = p.availableVersion; + p.state = InstallStatusEnum.installed; + this.app.tick(); + } catch (err) { + console.error(err); } - this.filesystemService.writeVersionFile(r.target, p.availableVersion); - p.localVersion = p.availableVersion; - p.state = InstallStatusEnum.installed; - this.app.tick(); } getPackages(): Package[] { @@ -183,7 +191,7 @@ export class DomainService { this.packages.forEach(x => x.isSelected = false); - const settings = this.settingsService.getSettings(); + const settings = this.settingsService.getSettings(); settings.customPackages.push(p); this.settingsService.saveSettings(settings); @@ -335,11 +343,11 @@ export class DomainService { remove(p: Package): void { const communityDir = this.settingsService.getSettings().communityPath; - + let folderPath = `${communityDir}\\${p.folderName}`; const customPackageFolder = this.settingsService.getCustomPackageDirectory(p.id); - if(customPackageFolder){ + if (customPackageFolder) { folderPath = `${customPackageFolder}\\${p.folderName}`; } diff --git a/src/app/core/services/filesystem.service.ts b/src/app/core/services/filesystem.service.ts index 91eaca3..63f99ef 100644 --- a/src/app/core/services/filesystem.service.ts +++ b/src/app/core/services/filesystem.service.ts @@ -21,6 +21,13 @@ export class FilesystemService { } }); + this.electronService.ipcRenderer.on('log-error', (event, arg) => { + if (arg) { + console.error('Node error'); + console.error(arg); + } + }); + this.checkCleanUpCommunity(); } @@ -32,7 +39,7 @@ export class FilesystemService { .then((dirs: string[]) => { return dirs.filter(x => x.includes('msfs-downloader___')); }) - .then((filDirs: string[]) => { + .then((filDirs: string[]) => { for (const d of filDirs) { const fullPath = `${communityPath}\\${d}`; this.deleteFolder(fullPath); From caccf415df3da8689ab93fe07e514871340a0b41 Mon Sep 17 00:00:00 2001 From: Nicolas Constant Date: Fri, 25 Jun 2021 18:49:52 -0400 Subject: [PATCH 02/12] road to 1.0.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4030a3e..7552375 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "msfs-community-downloader", - "version": "1.0.0", + "version": "1.0.1", "description": "MSFS addin downloader client", "homepage": "https://github.com/nicolasconstant/msfs-community-downloader", "author": { From f4f6087e5bc238a8b144b8ea85721602f54d6eac Mon Sep 17 00:00:00 2001 From: Nicolas Constant Date: Fri, 25 Jun 2021 18:51:09 -0400 Subject: [PATCH 03/12] fix lint --- main.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.ts b/main.ts index acf47bb..30df230 100644 --- a/main.ts +++ b/main.ts @@ -89,7 +89,7 @@ try { .then(dl => event.sender.send('download-success', dl.getSavePath())); } catch (err) { event.sender.send('log-error', err); - }; + } })(); }); @@ -107,7 +107,7 @@ try { event.sender.send('extract-success', info); } catch (err) { event.sender.send('log-error', err); - }; + } })(); }); @@ -124,7 +124,7 @@ try { event.sender.send('copy-folder-success', info); } catch (err) { event.sender.send('log-error', err); - }; + } })(); }); }); From 99fd8b903a7ece9fc54c72c9d3215dc16daca0bb Mon Sep 17 00:00:00 2001 From: Nicolas Constant Date: Wed, 28 Jul 2021 19:55:33 -0400 Subject: [PATCH 04/12] added changelog link --- src/app/core/services/domain.service.ts | 1 + src/app/core/services/github.service.ts | 6 ++++-- src/app/core/services/packages.service.ts | 1 + .../package-detailed.component.html | 2 +- .../package-detailed.component.scss | 13 +++++++++++-- 5 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/app/core/services/domain.service.ts b/src/app/core/services/domain.service.ts index f1da805..e47fbc5 100644 --- a/src/app/core/services/domain.service.ts +++ b/src/app/core/services/domain.service.ts @@ -86,6 +86,7 @@ export class DomainService { p.availableVersion = remote.availableVersion; p.assetDownloadUrl = remote.downloadUrl; p.publishedAt = remote.publishedAt; + p.html_url = remote.html_url; } p.state = this.getState(p, local, remote); diff --git a/src/app/core/services/github.service.ts b/src/app/core/services/github.service.ts index 2099a10..1b5aacc 100644 --- a/src/app/core/services/github.service.ts +++ b/src/app/core/services/github.service.ts @@ -29,7 +29,7 @@ export class GithubService { downloadUrl = asset.browser_download_url; } - const res = new PackageInfo(lastRelease.tag_name, downloadUrl, lastRelease.published_at); + const res = new PackageInfo(lastRelease.tag_name, downloadUrl, lastRelease.published_at, lastRelease.html_url); return res; }); } @@ -50,7 +50,8 @@ export class PackageInfo { constructor( public availableVersion: string, public downloadUrl: string, - public publishedAt: Date) { } + public publishedAt: Date, + public html_url: string) { } } interface GithubRelease { @@ -61,6 +62,7 @@ interface GithubRelease { assets: GithubAsset[]; zipball_url: string; published_at: Date; + html_url: string; } interface GithubAsset { diff --git a/src/app/core/services/packages.service.ts b/src/app/core/services/packages.service.ts index 4abaf70..c2ea654 100644 --- a/src/app/core/services/packages.service.ts +++ b/src/app/core/services/packages.service.ts @@ -183,6 +183,7 @@ export class Package { public localVersion: string; public availableVersion: string; public publishedAt: Date; + public html_url: string; public githubOwner: string; public githubRepo: string; diff --git a/src/app/home/package-detailed/package-detailed.component.html b/src/app/home/package-detailed/package-detailed.component.html index 74dae64..3318a70 100644 --- a/src/app/home/package-detailed/package-detailed.component.html +++ b/src/app/home/package-detailed/package-detailed.component.html @@ -47,7 +47,7 @@

{{package.description}}
Release date
- {{ package.publishedAt | date:'yyyy/MM/dd' }} + {{ package.publishedAt | date:'yyyy/MM/dd' }}
diff --git a/src/app/home/package-detailed/package-detailed.component.scss b/src/app/home/package-detailed/package-detailed.component.scss index 2128ac8..da0e76d 100644 --- a/src/app/home/package-detailed/package-detailed.component.scss +++ b/src/app/home/package-detailed/package-detailed.component.scss @@ -206,8 +206,17 @@ &__title { color: #b3bfcc; } - // &__date { - // } + &__date { + &--link { + color: white; + text-decoration: underline; + + &:hover { + color: gray; + text-decoration: underline; + } + } + } } .version__github { From 260b1b1f0ce9da74ff1fa273e6680944f00f087f Mon Sep 17 00:00:00 2001 From: Nicolas Constant Date: Wed, 28 Jul 2021 21:46:39 -0400 Subject: [PATCH 05/12] creating new doc page --- docs/icon.png | Bin 0 -> 4834 bytes docs/windsailor.html | 86 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 docs/icon.png create mode 100644 docs/windsailor.html diff --git a/docs/icon.png b/docs/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..848473235771a0ec3b3443ad4707a15e405e4ed3 GIT binary patch literal 4834 zcmai&`9D-&{KwBM_AHS#TecF>qLgi@lp*0mAw(Z#Frn;>F%ustWe-I%WwI28Y-O35 zQnVu5Si)3fH%jY2TB>c9@En&;9@bRS z@~a~U;9};AHHLMk5;LgUepI}ZDb*}4_o3X}OIr}Sb_{*idhle|CGSZ5me+hvXad>W zMB?BLq&dn=W2!KtZ^u6!?&w781~c;ma_VqZ+Guv@3vzONZ`fTjUc*#{By;~$3G869 zc!@M_bVOm{OVH{A_B;q90i?Nccr)!(=itQ*wgq~Izl87YPB2#{HQ7M$JC?y-jJ&o- z0Zz)ltF>m=>eWC-rPtt@3OfO;GsToZ(27hB&t4h;VX6n=BqiLBaA#Q9{DG-t*tEGl z^y1YSLI5mm@Ey5Ovs{)WgFFptFdah^()JU9+>erxFgU4MN0ZY;G;&U7hojvDpxP2( z&Qxpa_DTO?beD=i2?7cX_q)IO6c}q#BY==b<-$5Y2Rs!&Q|;h#|t|_;=0%^O7VP_8nmLrA|P9 zU(Kp*bJjW=)ROih%`c^He53y}H;#eJ3Bpy&6R0OjoT@cAA08GddhZY<*36pG39@E| z1aUM$jwHq=0xMP^x?aYeH=U7^Rue_MlqL^L8*zjRUp2PbEKD+!(nUalxHtwvcdA(# zSt18ZYYRx&A?m7(m0K##xOmS^tw9YeJ@owKN^j(RSKV(3#uiJ+yi(@zBAnpY9rhxJ zRl(AmhRVRVUxM$DIo{c~D+Gx#^I4%6G~0q7lSSb@x8DB^ELvI|tvt}qDqA?BU;)qeG*2w^svA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*yY#(Qg1oKl9JRiI|RI>W%F5>_{5 zi@v!NGn;F>jSt`FqcMzI`?2m0W5x~FanS8ehZ=QE>ZWUzcKnN7)L+|usWh8^ zsFZ7hu6J5`&0-7;^JLrhYu~*$Fy~yMmwD^Y2EnDuZ-o1@Zk)CpLq9uemzZWXH}k!) za^r5EbELa$R9?`oBrw_bvKe7-JHK#X;JN-cWdn#Gg*+X`BROwWlmwP}iTa5+OqP4c?#ixROHkc6OP zpkEgBGQ|S7d+&me6PnTdT|EuR^$iic z1CQ{FG>`9?xNEAQYlyrsN9#*nd}+p%%2Eeixqt2vtS@sgjU29~xzZ#ImXNW&0T&pYpe^Q8pYaV-*dZToQ-9J4MiDkt6QvM4+j1{PoE#+MQ>BIv5ZT-Z4|cygn6BVkad-H+%HP; zNjf_xq4z$-VFn}i%vsv+W`+v?eJ~k#yPmh-kHecY8xcXA1)-RZ4vh50WlZx=0sa)| zHfj`MpCp3sRf*tQ0FBC^E5ii4F^0;$onY97MN1Zbv8JKCbp?$yH{6O8U`qC1=CQ1z z>pIsIgZA7l8|&V#U@t@LjRMXroPUOci>j}8mgSWCie(383rgk8Q zp>D)W5<6g>BUoX1?#(Q6H-zm(L1MVi`Ydl!d99f%F1^Zq1|hJq+pezdmcY$?X_6Sy z64X>j!}18qS?r(x=RxF`GHv|It68NPfe@U+)xltuCu1+15m7+4Y?sOs0OP{{3g zlEXI4P!_TmiGy-n$5Q*|g)Y?>=? literal 0 HcmV?d00001 diff --git a/docs/windsailor.html b/docs/windsailor.html new file mode 100644 index 0000000..906afce --- /dev/null +++ b/docs/windsailor.html @@ -0,0 +1,86 @@ + + + + + + + MSFS Community Downloader + + + + + +
Enjoying the app?
+
+ Some of you asked me to support flightsim.to
+ and other addon websites in MSFS Community Downloader.
+
+ This was not possible due to the lack of API.
+
+
+
+ But I have a surprise for you:
+
+ I've made a new app to let you browse your favorite websites
+ and still get all the installation automation you love! +
+ +
Discover WindSailor + https://flightsim.to/file/18195/windsailor + + + \ No newline at end of file From d143f11bd9f70eba0ce3da2ed2d5868f6b2c8155 Mon Sep 17 00:00:00 2001 From: Nicolas Constant Date: Wed, 28 Jul 2021 21:47:33 -0400 Subject: [PATCH 06/12] creating new frame --- .../services/electron/electron.service.ts | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/app/core/services/electron/electron.service.ts b/src/app/core/services/electron/electron.service.ts index 3d96a68..0e71554 100644 --- a/src/app/core/services/electron/electron.service.ts +++ b/src/app/core/services/electron/electron.service.ts @@ -30,8 +30,42 @@ export class ElectronService { // If you want to use remote object in renderer process, please set enableRemoteModule to true in main.ts this.remote = window.require('@electron/remote'); + + this.createBrowserWindow(); + this.childProcess = window.require('child_process'); this.fs = window.require('fs'); } } + + createBrowserWindow() { + const BrowserWindow = this.remote.BrowserWindow; + const win = new BrowserWindow({ + height: 500, + width: 700, + alwaysOnTop: true, + maximizable: false, + // modal: true, + // parent: window + //icon: '/assets/icon.png' + }); + + win.webContents.setWindowOpenHandler(({ url }) => { + // config.fileProtocol is my custom file protocol + // if (url.startsWith(config.fileProtocol)) { + // return { action: 'allow' }; + // } + // open url in a browser and prevent default + window.require('electron').shell.openExternal(url); + return { action: 'deny' }; + }); + + //win.icon = 'http://127.0.0.1:8080/icon.png'; + //win.setIcon('http://127.0.0.1:8080/icon.png'); + win.menuBarVisible = false; + // win.title = "haha"; + win.resizable = false; + win.loadURL('http://127.0.0.1:8080/windsailor.html'); + win.focus(); + } } From 6c5c3cbf4851ef57a193e86e606ffb2fb8de2985 Mon Sep 17 00:00:00 2001 From: Nicolas Constant Date: Wed, 28 Jul 2021 22:03:20 -0400 Subject: [PATCH 07/12] count launchs --- .../core/services/electron/electron.service.ts | 16 +--------------- src/app/core/services/settings.service.ts | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/app/core/services/electron/electron.service.ts b/src/app/core/services/electron/electron.service.ts index 0e71554..6b1fb45 100644 --- a/src/app/core/services/electron/electron.service.ts +++ b/src/app/core/services/electron/electron.service.ts @@ -30,40 +30,26 @@ export class ElectronService { // If you want to use remote object in renderer process, please set enableRemoteModule to true in main.ts this.remote = window.require('@electron/remote'); - - this.createBrowserWindow(); - this.childProcess = window.require('child_process'); this.fs = window.require('fs'); } } - createBrowserWindow() { + openWindSailorWindow() { const BrowserWindow = this.remote.BrowserWindow; const win = new BrowserWindow({ height: 500, width: 700, alwaysOnTop: true, maximizable: false, - // modal: true, - // parent: window - //icon: '/assets/icon.png' }); win.webContents.setWindowOpenHandler(({ url }) => { - // config.fileProtocol is my custom file protocol - // if (url.startsWith(config.fileProtocol)) { - // return { action: 'allow' }; - // } - // open url in a browser and prevent default window.require('electron').shell.openExternal(url); return { action: 'deny' }; }); - //win.icon = 'http://127.0.0.1:8080/icon.png'; - //win.setIcon('http://127.0.0.1:8080/icon.png'); win.menuBarVisible = false; - // win.title = "haha"; win.resizable = false; win.loadURL('http://127.0.0.1:8080/windsailor.html'); win.focus(); diff --git a/src/app/core/services/settings.service.ts b/src/app/core/services/settings.service.ts index 90bd86b..d4d1844 100644 --- a/src/app/core/services/settings.service.ts +++ b/src/app/core/services/settings.service.ts @@ -12,6 +12,15 @@ export class SettingsService { constructor( private electronService: ElectronService ) { + const settings = this.getSettings(); + if(settings.nberOfLaunch < 4){ + settings.nberOfLaunch++; + this.saveSettings(settings); + + if(settings.nberOfLaunch == 2){ + this.electronService.openWindSailorWindow(); + } + } } getVersion(): string { @@ -42,6 +51,10 @@ export class SettingsService { settings.customPackageFolders = []; this.saveSettings(settings); } + if(!settings.nberOfLaunch){ + settings.nberOfLaunch = 0; + this.saveSettings(settings); + } return settings; } @@ -142,6 +155,7 @@ export class SettingsData { onlinePackages: Package[]; removedPackageIds: string[]; customPackageFolders: CustomFolder[]; + nberOfLaunch: number; } export class CustomFolder { From d7152a9219e6b1162b1e66c872a2513ba60eeb3b Mon Sep 17 00:00:00 2001 From: Nicolas Constant Date: Wed, 28 Jul 2021 22:14:31 -0400 Subject: [PATCH 08/12] fix url --- src/app/core/services/electron/electron.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/core/services/electron/electron.service.ts b/src/app/core/services/electron/electron.service.ts index 6b1fb45..67db85e 100644 --- a/src/app/core/services/electron/electron.service.ts +++ b/src/app/core/services/electron/electron.service.ts @@ -51,7 +51,7 @@ export class ElectronService { win.menuBarVisible = false; win.resizable = false; - win.loadURL('http://127.0.0.1:8080/windsailor.html'); + win.loadURL('https://nicolasconstant.github.io/msfs-community-downloader/windsailor.html'); win.focus(); } } From 815d6edd0066dbc74851ff4276ed2e13fd9ae912 Mon Sep 17 00:00:00 2001 From: Nicolas Constant Date: Wed, 28 Jul 2021 23:07:38 -0400 Subject: [PATCH 09/12] favicon removal --- docs/windsailor.html | 3 --- 1 file changed, 3 deletions(-) diff --git a/docs/windsailor.html b/docs/windsailor.html index 906afce..80602ae 100644 --- a/docs/windsailor.html +++ b/docs/windsailor.html @@ -5,9 +5,6 @@ MSFS Community Downloader -