Skip to content

Commit

Permalink
Merge pull request #89 from DSaladinCH/hotfix/app-packages-not-loading
Browse files Browse the repository at this point in the history
Hotfix/app packages not loading
  • Loading branch information
DominicSaladin committed Jul 25, 2023
2 parents 834db99 + cc70c1f commit d68c54e
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 15 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Change Log
All versions of AL Object Helper will be documented in this file.

## [2.3.7] - 2023-07-25
### Fix
- App packages not loading if configuration is a string and not a array

## [2.3.6] - 2023-07-21
### Fix
- Version Comparing when checking app packages
Expand Down Expand Up @@ -255,6 +259,7 @@ All versions of AL Object Helper will be documented in this file.
## [1.0.0] - 2020-06-24
- Initial release

[2.3.7]: https://github.com/DSaladinCH/al-object-helper/compare/2.3.6...2.3.7
[2.3.6]: https://github.com/DSaladinCH/al-object-helper/compare/2.3.5...2.3.6
[2.3.5]: https://github.com/DSaladinCH/al-object-helper/compare/2.3.4...2.3.5
[2.3.4]: https://github.com/DSaladinCH/al-object-helper/compare/2.3.3...2.3.4
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"name": "Dominic Saladin"
},
"license": "MIT",
"version": "2.3.6",
"version": "2.3.7",
"icon": "Images/ALObjectHelper_Small.png",
"engines": {
"vscode": "^1.65.0"
Expand Down
3 changes: 3 additions & 0 deletions src/Objects/Misc/ALInterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import { ALApp, ALObject, ObjectType } from "../../internal";

export class ALInterface extends ALObject {
constructor(objectPath: string, objectID: string, objectName: string, alApp: ALApp) {
if (!objectID)
objectID = "";

super(objectPath, ObjectType.Interface, objectID, objectName, alApp);
}

Expand Down
38 changes: 24 additions & 14 deletions src/Reader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,18 @@ export class Reader {
let workspaceFolderconfig = vscode.workspace.getConfiguration('al', wf.uri);
let packageCache = workspaceFolderconfig.get<string>('packageCachePath');

if (packageCache)
if (!reader.alPackageCachePaths.includes(path.resolve(wf.uri.fsPath, packageCache[0])))
reader.alPackageCachePaths.push(path.resolve(wf.uri.fsPath, packageCache[0]));
if (packageCache) {
let newPath = "";
if (typeof packageCache === "string")
newPath = path.resolve(wf.uri.fsPath, packageCache);
else if (Array.isArray(packageCache))
newPath = path.resolve(wf.uri.fsPath, packageCache[0]);
else
return;

if (!reader.alPackageCachePaths.includes(newPath))
reader.alPackageCachePaths.push(newPath);
}
});
}
}
Expand All @@ -78,7 +87,7 @@ export class Reader {
if (!this.alPackageCachePaths || this.alPackageCachePaths.length == 0)
return;

this.alPackageCachePaths.forEach(async apcp => {
for (const apcp of this.alPackageCachePaths) {
if (!path.isAbsolute(apcp)) {
for (let index = 0; index < this.alApps.filter(app => app.appType === AppType.local).length; index++) {
const alApp = this.alApps.filter(app => app.appType === AppType.local)[index];
Expand All @@ -88,14 +97,14 @@ export class Reader {
else {
await this.searchAppPackages(apcp);
}
if (this.printDebug) { this.outputChannel.appendLine(`Found ${this.alApps.filter(alApp => alApp.appType === AppType.appPackage).length} app files in all projects`); }
await Promise.all([
this.readLocalApps(this.alApps.filter(app => app.appType === AppType.local)),
this.readAppPackages(this.alApps.filter(app => app.appType === AppType.appPackage && app.appChanged))
]);
});
}

if (this.printDebug) { this.outputChannel.appendLine(`Found ${this.alApps.filter(alApp => alApp.appType === AppType.appPackage).length} app files in all projects`); }

await Promise.all([
this.readLocalApps(this.alApps.filter(app => app.appType === AppType.local)),
this.readAppPackages(this.alApps.filter(app => app.appType === AppType.appPackage && app.appChanged))
]);
}

addLocalFolderAsApp(folderPath: string): ALApp | null {
Expand All @@ -115,7 +124,8 @@ export class Reader {
if (supportedVersion === undefined)
supportedVersion = json.platform;

this.alApplicationVersion = supportedVersion;
if (this.alApplicationVersion == "")
this.alApplicationVersion = supportedVersion;

const alApp = new ALApp(AppType.local, json.id, json.name, json.publisher, json.version, supportedVersion, json.runtime, folderPath, new Date(), showMyCode);
this.alApps.push(alApp);
Expand Down Expand Up @@ -281,7 +291,7 @@ export class Reader {
var hasCorrectMajorPackage: boolean = false;
var alAppToUse: ALApp;
alApps.forEach(alApp => {
if (compareVersions(alApp.appSupportedVersion, this.alApplicationVersion) > 0) {
if (compareVersions(alApp.appSupportedVersion, this.alApplicationVersion) < 0) {
this.alApps.splice(this.alApps.indexOf(alApp), 1);
return;
}
Expand Down

0 comments on commit d68c54e

Please sign in to comment.