Skip to content

Commit

Permalink
determine output path from project path
Browse files Browse the repository at this point in the history
  • Loading branch information
thewahome committed Nov 12, 2024
1 parent 5922724 commit 46d1df1
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions vscode/microsoft-kiota/src/utilities/deep-linking.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as fs from 'fs';

import { GenerateState } from "../modules/steps/generateSteps";
import { KiotaGenerationLanguage, KiotaPluginType } from "../types/enums";
import { allGenerationLanguagesToString, getSanitizedString, parseGenerationLanguage, parsePluginType } from "../util";
Expand Down Expand Up @@ -34,7 +36,7 @@ export function transformToGenerationConfig(deepLinkParams: Partial<IntegrationP
}
generationConfig.outputPath =
(deepLinkParams.source && deepLinkParams.source?.toLowerCase() === 'ttk')
? createTemporaryFolder()
? determineOutputPath(deepLinkParams)
: undefined;
}
return generationConfig;
Expand All @@ -49,7 +51,8 @@ export interface IntegrationParams {
source: string;
ttkContext: {
lastCommand: string;
}
},
projectPath: string;
};

export function validateDeepLinkQueryParams(queryParameters: Partial<IntegrationParams>):
Expand All @@ -59,6 +62,8 @@ export function validateDeepLinkQueryParams(queryParameters: Partial<Integration
const descriptionurl = queryParameters["descriptionurl"];
const name = getSanitizedString(queryParameters["name"]);
const source = getSanitizedString(queryParameters["source"]);
const projectPath = queryParameters["projectPath"];

let lowercasedKind: string = queryParameters["kind"]?.toLowerCase() ?? "";
let validKind: string | undefined = ["plugin", "client"].indexOf(lowercasedKind) > -1 ? lowercasedKind : undefined;
if (!validKind) {
Expand Down Expand Up @@ -105,12 +110,20 @@ export function validateDeepLinkQueryParams(queryParameters: Partial<Integration

validQueryParams = {
descriptionurl: descriptionurl,
name: name,
name,
kind: validKind,
type: providedType,
language: givenLanguage,
source: source,
ttkContext: queryParameters.ttkContext ? queryParameters.ttkContext : undefined
source,
ttkContext: queryParameters.ttkContext ? queryParameters.ttkContext : undefined,
projectPath: projectPath ? projectPath : undefined
};
return [validQueryParams, errormsg];
}

function determineOutputPath(deepLinkParams: Partial<IntegrationParams>): string | undefined {
if (deepLinkParams.projectPath && fs.existsSync(deepLinkParams.projectPath)) {
return deepLinkParams.projectPath;
}
return createTemporaryFolder();
}

0 comments on commit 46d1df1

Please sign in to comment.