Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as path from 'path';
import * as vscode from 'vscode';
import { beforeEach, describe, expect, it, type Mock, vi } from 'vitest';
import { ext } from '../../../extensionVariables';
import { isCodefulProject } from '../../utils/codeful';
import { hasCodefulWorkflowSetting } from '../../utils/codeful';
import { getLogicAppWithoutCustomCode, getWorkspaceRoot } from '../../utils/workspace';
import { tryGetLogicAppProjectRoot } from '../../utils/verifyIsProject';
import { cloudToLocal } from '../cloudToLocal/cloudToLocal';
Expand Down Expand Up @@ -47,7 +47,7 @@ vi.mock('../../utils/workspace', () => ({
}));

vi.mock('../../utils/codeful', () => ({
isCodefulProject: vi.fn(),
hasCodefulWorkflowSetting: vi.fn(),
}));

vi.mock('../../utils/verifyIsProject', () => ({
Expand All @@ -70,7 +70,7 @@ describe('workspace webview command wrappers', () => {
(vscode.workspace.fs.readFile as Mock).mockReset();
(getWorkspaceRoot as Mock).mockResolvedValue(workspaceRoot);
(tryGetLogicAppProjectRoot as Mock).mockResolvedValue(logicAppRoot);
(isCodefulProject as Mock).mockResolvedValue(false);
(hasCodefulWorkflowSetting as Mock).mockResolvedValue(false);
(getLogicAppWithoutCustomCode as Mock).mockResolvedValue([]);
});

Expand Down Expand Up @@ -192,12 +192,12 @@ describe('workspace webview command wrappers', () => {
} as vscode.WorkspaceFolder;
(vscode.workspace as any).workspaceFolders = [folder];
(tryGetLogicAppProjectRoot as Mock).mockResolvedValue(projectRoot);
(isCodefulProject as Mock).mockResolvedValue(true);
(hasCodefulWorkflowSetting as Mock).mockResolvedValue(true);

await createWorkflow(context);

expect(tryGetLogicAppProjectRoot).toHaveBeenCalledWith(context, workspaceRoot, true);
expect(isCodefulProject).toHaveBeenCalledWith(projectRoot);
expect(hasCodefulWorkflowSetting).toHaveBeenCalledWith(projectRoot);

const config = getLastWebviewConfig();
expect(config).toMatchObject({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ vi.mock('../../utils/vsCodeConfig/settings', () => ({
}));

vi.mock('../../utils/codeful', () => ({
isCodefulProject: vi.fn(),
hasCodefulWorkflowSetting: vi.fn(),
}));

vi.mock('../buildCustomCodeFunctionsProject', () => ({
Expand All @@ -77,7 +77,7 @@ import { getProjFiles } from '../../utils/dotnet/dotnet';
import { getFuncPortFromTaskOrProject, runningFuncTaskMap } from '../../utils/funcCoreTools/funcHostTask';
import { executeIfNotActive } from '../../utils/taskUtils';
import { delay } from '../../utils/delay';
import { isCodefulProject } from '../../utils/codeful';
import { hasCodefulWorkflowSetting } from '../../utils/codeful';
import { tryGetLogicAppProjectRoot } from '../../utils/verifyIsProject';
import { getWorkspaceSetting } from '../../utils/vsCodeConfig/settings';
import { tryBuildCustomCodeFunctionsProject } from '../buildCustomCodeFunctionsProject';
Expand Down Expand Up @@ -121,7 +121,7 @@ describe('pickFuncProcessInternal', () => {
context.errorHandling = {};
runningFuncTaskMap.clear();
(preDebugValidate as any).mockResolvedValue(true);
(isCodefulProject as any).mockResolvedValue(true);
(hasCodefulWorkflowSetting as any).mockResolvedValue(true);
(tryBuildCustomCodeFunctionsProject as any).mockResolvedValue(true);
(publishCodefulProject as any).mockResolvedValue(undefined);
(delay as any).mockResolvedValue(undefined);
Expand Down Expand Up @@ -158,14 +158,14 @@ describe('pickFuncProcessInternal', () => {
)
).rejects.toThrow('Failed to find "func: host start" task.');

expect(isCodefulProject).toHaveBeenCalledWith(projectPath);
expect(hasCodefulWorkflowSetting).toHaveBeenCalledWith(projectPath);
expect(tryBuildCustomCodeFunctionsProject).not.toHaveBeenCalled();
expect(publishCodefulProject).toHaveBeenCalledWith(context, workspaceFolder.uri, { skipIfBuildPopulatesCodeful: true });
expect(executeIfNotActive).not.toHaveBeenCalled();
});

it('custom code project skips codeful publish', async () => {
(isCodefulProject as any).mockResolvedValue(false);
(hasCodefulWorkflowSetting as any).mockResolvedValue(false);
(vscode.tasks.fetchTasks as any).mockResolvedValue([]);

await expect(
Expand All @@ -177,7 +177,7 @@ describe('pickFuncProcessInternal', () => {
)
).rejects.toThrow('Failed to find "func: host start" task.');

expect(isCodefulProject).toHaveBeenCalledWith(projectPath);
expect(hasCodefulWorkflowSetting).toHaveBeenCalledWith(projectPath);
expect(tryBuildCustomCodeFunctionsProject).toHaveBeenCalledWith(context, workspaceFolder.uri);
expect(publishCodefulProject).not.toHaveBeenCalled();
expect(executeIfNotActive).not.toHaveBeenCalled();
Expand Down Expand Up @@ -210,7 +210,7 @@ describe('pickFuncProcessInternal', () => {

it('waits for a previous func task to stop before custom code build', async () => {
const events: string[] = [];
(isCodefulProject as any).mockResolvedValue(false);
(hasCodefulWorkflowSetting as any).mockResolvedValue(false);
runningFuncTaskMap.set(workspaceFolder, { startTime: Date.now(), processId: 5678 });
(delay as any).mockImplementationOnce(async () => {
expect(tryBuildCustomCodeFunctionsProject).not.toHaveBeenCalled();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as vscode from 'vscode';
import { beforeEach, describe, expect, it, type Mock, vi } from 'vitest';
import { ext } from '../../../extensionVariables';
import { isCodefulProject } from '../../utils/codeful';
import { hasCodefulWorkflowSetting } from '../../utils/codeful';
import { getWorkspaceRoot } from '../../utils/workspace';
import { publishCodefulProject } from '../publishCodefulProject';

Expand All @@ -15,7 +15,7 @@ vi.mock('../../utils/workspace', () => ({
}));

vi.mock('../../utils/codeful', () => ({
isCodefulProject: vi.fn(),
hasCodefulWorkflowSetting: vi.fn(),
inspectCodefulCsprojBuildHooks: vi.fn(),
invalidateCodefulSdkCacheIfNeeded: vi.fn(),
}));
Expand Down Expand Up @@ -44,7 +44,7 @@ describe('publishCodefulProject', () => {
}),
};
(getWorkspaceRoot as Mock).mockResolvedValue(projectPath);
(isCodefulProject as Mock).mockResolvedValue(true);
(hasCodefulWorkflowSetting as Mock).mockResolvedValue(true);
(invalidateCodefulSdkCacheIfNeeded as Mock).mockResolvedValue(false);
(inspectCodefulCsprojBuildHooks as Mock).mockResolvedValue({
copyAfterTargets: 'Build;Publish',
Expand All @@ -63,11 +63,11 @@ describe('publishCodefulProject', () => {
errorMessage: 'No project path found to publish custom code functions project.',
});
expect(ext.outputChannel.appendLog).toHaveBeenCalledWith('No project path found to publish custom code functions project.');
expect(isCodefulProject).not.toHaveBeenCalled();
expect(hasCodefulWorkflowSetting).not.toHaveBeenCalled();
});

it('skips publishing when the selected path is not codeful', async () => {
(isCodefulProject as Mock).mockResolvedValue(false);
(hasCodefulWorkflowSetting as Mock).mockResolvedValue(false);

await publishCodefulProject(context, { fsPath: projectPath } as vscode.Uri);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
testsDirectoryName,
vscodeFolderName,
workerRuntimeKey,
workflowCodefulEnabled,
workflowCodefulEnabledKey,
workflowFileName,
} from '../../../../constants';
import { localize } from '../../../../localize';
Expand Down Expand Up @@ -106,7 +106,6 @@ export async function createLogicAppAndWorkflow(

context.telemetry.properties.logicAppType = logicAppType || 'logicApp';
context.telemetry.properties.workflowType = workflowType || 'unknown';
context.telemetry.properties.isCodefulWorkflow = String(logicAppType === ProjectType.codeful);

await fse.ensureDir(logicAppFolderPath);
if (logicAppType === ProjectType.codeful) {
Expand Down Expand Up @@ -230,10 +229,8 @@ export async function createLocalConfigurationFiles(
localSettingsJson.Values[azureWebJobsFeatureFlagsKey] = multiLanguageWorkerSetting;
}

// TODO(aeldridge): Update to point to codeful private bundle once it's published.
if (logicAppType === ProjectType.codeful) {
localSettingsJson.Values[workflowCodefulEnabled] = 'true';
localSettingsJson.Values['AzureFunctionsJobHost__extensionBundle__id'] = 'Microsoft.Azure.Functions.ExtensionBundle.Workflows';
localSettingsJson.Values[workflowCodefulEnabledKey] = 'true';
}

const hostJsonPath: string = path.join(logicAppFolderPath, hostFileName);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ProjectType } from '@microsoft/vscode-extension-logic-apps';
import * as vscode from 'vscode';
import { beforeEach, describe, expect, it, type Mock, vi } from 'vitest';
import { isCodefulProject } from '../../../utils/codeful';
import { hasCodefulWorkflowSetting } from '../../../utils/codeful';
import { addLocalFuncTelemetry } from '../../../utils/funcCoreTools/funcVersion';
import { createLogicAppAndWorkflow } from '../../createNewCodeProject/CodeProjectBase/CreateLogicAppWorkspace';
import { createLogicAppWorkflow } from '../createLogicAppWorkflow';
Expand All @@ -16,7 +16,7 @@ vi.mock('../../../utils/funcCoreTools/funcVersion', () => ({
}));

vi.mock('../../../utils/codeful', () => ({
isCodefulProject: vi.fn(),
hasCodefulWorkflowSetting: vi.fn(),
}));

vi.mock('../../createNewCodeProject/CodeProjectBase/CreateLogicAppWorkspace', () => ({
Expand All @@ -32,7 +32,7 @@ describe('createLogicAppWorkflow', () => {
vi.clearAllMocks();
context = { telemetry: { properties: {}, measurements: {} } };
(vscode.workspace as any).workspaceFile = { fsPath: workspaceFilePath };
(isCodefulProject as Mock).mockResolvedValue(true);
(hasCodefulWorkflowSetting as Mock).mockResolvedValue(true);
});

it('creates a workflow in the open workspace and infers codeful project metadata', async () => {
Expand All @@ -45,7 +45,7 @@ describe('createLogicAppWorkflow', () => {
await createLogicAppWorkflow(context, options, logicAppFolderPath);

expect(addLocalFuncTelemetry).toHaveBeenCalledWith(context);
expect(isCodefulProject).toHaveBeenCalledWith(logicAppFolderPath);
expect(hasCodefulWorkflowSetting).toHaveBeenCalledWith(logicAppFolderPath);
expect(options).toMatchObject({
logicAppType: ProjectType.codeful,
workspaceFilePath,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ vi.mock('../../shared/workspaceWebviewCommandHandler', () => ({
}));

vi.mock('../../../utils/codeful', () => ({
isCodefulProject: vi.fn(),
hasCodefulWorkflowSetting: vi.fn(),
}));

vi.mock('../../../utils/verifyIsProject', () => ({
Expand All @@ -28,7 +28,7 @@ vi.mock('../createLogicAppWorkflow', () => ({
}));

import { createWorkspaceWebviewCommandHandler } from '../../shared/workspaceWebviewCommandHandler';
import { isCodefulProject } from '../../../utils/codeful';
import { hasCodefulWorkflowSetting } from '../../../utils/codeful';
import { tryGetLogicAppProjectRoot } from '../../../utils/verifyIsProject';
import { createLogicAppWorkflow } from '../createLogicAppWorkflow';
import { createWorkflow } from '../createWorkflow';
Expand All @@ -45,7 +45,7 @@ describe('createWorkflow', () => {
vi.clearAllMocks();
(vscode.workspace as any).workspaceFolders = undefined;
(vscode.workspace.getWorkspaceFolder as any) = vi.fn();
vi.mocked(isCodefulProject).mockResolvedValue(false);
vi.mocked(hasCodefulWorkflowSetting).mockResolvedValue(false);
});

describe('project collection and selection', () => {
Expand All @@ -62,7 +62,7 @@ describe('createWorkflow', () => {
}
return undefined;
});
vi.mocked(isCodefulProject).mockImplementation(async (projectPath) => {
vi.mocked(hasCodefulWorkflowSetting).mockImplementation(async (projectPath) => {
return projectPath === 'D:\\workspace\\ProjectB';
});

Expand All @@ -84,7 +84,7 @@ describe('createWorkflow', () => {
const folder = { name: 'OnlyProject', uri: { fsPath: 'D:\\workspace\\OnlyProject' }, index: 0 } as vscode.WorkspaceFolder;
(vscode.workspace as any).workspaceFolders = [folder];
vi.mocked(tryGetLogicAppProjectRoot).mockResolvedValue('D:\\workspace\\OnlyProject');
vi.mocked(isCodefulProject).mockResolvedValue(true);
vi.mocked(hasCodefulWorkflowSetting).mockResolvedValue(true);

await createWorkflow(context);

Expand Down Expand Up @@ -142,7 +142,7 @@ describe('createWorkflow', () => {
}
return undefined;
});
vi.mocked(isCodefulProject).mockResolvedValue(true);
vi.mocked(hasCodefulWorkflowSetting).mockResolvedValue(true);

await createWorkflow(context, clickedUri);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { addLocalFuncTelemetry } from '../../utils/funcCoreTools/funcVersion';
import * as vscode from 'vscode';
import { createLogicAppAndWorkflow } from '../createNewCodeProject/CodeProjectBase/CreateLogicAppWorkspace';
import { localize } from '../../../localize';
import { isCodefulProject } from '../../utils/codeful';
import { hasCodefulWorkflowSetting } from '../../utils/codeful';

export async function createLogicAppWorkflow(context: IActionContext, options: any, logicAppFolderPath: string) {
addLocalFuncTelemetry(context);
Expand All @@ -13,7 +13,7 @@ export async function createLogicAppWorkflow(context: IActionContext, options: a

// If logicAppType is not set in options, check if this is a codeful project
if (!webviewProjectContext.logicAppType) {
const isCodeful = await isCodefulProject(logicAppFolderPath);
const isCodeful = await hasCodefulWorkflowSetting(logicAppFolderPath);
if (isCodeful) {
webviewProjectContext.logicAppType = ProjectType.codeful;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { createWorkspaceWebviewCommandHandler } from '../shared/workspaceWebview
import { localize } from '../../../localize';
import * as vscode from 'vscode';
import { createLogicAppWorkflow } from './createLogicAppWorkflow';
import { isCodefulProject } from '../../utils/codeful';
import { hasCodefulWorkflowSetting } from '../../utils/codeful';
import { tryGetLogicAppProjectRoot } from '../../utils/verifyIsProject';
import { getWorkflowsInLocalProject } from '../../utils/codeless/common';
import * as path from 'path';
Expand Down Expand Up @@ -106,7 +106,7 @@ async function collectAvailableProjects(context: IActionContext): Promise<Availa
for (const folder of vscode.workspace.workspaceFolders) {
const projectRoot = await tryGetLogicAppProjectRoot(context, folder.uri.fsPath, true);
if (projectRoot) {
const isCodeful = await isCodefulProject(projectRoot);
const isCodeful = await hasCodefulWorkflowSetting(projectRoot);
const workflows = await getWorkflowsInLocalProject(projectRoot);
projects.push({
name: path.basename(projectRoot.replace(/\\/g, '/')),
Expand Down
12 changes: 4 additions & 8 deletions apps/vs-code-designer/src/app/commands/deploy/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ import { uploadAppSettings } from '../appSettings/uploadAppSettings';
import { isNullOrUndefined, resolveConnectionsReferences } from '@microsoft/logic-apps-shared';
import { tryBuildCustomCodeFunctionsProject } from '../buildCustomCodeFunctionsProject';
import { publishCodefulProject } from '../publishCodefulProject';
import { isCodefulProject } from '../../utils/codeful';
import { hasCodefulWorkflowSetting } from '../../utils/codeful';

export async function deployProductionSlot(
context: IActionContext,
Expand Down Expand Up @@ -103,19 +103,15 @@ async function deploy(
if (!isNullOrUndefined(workspaceFolder)) {
const logicAppNode = workspaceFolder.uri;

// Check if this is a codeful project and build/publish if needed
const isCodeful = await isCodefulProject(logicAppNode.fsPath);
const isCodeful = await hasCodefulWorkflowSetting(logicAppNode.fsPath);
if (isCodeful) {
context.telemetry.properties.isCodefulProject = 'true';
ext.outputChannel.appendLog(localize('buildingCodefulProject', 'Building and publishing codeful Logic App project...'));

// Build the codeful project
await publishCodefulProject(actionContext, logicAppNode);
ext.outputChannel.appendLog(localize('codefulProjectPublished', 'Codeful project built and published successfully.'));
} else {
// For codeless projects, build custom code functions if they exist
const customFolderExists = await fse.pathExists(path.join(logicAppNode.fsPath, libDirectory, customDirectory));
if (customFolderExists) {
const customCodeFolderExists = await fse.pathExists(path.join(logicAppNode.fsPath, libDirectory, customDirectory));
if (customCodeFolderExists) {
await tryBuildCustomCodeFunctionsProject(actionContext, logicAppNode);
}
}
Expand Down
4 changes: 2 additions & 2 deletions apps/vs-code-designer/src/app/commands/pickFuncProcess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import parser from 'yargs-parser';
import { tryBuildCustomCodeFunctionsProject } from './buildCustomCodeFunctionsProject';
import { publishCodefulProject } from './publishCodefulProject';
import { getProjFiles } from '../utils/dotnet/dotnet';
import { isCodefulProject } from '../utils/codeful';
import { hasCodefulWorkflowSetting } from '../utils/codeful';
import { delay } from '../utils/delay';

type OSAgnosticProcess = { command: string | undefined; pid: number | string };
Expand Down Expand Up @@ -94,7 +94,7 @@ export async function pickFuncProcessInternal(
// (e.g. GenerateFunctionMetadata failing on obj/Debug/net8/WorkerExtensions)
await waitForPrevFuncTaskToStop(workspaceFolder);

if (await isCodefulProject(projectPath)) {
if (await hasCodefulWorkflowSetting(projectPath)) {
// For codeful projects, the `func: host start` task chains a Debug `build` via dependsOn,
// and the modern codeful template hooks `CopyToCodefulFolder`/`ReplaceLanguageNetCore` to
// `AfterTargets="Build;Publish"`. Running an explicit Release `publish` first would just
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { ext } from '../../extensionVariables';
import { getWorkspaceRoot } from '../utils/workspace';
import * as vscode from 'vscode';
import { isNullOrUndefined } from '@microsoft/logic-apps-shared';
import { inspectCodefulCsprojBuildHooks, invalidateCodefulSdkCacheIfNeeded, isCodefulProject } from '../utils/codeful';
import { inspectCodefulCsprojBuildHooks, invalidateCodefulSdkCacheIfNeeded, hasCodefulWorkflowSetting } from '../utils/codeful';

/**
* Optional behaviors for {@link publishCodefulProject}.
Expand Down Expand Up @@ -52,7 +52,7 @@ export async function publishCodefulProject(
return;
}

const isCodeful = await isCodefulProject(nodePath);
const isCodeful = await hasCodefulWorkflowSetting(nodePath);
if (!isCodeful) {
const message = `Skipping publish: Path "${nodePath}" is not a codeful project.`;
ext.outputChannel.appendLog(message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { assetsFolderName, localSettingsFileName, managementApiPrefix } from '../../../../constants';
import { assetsFolderName, localSettingsFileName, managementApiPrefix, workflowCodefulEnabledKey } from '../../../../constants';
import { ext } from '../../../../extensionVariables';
import { localize } from '../../../../localize';
import { getLocalSettingsJson } from '../../../utils/appSettings/localSettings';
Expand Down Expand Up @@ -127,7 +127,7 @@ export default class OpenMonitoringViewForLocal extends OpenMonitoringViewBase {
isMonitoringView: this.isMonitoringView,
runId: this.runId,
hostVersion: ext.extensionVersion,
supportsUnitTest: this.isLocal && this.localSettings?.['WORKFLOW_CODEFUL_ENABLED'] !== 'true',
supportsUnitTest: this.isLocal && this.localSettings?.[workflowCodefulEnabledKey] !== 'true',
},
});
break;
Expand Down
Loading
Loading