-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(vscode): Introduce support for Static Web Apps #5099
Changes from 12 commits
7a62e67
00b4539
a0a7c77
b69cb09
b87bd94
6053a4a
2122ec6
71f0017
79b814e
697eaf8
8f820e3
c6c2e2b
830669f
2723503
a1ca497
2a3af12
7176a58
9801764
4a8fef5
bce9b28
6ebf023
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. automatically changed. let me know if I should revert There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, please revert it |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -234,7 +234,6 @@ | |
"7ZR1xr": "Add an action", | ||
"7aJqIH": "Optional. The locale to be used when formatting (defaults to 'en-us').", | ||
"7gUE8h": "This will revert your workflow to the state it was in before Copilot's edit. If you made additional edits to the workflow after Copilot's, you will lose them. This action cannot be undone. Do you want to continue?", | ||
"7jAQar": "Enter value for parameter.", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. revert? |
||
"7jcTNd": "Enter a valid email.", | ||
"7k9jXx": "Status code", | ||
"7lnElz": "Returns the number of ticks (100 nanoseconds interval) since 1 January 0001 00:00:00 UT of a string timestamp", | ||
|
@@ -1158,7 +1157,6 @@ | |
"_7ZR1xr.comment": "Text on example action node", | ||
"_7aJqIH.comment": "Optional locale parameter to apply formatNumber function with", | ||
"_7gUE8h.comment": "Warning description of what undoing operation will do to the workflow", | ||
"_7jAQar.comment": "Parameter Field Default Value Placeholder Text", | ||
"_7jcTNd.comment": "Error validation message for emails", | ||
"_7k9jXx.comment": "Label text for response status code", | ||
"_7lnElz.comment": "Label for description of custom ticks Function", | ||
|
@@ -2136,7 +2134,6 @@ | |
"_mGUdCO.comment": "Label for description of custom getPastTime Function", | ||
"_mGpKsl.comment": "Label for description of custom dataUriToString Function", | ||
"_mNaBPE.comment": "Error message for invalid JSON in authentication editor", | ||
"_mOxbN1.comment": "Parameter Field Default Value Title", | ||
"_mPakaD.comment": "Label for description of custom encodeUriComponent Function", | ||
"_mPuXlv.comment": "Error message for when split on array is invalid. Do not remove the double single quotes around the placeholder text, as it is needed to wrap the placeholder text in single quotes.", | ||
"_mUURJW.comment": "Tooltip for the button to reassign actions", | ||
|
@@ -2784,7 +2781,6 @@ | |
"mGUdCO": "Returns a timestamp that is the current time minus the specified time interval.", | ||
"mGpKsl": "Returns a string representation of a data URI", | ||
"mNaBPE": "Enter a valid JSON.", | ||
"mOxbN1": "Value", | ||
"mPakaD": "Url encodes the input string", | ||
"mPuXlv": "Invalid type on split on value ''{splitOn}'', split on not in array.", | ||
"mUURJW": "Connection is invalid", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import type { IAzureConnectorsContext } from '../workflows/azureConnectorWizard'; | ||
import type * as vscode from 'vscode'; | ||
import { executeCommand } from '../../utils/funcCoreTools/cpUtils'; | ||
import { ext } from '../../../extensionVariables'; | ||
|
||
export async function generateStaticWebApp(context: IAzureConnectorsContext, node: vscode.Uri): Promise<void> { | ||
console.log('generate SWA'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this is user facing can we make this more descriptive? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @alain-zhiyanov Overall I would say to remove all console logs. If you want actually display something for the user to be aware of it, please the output channel and please localize the text. For example: |
||
//removing "/c: because that doesn't fit SWA cli format" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this comment still needed? |
||
const command: string = `node C:\\Users\\t-azhiyanov\\static-web-apps-cli-sifat\\dist\\cli\\bin.js generate ${node.path.substring(3)}`; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how can this be a static path? Won't it fail to find the bits on another machine? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @alain-zhiyanov I am not fully aware of the implementation or how we get this script, however if this is a static script, please upload the script in the repo or even better just make a function to call it. If its not static (generated), please make sure to have it a kind of static place for all users to work and also use |
||
executeCommand(ext.outputChannel, undefined, command); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,7 @@ import type { IFunctionWizardContext, IWorkflowTemplate, IHostJsonV2, StandardAp | |
import * as fse from 'fs-extra'; | ||
import * as path from 'path'; | ||
import type { MessageItem } from 'vscode'; | ||
import * as vscodeExtension from 'vscode'; | ||
|
||
export class CodelessWorkflowCreateStep extends WorkflowCreateStepBase<IFunctionWizardContext> { | ||
private constructor() { | ||
|
@@ -45,19 +46,71 @@ export class CodelessWorkflowCreateStep extends WorkflowCreateStepBase<IFunction | |
} | ||
|
||
public async executeCore(context: IFunctionWizardContext): Promise<string> { | ||
// Check if the user chose to initialize a static web app | ||
if (context.initializeStaticWebApp) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the comment needed here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shouldInitializeStaticWebApp |
||
context.telemetry.properties.initializeStaticWebApp = 'true'; | ||
//call deploy command | ||
|
||
vscodeExtension.commands.executeCommand('azureLogicAppsStandard.deploy'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NIT: Here is just better to call the function if possible, rather than calling the command |
||
} else { | ||
context.telemetry.properties.initializeStaticWebApp = 'false'; | ||
} | ||
|
||
const template: IWorkflowTemplate = nonNullProp(context, 'functionTemplate'); | ||
const functionPath: string = path.join(context.projectPath, nonNullProp(context, 'functionName')); | ||
|
||
const emptyStatefulDefinition: StandardApp = { | ||
definition: { | ||
$schema: 'https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#', | ||
actions: {}, | ||
contentVersion: '1.0.0.0', | ||
outputs: {}, | ||
triggers: {}, | ||
}, | ||
kind: 'Stateful', | ||
}; | ||
let emptyStatefulDefinition: StandardApp; | ||
if (context.initializeStaticWebApp) { | ||
//initiate basic logic app which can be called from SWA | ||
emptyStatefulDefinition = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we read this from a file instead? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we have a file to store the templates apps/vs-code-designer/src/app/utils/codeless/templates.ts |
||
definition: { | ||
$schema: 'https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#', | ||
actions: { | ||
Compose: { | ||
type: 'Compose', | ||
inputs: { | ||
status: 'Hello from Logic App', | ||
}, | ||
runAfter: {}, | ||
}, | ||
Response: { | ||
type: 'Response', | ||
kind: 'Http', | ||
inputs: { | ||
statusCode: 200, | ||
body: "@outputs('Compose')", | ||
}, | ||
runAfter: { | ||
Compose: ['SUCCEEDED'], | ||
}, | ||
}, | ||
}, | ||
contentVersion: '1.0.0.0', | ||
outputs: {}, | ||
triggers: { | ||
When_a_HTTP_request_is_received: { | ||
type: 'Request', | ||
kind: 'Http', | ||
inputs: { | ||
method: 'GET', | ||
relativePath: '/api/message', | ||
}, | ||
}, | ||
}, | ||
}, | ||
kind: 'Stateful', | ||
}; | ||
} else { | ||
emptyStatefulDefinition = { | ||
definition: { | ||
$schema: 'https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#', | ||
actions: {}, | ||
contentVersion: '1.0.0.0', | ||
outputs: {}, | ||
triggers: {}, | ||
}, | ||
kind: 'Stateful', | ||
}; | ||
} | ||
|
||
const emptyStatelessDefinition: StandardApp = { | ||
definition: { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,18 +7,33 @@ import { AzureWizardPromptStep } from '@microsoft/vscode-azext-utils'; | |
import type { IAzureQuickPickItem } from '@microsoft/vscode-azext-utils'; | ||
import type { IProjectWizardContext } from '@microsoft/vscode-extension-logic-apps'; | ||
|
||
interface ILogicAppPickData { | ||
isCustomCodeLogicApp: boolean; | ||
initializeStaticWebApp: boolean; | ||
} | ||
|
||
export class SetLogicAppType extends AzureWizardPromptStep<IProjectWizardContext> { | ||
public async prompt(context: IProjectWizardContext): Promise<void> { | ||
const picks: IAzureQuickPickItem<boolean>[] = [ | ||
{ label: localize('logicApp', 'Logic app'), data: false }, | ||
{ label: localize('logicAppCustomCode', 'Logic app with custom code project'), data: true }, | ||
const picks: IAzureQuickPickItem<ILogicAppPickData>[] = [ | ||
{ label: localize('logicApp', 'Logic app'), data: { isCustomCodeLogicApp: false, initializeStaticWebApp: false } }, | ||
{ | ||
label: localize('logicAppCustomCode', 'Logic app with custom code project'), | ||
data: { isCustomCodeLogicApp: true, initializeStaticWebApp: false }, | ||
}, | ||
{ | ||
label: localize('logicAppStaticWebApp', 'Logic app with Static Web App'), | ||
data: { isCustomCodeLogicApp: false, initializeStaticWebApp: true }, | ||
}, | ||
]; | ||
|
||
const placeHolder = localize('logicAppProjectTemplatePlaceHolder', 'Select a project template for your logic app workspace'); | ||
context.isCustomCodeLogicApp = (await context.ui.showQuickPick(picks, { placeHolder })).data; | ||
const selectedPick = await context.ui.showQuickPick(picks, { placeHolder }); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: remove extra line |
||
context.isCustomCodeLogicApp = selectedPick.data.isCustomCodeLogicApp; | ||
context.initializeStaticWebApp = selectedPick.data.initializeStaticWebApp; | ||
} | ||
|
||
public shouldPrompt(context: IProjectWizardContext): boolean { | ||
return context.isCustomCodeLogicApp === undefined; | ||
return context.isCustomCodeLogicApp === undefined && context.initializeStaticWebApp === undefined; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,12 +43,14 @@ export class ScriptProjectCreateStep extends ProjectCreateStepBase { | |
} | ||
|
||
const localSettingsJsonPath: string = path.join(context.projectPath, localSettingsFileName); | ||
//added new setting here to allow local start without SAS | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are we always adding this setting now or only if is starting through swa cli? |
||
if (await confirmOverwriteFile(context, localSettingsJsonPath)) { | ||
const localSettingsJson: ILocalSettingsJson = { | ||
IsEncrypted: false, | ||
Values: { | ||
AzureWebJobsStorage: '', | ||
APP_KIND: logicAppKind, | ||
'AzureFunctionsJobHost__extensions__workflow__Settings__Runtime.Triggers.AnonymousAuthEnabledForDevEnvironment': 'true', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: the formatting here is off There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also make sure to just add it when is needed for static web apps and not for all of the scenarios |
||
ProjectDirectoryPath: path.join(context.projectPath), | ||
}, | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,6 +48,7 @@ import type { ConnectionsData, FuncVersion, IIdentityWizardContext, ProjectLangu | |
import * as fse from 'fs-extra'; | ||
import * as path from 'path'; | ||
import type { Uri, MessageItem, WorkspaceFolder } from 'vscode'; | ||
import * as vscodeExtension from 'vscode'; | ||
|
||
export async function deployProductionSlot( | ||
context: IActionContext, | ||
|
@@ -188,8 +189,16 @@ async function deploy( | |
} | ||
} | ||
}); | ||
|
||
await node.loadAllChildren(context); | ||
|
||
//need to add flag for this call and remove region hardcode TODO | ||
const suffix = '/config/web'; | ||
const logicAppBackendResourceId = siteConfig.id.substring(0, siteConfig.id.length - suffix.length); | ||
vscodeExtension.commands.executeCommand('staticWebApps.createStaticWebApp', undefined, undefined, { | ||
backendResourceId: logicAppBackendResourceId, | ||
region: 'eastus', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How can this region be static? |
||
name: siteConfig.name, | ||
}); | ||
await notifyDeployComplete(node, context.workspaceFolder, settingsToExclude); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: I think there is no need for an extra breakline here