Skip to content
Draft
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
5 changes: 3 additions & 2 deletions apps/vs-code-designer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,14 @@
"scripts": {
"build:extension": "tsup && pnpm run copyFiles",
"build:ui": "tsup --config tsup.e2e.test.config.ts",
"copyFiles": "node extension-copy-svgs.js",
"copyFiles": "node scripts/extension-copy-svgs.js",
"vscode:designer:pack": "pnpm run vscode:designer:pack:step1 && pnpm run vscode:designer:pack:step2",
"vscode:designer:pack:step1": "cd ./dist && npm install",
"vscode:designer:pack:step2": "cd ./dist && vsce package",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"test:extension-unit": "vitest run --retry=3",
"vscode:designer:e2e:ui": "pnpm run build:ui && cd dist && extest setup-and-run ../out/test/**/*.js --coverage",
"vscode:designer:e2e:headless": "pnpm run build:ui && cd dist && extest setup-and-run ../out/test/**/*.js --coverage"
"vscode:designer:e2e:headless": "pnpm run build:ui && cd dist && extest setup-and-run ../out/test/**/*.js --coverage",
"update:extension-bundle-version": "node scripts/update-extension-bundle-version.js"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const copyDoc = async (projectPath) => {
await copy('./src', `${projectPath}`, {
filter: ['LICENSE.md', 'package.json', 'README.md', 'assets/**'],
});
await copy(path.resolve(__dirname, '..', '..'), `${projectPath}`, {
await copy(path.resolve(__dirname, '..'), `${projectPath}`, {
filter: ['CHANGELOG.md'],
});
};
Expand Down
41 changes: 41 additions & 0 deletions apps/vs-code-designer/scripts/update-extension-bundle-version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env node
/* eslint-disable no-undef */
const fs = require('fs/promises');
const path = require('path');

async function main() {
const version = process.argv[2];
if (!version) {
console.error('Usage: node scripts/update-extension-bundle-version.js <version>');
process.exitCode = 1;
return;
}

const constantsPath = path.resolve(__dirname, '../src/constants.ts');
const dockerfilePath = path.resolve(__dirname, '../src/container/Dockerfile');

await updateFile(
constantsPath,
/export const EXTENSION_BUNDLE_VERSION = ['"][^'"]+['"];\s*/,
`export const EXTENSION_BUNDLE_VERSION = '${version}';\n`
);
await updateFile(dockerfilePath, /ARG EXTENSION_BUNDLE_VERSION=[^\s]+/, `ARG EXTENSION_BUNDLE_VERSION=${version}`);

console.log(`Updated extension bundle version to ${version}`);
}

async function updateFile(filePath, regex, replacement) {
const original = await fs.readFile(filePath, 'utf8');
if (!regex.test(original)) {
throw new Error(`Could not find target pattern in ${filePath}`);
}
const updated = original.replace(regex, replacement);
if (updated !== original) {
await fs.writeFile(filePath, updated);
}
}

main().catch((err) => {
console.error(err.message || err);
process.exitCode = 1;
});

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import type { CustomLocation } from '@microsoft/vscode-azext-azureappservice';
import { LocationListStep } from '@microsoft/vscode-azext-azureutils';
import { AzureWizardExecuteStep, nonNullOrEmptyValue, nonNullProp } from '@microsoft/vscode-azext-utils';
import type { ILogicAppWizardContext, ConnectionStrings } from '@microsoft/vscode-extension-logic-apps';
import { StorageOptions, FuncVersion, WorkerRuntime } from '@microsoft/vscode-extension-logic-apps';
import { StorageOptions, WorkerRuntime } from '@microsoft/vscode-extension-logic-apps';
import type { Progress } from 'vscode';

export class LogicAppCreateStep extends AzureWizardExecuteStep<ILogicAppWizardContext> {
Expand Down Expand Up @@ -191,18 +191,7 @@ export class LogicAppCreateStep extends AzureWizardExecuteStep<ILogicAppWizardCo
);
}

if (context.version === FuncVersion.v1) {
appSettings.push({
name: 'AzureWebJobsDashboard',
value: storageConnectionString.azureWebJobsDashboardValue,
});
}

if (
context.newSiteOS === WebsiteOS.windows &&
runtimeWithoutVersion.toLowerCase() === WorkerRuntime.Node &&
context.version !== FuncVersion.v1
) {
if (context.newSiteOS === WebsiteOS.windows && runtimeWithoutVersion.toLowerCase() === WorkerRuntime.Node) {
// Linux doesn't need this because it uses linuxFxVersion
// v1 doesn't need this because it only supports one version of Node
appSettings.push({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
createRulesFiles,
updateWorkspaceFile,
} from './CreateLogicAppWorkspace';
import { devContainerFolderName, devContainerFileName } from '../../../../constants';

export async function createLogicAppProject(context: IActionContext, options: any, workspaceRootFolder: any): Promise<void> {
addLocalFuncTelemetry(context);
Expand All @@ -42,6 +43,12 @@ export async function createLogicAppProject(context: IActionContext, options: an
const workspaceFilePath = vscode.workspace.workspaceFile.fsPath;
myWebviewProjectContext.workspaceFilePath = workspaceFilePath;
myWebviewProjectContext.shouldCreateLogicAppProject = !doesLogicAppExist;

// Detect if this is a devcontainer project by checking:
// 1. If .devcontainer folder exists in workspace file
// 2. If devcontainer.json exists in that folder
myWebviewProjectContext.isDevContainerProject = await isDevContainerWorkspace(workspaceFilePath, workspaceFolder);

// need to get logic app in projects
await updateWorkspaceFile(myWebviewProjectContext);
} else {
Expand Down Expand Up @@ -85,3 +92,32 @@ export async function createLogicAppProject(context: IActionContext, options: an
}
vscode.window.showInformationMessage(localize('finishedCreating', 'Finished creating project.'));
}

/**
* Checks if the workspace is a devcontainer project by:
* 1. Checking if .devcontainer folder is listed in the workspace file
* 2. Verifying that devcontainer.json exists in that folder
* @param workspaceFilePath - Path to the .code-workspace file
* @param workspaceFolder - Root folder of the workspace
* @returns true if this is a devcontainer workspace, false otherwise
*/
async function isDevContainerWorkspace(workspaceFilePath: string, workspaceFolder: string): Promise<boolean> {
// Read the workspace file
const workspaceFileContent = await fse.readJSON(workspaceFilePath);

// Check if .devcontainer folder is in the workspace folders
const folders = workspaceFileContent.folders || [];
const hasDevContainerFolder = folders.some(
(folder: any) => folder.path === devContainerFolderName || folder.path === `./${devContainerFolderName}`
);

if (!hasDevContainerFolder) {
return false;
}

// Verify devcontainer.json actually exists
const devContainerJsonPath = path.join(workspaceFolder, devContainerFolderName, devContainerFileName);
const devContainerJsonExists = await fse.pathExists(devContainerJsonPath);

return devContainerJsonExists;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import { latestGAVersion, ProjectLanguage, ProjectType, TargetFramework } from '
import type { ILaunchJson, ISettingToAdd, IWebviewProjectContext } from '@microsoft/vscode-extension-logic-apps';
import {
assetsFolderName,
containerTemplatesFolderName,
deploySubpathSetting,
devContainerFileName,
devContainerFolderName,
extensionCommand,
extensionsFileName,
funcVersionSetting,
Expand Down Expand Up @@ -53,13 +56,19 @@ export async function writeExtensionsJson(context: IActionContext, vscodePath: s
await fse.copyFile(templatePath, extensionsJsonPath);
}

export async function writeTasksJson(context: IActionContext, vscodePath: string): Promise<void> {
export async function writeTasksJson(context: IWebviewProjectContext, vscodePath: string): Promise<void> {
const tasksJsonPath: string = path.join(vscodePath, tasksFileName);
const tasksJsonFile = 'TasksJsonFile';
const tasksJsonFile = context.isDevContainerProject ? 'DevContainerTasksJsonFile' : 'TasksJsonFile';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there support for working on a 'dev container project' without dev containers, i.e. using the existing solution as a fallback?

const templatePath = path.join(__dirname, assetsFolderName, workspaceTemplatesFolderName, tasksJsonFile);
await fse.copyFile(templatePath, tasksJsonPath);
}

export async function writeDevContainerJson(devContainerPath: string): Promise<void> {
const devContainerJsonPath: string = path.join(devContainerPath, devContainerFileName);
const templatePath = path.join(__dirname, assetsFolderName, containerTemplatesFolderName, devContainerFileName);
await fse.copyFile(templatePath, devContainerJsonPath);
}

export function getDebugConfiguration(logicAppName: string, customCodeTargetFramework?: TargetFramework): DebugConfiguration {
if (customCodeTargetFramework) {
return {
Expand Down Expand Up @@ -129,3 +138,11 @@ export async function createLogicAppVsCodeContents(
myWebviewProjectContext.targetFramework as TargetFramework
);
}

export async function createDevContainerContents(myWebviewProjectContext: IWebviewProjectContext, workspaceFolder: string): Promise<void> {
if (myWebviewProjectContext.isDevContainerProject) {
const devContainerPath: string = path.join(workspaceFolder, devContainerFolderName);
await fse.ensureDir(devContainerPath);
await writeDevContainerJson(devContainerPath);
}
}
Loading
Loading