in apps/vs-code-designer/src/app/commands/generateDeploymentScripts/generateDeploymentScripts.ts [45:125]
export async function generateDeploymentScripts(context: IActionContext, node?: vscode.Uri): Promise<void> {
let projectPath: string;
let projectRoot: vscode.Uri;
try {
ext.outputChannel.show();
ext.outputChannel.appendLog(localize('initScriptGen', 'Initiating script generation...'));
addLocalFuncTelemetry(context);
if (node) {
projectPath = node.fsPath;
projectRoot = node;
} else {
const workspaceFolder = await getWorkspaceFolder(context);
projectPath = await tryGetLogicAppProjectRoot(context, workspaceFolder);
projectRoot = vscode.Uri.file(projectPath);
}
const connectionsJson = await getConnectionsJson(projectPath);
const connectionsData: ConnectionsData = isEmptyString(connectionsJson) ? {} : JSON.parse(connectionsJson);
const isParameterized = await areAllConnectionsParameterized(connectionsData);
const workflowFiles = getWorkflowFilePaths(projectPath);
if (!(await convertToWorkspace(context))) {
ext.outputChannel.appendLog(localize('exitScriptGen', 'Exiting script generation...'));
return;
}
if (!isParameterized) {
const message = localize(
'parameterizeInDeploymentScripts',
'Allow parameterization for connections? Declining cancels generation for deployment scripts.'
);
const result = await vscode.window.showInformationMessage(message, { modal: true }, DialogResponses.yes, DialogResponses.no);
if (result === DialogResponses.yes) {
await parameterizeConnections(context);
context.telemetry.properties.parameterizeConnectionsInDeploymentScripts = 'true';
} else {
context.telemetry.properties.parameterizeConnectionsInDeploymentScripts = 'false';
ext.outputChannel.appendLog(localize('exitScriptGen', 'Exiting script generation...'));
return;
}
}
const scriptContext = await setupWizardScriptContext(context, projectRoot);
const inputs = await gatherAndValidateInputs(scriptContext, projectRoot);
const sourceControlPath = scriptContext.sourceControlPath;
await callConsumptionApi(scriptContext, inputs);
const standardArtifactsContent = await callStandardApi(inputs, projectPath);
await handleApiResponse(standardArtifactsContent, sourceControlPath);
const deploymentScriptLocation = `workspace/${scriptContext.sourceControlPath}`;
const localizedLogMessage = localize(
'scriptGenSuccess',
'Deployment script generation completed successfully. The scripts are added at location: {0}. Warning: One or more workflows in your logic app may contain user-based authentication for managed connectors. You are required to manually authenticate the connection from the Azure portal after the resource is deployed by the DevOps pipeline.',
deploymentScriptLocation
);
ext.outputChannel.appendLog(localizedLogMessage);
if (scriptContext.isValidWorkspace) {
FileManagement.addFolderToWorkspace(sourceControlPath);
} else {
FileManagement.convertToValidWorkspace(sourceControlPath);
}
const correlationId = uuidv4();
const currentDateTime = new Date().toISOString();
workflowFiles.forEach((filePath) => updateMetadata(filePath, projectPath, correlationId, currentDateTime));
} catch (error) {
const errorMessage = localize('errorScriptGen', 'Error during deployment script generation: {0}', error.message ?? error);
ext.outputChannel.appendLog(errorMessage);
context.telemetry.properties.error = errorMessage;
context.telemetry.properties.pinnedBundleVersion = ext.pinnedBundleVersion.has(projectPath)
? ext.pinnedBundleVersion.get(projectPath).toString()
: 'false';
context.telemetry.properties.currentWorkflowBundleVersion = ext.currentBundleVersion.has(projectPath)
? ext.currentBundleVersion.get(projectPath)
: ext.defaultBundleVersion;
if (!errorMessage.includes(COMMON_ERRORS.OPERATION_CANCELLED)) {
throw new Error(errorMessage);
}
}
}