Skip to content

Commit

Permalink
declare lockfile constant
Browse files Browse the repository at this point in the history
  • Loading branch information
ElinorW committed Jun 13, 2024
1 parent b98b705 commit 276fdef
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions vscode/microsoft-kiota/src/openApiTreeProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
KiotaOpenApiNode,
KiotaShowConfiguration,
KiotaShowResult,
LockFile,
ConfigurationFile,
PluginObjectProperties } from './kiotaInterop';
import { ExtensionSettings } from './extensionSettings';
import { treeViewId } from './constants';
Expand All @@ -31,18 +31,18 @@ export class OpenApiTreeProvider implements vscode.TreeDataProvider<OpenApiTreeN

}
private _lockFilePath?: string;
private _lockFile?: LockFile | Partial<LockFile> = {};
private _lockFile?: ConfigurationFile | Partial<ConfigurationFile> = {};
public get isLockFileLoaded(): boolean {
return !!this._lockFile;
}
public async loadLockFile(path: string, clientOrPluginName?: string): Promise<void> {
this.closeDescription(false);
this._lockFilePath = path;
const lockFileData = await vscode.workspace.fs.readFile(vscode.Uri.file(path));
let parsedLockFile = JSON.parse(lockFileData.toString()) as LockFile;
let parsedLockFile = JSON.parse(lockFileData.toString()) as ConfigurationFile;

if (clientOrPluginName) {
let filteredData: Partial<LockFile> = { version: parsedLockFile.version };
let filteredData: Partial<ConfigurationFile> = { version: parsedLockFile.version };

if (parsedLockFile.clients && parsedLockFile.clients[clientOrPluginName]) {
filteredData.clients = {
Expand All @@ -56,7 +56,7 @@ export class OpenApiTreeProvider implements vscode.TreeDataProvider<OpenApiTreeN
};
}

parsedLockFile = filteredData as LockFile;
parsedLockFile = filteredData as ConfigurationFile;
}

this._lockFile = parsedLockFile;
Expand All @@ -80,14 +80,14 @@ export class OpenApiTreeProvider implements vscode.TreeDataProvider<OpenApiTreeN
}
public async loadEditPaths(clientOrPluginKey: string, clientObject: ClientOrPluginProperties): Promise<void> {
this.closeDescription(false);
this._lockFile = { version: '1.0.0', clients: {}, plugins: {} };
const newLockFile: ConfigurationFile = { version: '1.0.0', clients: {}, plugins: {} };

if ((clientObject as ClientObjectProperties).clientNamespaceName) {
this._lockFile.clients![clientOrPluginKey] = clientObject as ClientObjectProperties;
newLockFile.clients![clientOrPluginKey] = clientObject as ClientObjectProperties;
} else {
this._lockFile.plugins![clientOrPluginKey] = clientObject as PluginObjectProperties;
newLockFile.plugins![clientOrPluginKey] = clientObject as PluginObjectProperties;
}

this._lockFile = newLockFile;
if (clientObject.descriptionLocation) {
this._descriptionUrl = clientObject.descriptionLocation;
this.includeFilters = clientObject.includePatterns;
Expand Down

0 comments on commit 276fdef

Please sign in to comment.