Skip to content

Commit

Permalink
fix(vscode): Keep host.json when converting to NuGet based project (#…
Browse files Browse the repository at this point in the history
…4534)

Update host.json when converting to NuGet based project
  • Loading branch information
ccastrotrejo authored Apr 3, 2024
1 parent e5b3206 commit 0193161
Showing 1 changed file with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { connectionsFileName, funcIgnoreFileName, funcVersionSetting, hostFileName, localSettingsFileName } from '../../../constants';
import {
connectionsFileName,
funcIgnoreFileName,
funcVersionSetting,
hostFileName,
localSettingsFileName,
workflowFileName,
} from '../../../constants';
import { localize } from '../../../localize';
import { initProjectForVSCode } from '../../commands/initProjectForVSCode/initProjectForVSCode';
import { DotnetTemplateProvider } from '../../templates/dotnet/DotnetTemplateProvider';
Expand Down Expand Up @@ -191,7 +198,7 @@ async function updateBuildFile(context: IActionContext, target: vscode.Uri, dotn
}

async function deleteBundleProjectFiles(target: vscode.Uri): Promise<void> {
const filesTobeDeleted: string[] = [hostFileName, funcIgnoreFileName];
const filesTobeDeleted: string[] = [funcIgnoreFileName];
for (const fileName of filesTobeDeleted) {
if (await fse.pathExists(path.join(target.fsPath, fileName))) {
await deleteFile(path.join(target.fsPath, fileName));
Expand All @@ -204,7 +211,7 @@ async function deleteFile(file: string): Promise<void> {
}

async function renameBundleProjectFiles(target: vscode.Uri): Promise<void> {
const filesToBeRenamed: string[] = [localSettingsFileName];
const filesToBeRenamed: string[] = [hostFileName, localSettingsFileName];
for (const fileName of filesToBeRenamed) {
if (await fse.pathExists(path.join(target.fsPath, fileName))) {
await renameFile(path.join(target.fsPath, fileName), path.join(target.fsPath, fileName + '-copy'));
Expand All @@ -217,7 +224,7 @@ async function renameFile(fileName: string, newFileName: string): Promise<void>
}

async function copyBundleProjectFiles(target: vscode.Uri): Promise<void> {
const filesToBeCopied: string[] = [localSettingsFileName];
const filesToBeCopied: string[] = [hostFileName, localSettingsFileName];
for (const fileName of filesToBeCopied) {
if (
(await fse.pathExists(path.join(target.fsPath, fileName))) &&
Expand All @@ -229,8 +236,8 @@ async function copyBundleProjectFiles(target: vscode.Uri): Promise<void> {
}
}

async function getArtifactNamesFromProject(target: vscode.Uri): Promise<{ [key: string]: string[] }> {
const artifactDict: { [key: string]: string[] } = {
async function getArtifactNamesFromProject(target: vscode.Uri): Promise<Record<string, string[]>> {
const artifactDict: Record<string, string[]> = {
workflows: [],
connections: [],
artifacts: [],
Expand All @@ -256,7 +263,7 @@ async function getArtifactNamesFromProject(target: vscode.Uri): Promise<{ [key:
const filePath: string = path.join(target.fsPath, file);
if (await (await fse.stat(filePath)).isDirectory()) {
const workflowFiles: string[] = await fse.readdir(filePath);
if (workflowFiles.length == 1 && workflowFiles[0] == 'workflow.json') {
if (workflowFiles.length == 1 && workflowFiles[0] == workflowFileName) {
artifactDict['workflows'].push(file);
}
}
Expand Down

0 comments on commit 0193161

Please sign in to comment.