diff --git a/docs/icon.png b/docs/icon.png
new file mode 100644
index 0000000..8484732
Binary files /dev/null and b/docs/icon.png differ
diff --git a/docs/windsailor.html b/docs/windsailor.html
new file mode 100644
index 0000000..80602ae
--- /dev/null
+++ b/docs/windsailor.html
@@ -0,0 +1,83 @@
+
+
+
+
+
+
+ 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
diff --git a/main.ts b/main.ts
index 20a8dab..30df230 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/package.json b/package.json
index 4030a3e..3ba985b 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "msfs-community-downloader",
- "version": "1.0.0",
+ "version": "1.1.0",
"description": "MSFS addin downloader client",
"homepage": "https://github.com/nicolasconstant/msfs-community-downloader",
"author": {
diff --git a/src/app/core/services/domain.service.ts b/src/app/core/services/domain.service.ts
index f577d4d..e47fbc5 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;
@@ -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);
@@ -124,44 +125,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 +192,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 +344,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/electron/electron.service.ts b/src/app/core/services/electron/electron.service.ts
index 3d96a68..c1e527c 100644
--- a/src/app/core/services/electron/electron.service.ts
+++ b/src/app/core/services/electron/electron.service.ts
@@ -34,4 +34,24 @@ export class ElectronService {
this.fs = window.require('fs');
}
}
+
+ openWindSailorWindow(): void {
+ const BrowserWindow = this.remote.BrowserWindow;
+ const win = new BrowserWindow({
+ height: 500,
+ width: 700,
+ alwaysOnTop: true,
+ maximizable: false,
+ });
+
+ win.webContents.setWindowOpenHandler(({ url }) => {
+ window.require('electron').shell.openExternal(url);
+ return { action: 'deny' };
+ });
+
+ win.menuBarVisible = false;
+ win.resizable = false;
+ win.loadURL('https://nicolasconstant.github.io/msfs-community-downloader/windsailor.html');
+ win.focus();
+ }
}
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);
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/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 {
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 @@