Skip to content

Commit 16fc422

Browse files
authored
feat(vscode): Custom Code Support in VSCode (#6251)
* merge * temp commit * work in progress * temp commit * work being done * remove datamapper code * fixing code based on comments * merge * add unit tests * edit error message
1 parent 32a579e commit 16fc422

File tree

54 files changed

+489
-212
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+489
-212
lines changed

.eslintrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@
4040
"error",
4141
{
4242
"argsIgnorePattern": "^_",
43-
"destructuredArrayIgnorePattern": "^_"
43+
"destructuredArrayIgnorePattern": "^_",
44+
"caughtErrorsIgnorePattern": "^_"
4445
}
4546
],
4647
"@typescript-eslint/explicit-module-boundary-types": "off",

apps/Standalone/.eslintrc.cjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ module.exports = {
1313
{
1414
argsIgnorePattern: '^_',
1515
destructuredArrayIgnorePattern: '^_',
16+
caughtErrorsIgnorePattern: '^_',
1617
},
1718
],
1819
},

apps/Standalone/src/designer/app/AzureLogicAppsDesigner/Models/Workflow.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export const Artifact = {
1515
ConnectionsFile: 'connections.json',
1616
ParametersFile: 'parameters.json',
1717
WorkflowFile: 'workflow.json',
18+
HostFile: 'host.json',
1819
} as const;
1920

2021
export interface ArtifactProperties {
@@ -105,7 +106,7 @@ export interface ConnectionsData {
105106
}
106107

107108
// eslint-disable-next-line @typescript-eslint/no-empty-interface
108-
export interface ParametersData extends Record<string, Parameter> {}
109+
export type ParametersData = Record<string, Parameter>;
109110

110111
export interface Parameter {
111112
name?: string;

apps/Standalone/src/designer/app/AzureLogicAppsDesigner/Utilities/resourceUtilities.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export const fetchAppsByQuery = async (query: string): Promise<any[]> => {
3939
return await requestPage(value, pageNum + 1, $skipToken);
4040
}
4141
return value;
42-
} catch (error) {
42+
} catch (_e) {
4343
return value;
4444
}
4545
};

apps/Standalone/src/designer/state/store.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import workflowSlice from './workflowLoadingSlice';
22
import { configureStore } from '@reduxjs/toolkit';
33

4-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
5-
64
export const store = configureStore({
75
reducer: {
86
workflowLoader: workflowSlice,

apps/vs-code-designer/src/app/commands/createNewCodeProject/__test__/cloudToLocal.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { extractConnectionDetails, changeAuthTypeToRaw } from '../cloudToLocalHelper';
1+
import { extractConnectionDetails } from '../cloudToLocalHelper';
22
import type { ConnectionReferenceModel } from '@microsoft/vscode-extension-logic-apps';
33
import { describe, it, expect, vi } from 'vitest';
44
import { beforeEach } from 'vitest';

apps/vs-code-designer/src/app/commands/dataMapper/DataMapperPanel.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ import {
1313
supportedSchemaFileExts,
1414
supportedCustomXsltFileExts,
1515
} from './extensionConfig';
16-
import { type SchemaType, type MapMetadata, type IFileSysTreeItem, LogEntryLevel } from '@microsoft/logic-apps-shared';
16+
import { LogEntryLevel } from '@microsoft/logic-apps-shared';
17+
import type { SchemaType, MapMetadata, IFileSysTreeItem } from '@microsoft/logic-apps-shared';
1718
import type { IActionContext } from '@microsoft/vscode-azext-utils';
1819
import { callWithTelemetryAndErrorHandlingSync } from '@microsoft/vscode-azext-utils';
1920
import type { MapDefinitionData, MessageToVsix, MessageToWebview } from '@microsoft/vscode-extension-logic-apps';

apps/vs-code-designer/src/app/commands/deploy/deploy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ async function getLogicAppsPicks(
278278
* @param context {@link IActionContext}
279279
* @param fsPath publish path for logic app extension
280280
*/
281-
async function cleanupPublishBinPath(context: IActionContext, fsPath: string): Promise<void> {
281+
async function cleanupPublishBinPath(_context: IActionContext, fsPath: string): Promise<void> {
282282
const netFxWorkerBinPath = path.join(fsPath, 'bin', 'NetFxWorker');
283283
const netFxWorkerAssetPath = path.join(fsPath, 'NetFxWorker');
284284
if (await fse.pathExists(netFxWorkerBinPath)) {

apps/vs-code-designer/src/app/commands/workflows/openDesigner/openDesignerForLocalProject.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,12 @@ import {
1414
addConnectionData,
1515
getConnectionsAndSettingsToUpdate,
1616
getConnectionsFromFile,
17+
getCustomCodeFromFiles,
18+
getCustomCodeToUpdate,
1719
getLogicAppProjectRoot,
1820
getParametersFromFile,
1921
saveConnectionReferences,
22+
saveCustomCodeStandard,
2023
} from '../../../utils/codeless/connection';
2124
import { saveWorkflowParameter } from '../../../utils/codeless/parameter';
2225
import { startDesignTimeApi } from '../../../utils/codeless/startDesignTimeApi';
@@ -251,14 +254,14 @@ export default class OpenDesignerForLocalProject extends OpenDesignerBase {
251254

252255
await window.withProgress(options, async () => {
253256
try {
254-
const { definition, connectionReferences, parameters } = workflowToSave;
257+
const { definition, connectionReferences, parameters, customCodeData } = workflowToSave;
255258
const definitionToSave: any = definition;
256259
const parametersFromDefinition = parameters;
260+
const projectPath = await getLogicAppProjectRoot(this.context, filePath);
257261

258262
workflow.definition = definitionToSave;
259263

260264
if (connectionReferences) {
261-
const projectPath = await getLogicAppProjectRoot(this.context, filePath);
262265
const connectionsAndSettingsToUpdate = await getConnectionsAndSettingsToUpdate(
263266
this.context,
264267
projectPath,
@@ -271,6 +274,11 @@ export default class OpenDesignerForLocalProject extends OpenDesignerBase {
271274
await saveConnectionReferences(this.context, projectPath, connectionsAndSettingsToUpdate);
272275
}
273276

277+
if (customCodeData) {
278+
const customCodeToUpdate = await getCustomCodeToUpdate(this.context, filePath, customCodeData);
279+
await saveCustomCodeStandard(filePath, customCodeToUpdate);
280+
}
281+
274282
if (parametersFromDefinition) {
275283
delete parametersFromDefinition.$connections;
276284
for (const parameterKey of Object.keys(parametersFromDefinition)) {
@@ -417,6 +425,9 @@ export default class OpenDesignerForLocalProject extends OpenDesignerBase {
417425
const connectionsData: string = await getConnectionsFromFile(this.context, this.workflowFilePath);
418426
const projectPath: string | undefined = await getLogicAppProjectRoot(this.context, this.workflowFilePath);
419427
const parametersData: Record<string, Parameter> = await getParametersFromFile(this.context, this.workflowFilePath);
428+
const customCodeData: Record<string, string> = await getCustomCodeFromFiles(this.workflowFilePath);
429+
const workflowDetails = await getManualWorkflowsInLocalProject(projectPath, this.workflowName);
430+
const artifacts = await getArtifactsInLocalProject(projectPath);
420431
let localSettings: Record<string, string>;
421432
let azureDetails: AzureConnectorDetails;
422433

@@ -432,14 +443,15 @@ export default class OpenDesignerForLocalProject extends OpenDesignerBase {
432443
appSettingNames: Object.keys(localSettings),
433444
standardApp: getStandardAppData(this.workflowName, workflowContent),
434445
connectionsData,
446+
customCodeData,
435447
parametersData,
436448
localSettings,
437449
azureDetails,
438450
accessToken: azureDetails.accessToken,
439451
workflowContent,
440-
workflowDetails: await getManualWorkflowsInLocalProject(projectPath, this.workflowName),
452+
workflowDetails,
441453
workflowName: this.workflowName,
442-
artifacts: await getArtifactsInLocalProject(projectPath),
454+
artifacts,
443455
schemaArtifacts: this.schemaArtifacts,
444456
mapArtifacts: this.mapArtifacts,
445457
};

apps/vs-code-designer/src/app/commands/workflows/openMonitoringView/openMonitoringViewForLocal.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@ import {
1212
getAzureConnectorDetailsForLocalProject,
1313
getStandardAppData,
1414
} from '../../../utils/codeless/common';
15-
import { getConnectionsFromFile, getLogicAppProjectRoot, getParametersFromFile } from '../../../utils/codeless/connection';
15+
import {
16+
getConnectionsFromFile,
17+
getCustomCodeFromFiles,
18+
getLogicAppProjectRoot,
19+
getParametersFromFile,
20+
} from '../../../utils/codeless/connection';
1621
import { sendRequest } from '../../../utils/requestUtils';
1722
import { OpenMonitoringViewBase } from './openMonitoringViewBase';
1823
import { getTriggerName, HTTP_METHODS } from '@microsoft/logic-apps-shared';
@@ -166,6 +171,7 @@ export default class OpenMonitoringViewForLocal extends OpenMonitoringViewBase {
166171
const projectPath: string | undefined = await getLogicAppProjectRoot(this.context, this.workflowFilePath);
167172
const workflowContent: any = JSON.parse(readFileSync(this.workflowFilePath, 'utf8'));
168173
const parametersData: Record<string, Parameter> = await getParametersFromFile(this.context, this.workflowFilePath);
174+
const customCodeData: Record<string, string> = await getCustomCodeFromFiles(this.workflowFilePath);
169175
let localSettings: Record<string, string>;
170176
let azureDetails: AzureConnectorDetails;
171177

@@ -182,6 +188,7 @@ export default class OpenMonitoringViewForLocal extends OpenMonitoringViewBase {
182188
connectionsData,
183189
localSettings,
184190
parametersData,
191+
customCodeData,
185192
azureDetails,
186193
accessToken: azureDetails.accessToken,
187194
workflowName: this.workflowName,

0 commit comments

Comments
 (0)