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
2 changes: 1 addition & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import { defineConfig } from 'eslint/config';
export default defineConfig([
azExtEslintRecommended,
lazyImportRuleConfig([
'@modelcontextprotocol/*',
'@azure/*',
'handlebars',
'@microsoft/vscode-azext-azure*',
'tar',
'vscode-languageclient*',
'!@microsoft/vscode-azext-azureauth',
]),
Expand Down
45 changes: 14 additions & 31 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 5 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3351,41 +3351,40 @@
"vscode.yaml"
],
"devDependencies": {
"@azure/arm-appservice": "^15.0.0",
"@azure/arm-appservice": "*",
"@azure/arm-authorization": "*",
Comment thread
bwateratmsft marked this conversation as resolved.
Resolved
"@microsoft/vscode-azext-eng": "1.0.0-alpha.12",
"@types/fs-extra": "^11.0.1",
"@types/node": "22.x",
"@types/semver": "^7.3.13",
"@types/vscode": "1.105.0",
"@types/xml2js": "^0.4.11",
"@vscode/test-cli": "*",
"@vscode/test-electron": "*",
"@vscode/vsce": "*",
"esbuild": "*",
"esbuild-plugin-copy": "*"
},
"dependencies": {
"@azure/arm-authorization": "^9.0.0",
Comment thread
bwateratmsft marked this conversation as resolved.
Resolved
"@azure/arm-containerregistry": "^10.1.0",
"@azure/storage-blob": "^12.14.0",
"@microsoft/compose-language-service": "^0.5.0",
"@microsoft/vscode-azext-azureappservice": "^4.0.0",
"@microsoft/vscode-azext-azureauth": "6.0.0-alpha.1",
"@microsoft/vscode-azext-azureutils": "^4.0.0",
"@microsoft/vscode-azext-utils": "^4.0.4",
"@microsoft/vscode-container-client": "^0.5.2",
"@microsoft/vscode-container-client": "^0.5.3",
"@microsoft/vscode-docker-registries": "^0.4.1",
"@microsoft/vscode-processutils": "^0.2.1",
"dayjs": "^1.11.7",
"dockerfile-language-server-nodejs": "^0.15.0",
"fast-xml-parser": "^5.3.4",
"fs-extra": "^11.1.1",
"gradle-to-js": "^2.0.1",
"handlebars": "^4.7.7",
"handlebars": "^4.7.8",
"semver": "^7.5.2",
"tar": "^7.5.7",
"vscode-languageclient": "^10.0.0-next.19",
"vscode-tas-client": "^0.1.75",
"xml2js": "^0.6.0",
"zod": "~4"
}
}
5 changes: 3 additions & 2 deletions src/commands/registries/azure/tasks/scheduleRunRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@ import * as fse from 'fs-extra';
import * as os from 'os';
import * as path from 'path';
import * as readline from 'readline';
import * as tar from 'tar';
import * as vscode from 'vscode';
import { ext } from '../../../../extensionVariables';
import { AzureRegistry, AzureRegistryItem } from "../../../../tree/registries/Azure/AzureRegistryDataProvider";
import { UnifiedRegistryItem } from "../../../../tree/registries/UnifiedRegistryTreeDataProvider";
import { createArmContainerRegistryClient, getResourceGroupFromId } from "../../../../utils/azureUtils";
import { getStorageBlob } from '../../../../utils/lazyPackages';
import { getStorageBlob, getTar } from '../../../../utils/lazyPackages';
import { delay } from '../../../../utils/promiseUtils';
import { Item, quickPickDockerFileItem, quickPickYamlFileItem } from '../../../../utils/quickPickFile';
import { quickPickWorkspaceFolder } from '../../../../utils/quickPickWorkspaceFolder';
Expand Down Expand Up @@ -139,6 +138,8 @@ async function quickPickImageName(context: IActionContext, rootFolder: vscode.Wo
}

async function uploadSourceCode(client: ContainerRegistryManagementClient, registryName: string, resourceGroupName: string, rootFolder: vscode.Uri, tarFilePath: string): Promise<string> {
const tar = await getTar();

ext.outputChannel.info(vscode.l10n.t(' Sending source code to temp file'));
const source: string = rootFolder.fsPath;
let items = await fse.readdir(source);
Comment thread
bwateratmsft marked this conversation as resolved.
Resolved
Comment thread
bwateratmsft marked this conversation as resolved.
Resolved
Expand Down
4 changes: 2 additions & 2 deletions src/runtimes/files/ContainerFilesProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class ContainerFilesProvider extends vscode.Disposable implements vscode.
const containerOS = dockerUri.options?.containerOS || await getDockerOSType();

const accumulator = new AccumulatorStream();
const targetStream = containerOS === 'windows' ? accumulator : tarUnpackStream(accumulator);
const targetStream = containerOS === 'windows' ? accumulator : await tarUnpackStream(accumulator);

const generator = ext.streamWithDefaults(
client => client.readFile({
Expand Down Expand Up @@ -133,7 +133,7 @@ export class ContainerFilesProvider extends vscode.Disposable implements vscode.
operatingSystem: containerOS,
}),
{
stdInPipe: tarPackStream(Buffer.from(content), path.basename(uri.path), nowDate, nowDate, nowDate, mode, gid, uid),
stdInPipe: await tarPackStream(Buffer.from(content), path.basename(uri.path), nowDate, nowDate, nowDate, mode, gid, uid),
},
);
});
Expand Down
5 changes: 3 additions & 2 deletions src/scaffolding/wizard/java/JavaGatherInformationStep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
* Licensed under the MIT License. See LICENSE.md in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { XMLParser } from 'fast-xml-parser';
import * as fse from 'fs-extra';
import * as gradleParser from 'gradle-to-js/lib/parser';
import * as xml2js from 'xml2js';
import { GatherInformationStep } from '../GatherInformationStep';
import { JavaScaffoldingWizardContext } from './JavaScaffoldingWizardContext';

Expand Down Expand Up @@ -33,7 +33,8 @@ export class JavaGatherInformationStep extends GatherInformationStep<JavaScaffol
if (/pom.xml$/i.test(wizardContext.artifact)) {
// If it's a POM file, parse as XML
this.javaProjectType = 'pom';
const pomObject = <PomContents>await xml2js.parseStringPromise(contents, { trim: true, normalizeTags: true, normalize: true, mergeAttrs: true });
const parser = new XMLParser({ trimValues: true, transformTagName: (tagName) => tagName.toLowerCase() });
const pomObject = parser.parse(contents) as PomContents;

wizardContext.version = pomObject?.project?.version || '0.0.1';

Expand Down
28 changes: 17 additions & 11 deletions src/utils/lazyPackages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@
import { ext } from '../extensionVariables';
import { Lazy } from './lazy';

const armAuthLazy = new Lazy(async () => await import('@azure/arm-authorization'));
Comment thread
bwateratmsft marked this conversation as resolved.
Resolved
export async function getArmAuth() {
return await armAuthLazy.value;
}

const armContainerRegistryLazy = new Lazy(async () => await import('@azure/arm-containerregistry'));
export async function getArmContainerRegistry() {
return await armContainerRegistryLazy.value;
Expand All @@ -21,16 +16,17 @@ export async function getStorageBlob() {
return await storageBlobLazy.value;
}

const handlebarsLazy = new Lazy(async () => await import('handlebars'));
const handlebarsLazy = new Lazy(async () => getDefaultExport(await import('handlebars')));
export async function getHandlebars() {
return await handlebarsLazy.value;
}

const languageClientLazy = new Lazy(async () => {
const module = await import('vscode-languageclient/node');
// The module is CJS; when bundled to ESM by esbuild the exports end up on `default`. Fall back to the module itself for unbundled usage.
return (module as unknown as typeof module & { default?: typeof module }).default ?? module;
});
const tarLazy = new Lazy(async () => await import('tar'));
Comment thread
bwateratmsft marked this conversation as resolved.
Resolved
export async function getTar() {
return await tarLazy.value;
}

const languageClientLazy = new Lazy(async () => getDefaultExport(await import('vscode-languageclient/node')));
export async function getLanguageClient() {
return await languageClientLazy.value;
}
Expand All @@ -53,3 +49,13 @@ const azExtAppServiceLazy = new Lazy(async () => {
export async function getAzExtAppService() {
return await azExtAppServiceLazy.value;
}

/**
* Gets the default export out of a module, if it exists, otherwise returns the module itself. This is necessary to support CJS modules, as well as bundled and unbundled usage.
* @param module The module to get the default export for
* @returns The module's default, if it exists, otherwise the module
*/
function getDefaultExport<T>(module: T | { default: T }): T {
// The module is CJS; when bundled to ESM by esbuild the exports end up on `default`. Fall back to the module itself for unbundled usage.
return (module as unknown as { default?: T }).default ?? (module as T);
Comment thread
bwateratmsft marked this conversation as resolved.
Resolved
}
30 changes: 16 additions & 14 deletions src/utils/netCoreUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { parseError } from '@microsoft/vscode-azext-utils';
import { CommandLineArgs, composeArgs, withArg, withQuotedArg } from '@microsoft/vscode-processutils';
import * as path from 'path';
import * as vscode from 'vscode';
import { z } from 'zod';
import * as z from 'zod/mini';
import { execAsync } from './execAsync';

interface NetCoreCommonProjectInfo {
Expand All @@ -33,16 +33,18 @@ export type NetCoreProjectInfo = NetCoreCommonProjectInfo & (NetCoreContainerPro
const RawNetCoreProjectInfoSchema = z.object({
Properties: z
.object({
AssemblyName: z.string().min(1, vscode.l10n.t('AssemblyName must have a value')),
OutputPath: z.string().min(1, vscode.l10n.t('OutputPath must have a value')),
TargetFramework: z.string().optional(),
TargetFrameworks: z.string().optional(),
EnableSdkContainerSupport: z.stringbool().optional(),
ContainerWorkingDirectory: z.string().optional(),
ContainerRepository: z.string().optional(),
AssemblyName: z.string().check(z.minLength(1, vscode.l10n.t('AssemblyName must have a value'))),
OutputPath: z.string().check(z.minLength(1, vscode.l10n.t('OutputPath must have a value'))),
TargetFramework: z.optional(z.string()),
TargetFrameworks: z.optional(z.string()),
EnableSdkContainerSupport: z.optional(z.stringbool()),
ContainerWorkingDirectory: z.optional(z.string()),
ContainerRepository: z.optional(z.string()),
})
.refine(info => info.TargetFramework || info.TargetFrameworks, vscode.l10n.t('Either TargetFramework or TargetFrameworks must have a value'))
.refine(info => !info.EnableSdkContainerSupport || (info.ContainerWorkingDirectory && info.ContainerRepository), vscode.l10n.t('ContainerWorkingDirectory and ContainerRepository must have values when EnableSdkContainerSupport is true'))
.check(
z.refine(info => info.TargetFramework || info.TargetFrameworks, vscode.l10n.t('Either TargetFramework or TargetFrameworks must have a value')),
z.refine(info => !info.EnableSdkContainerSupport || (info.ContainerWorkingDirectory && info.ContainerRepository), vscode.l10n.t('ContainerWorkingDirectory and ContainerRepository must have values when EnableSdkContainerSupport is true')),
),
});

export async function getNetCoreProjectInfo(project: string, additionalProperties?: CommandLineArgs): Promise<NetCoreProjectInfo> {
Expand Down Expand Up @@ -96,10 +98,10 @@ export interface BlazorManifestInfo {

const RawBlazorManifestInfoSchema = z.object({
Properties: z.object({
MSBuildProjectDirectory: z.string().min(1, vscode.l10n.t('MSBuildProjectDirectory must have a value')),
StaticWebAssetDevelopmentManifestPath: z.string().min(1, vscode.l10n.t('StaticWebAssetDevelopmentManifestPath must have a value')),
OutputPath: z.string().min(1, vscode.l10n.t('OutputPath must have a value')),
TargetName: z.string().min(1, vscode.l10n.t('TargetName must have a value')),
MSBuildProjectDirectory: z.string().check(z.minLength(1, vscode.l10n.t('MSBuildProjectDirectory must have a value'))),
StaticWebAssetDevelopmentManifestPath: z.string().check(z.minLength(1, vscode.l10n.t('StaticWebAssetDevelopmentManifestPath must have a value'))),
OutputPath: z.string().check(z.minLength(1, vscode.l10n.t('OutputPath must have a value'))),
TargetName: z.string().check(z.minLength(1, vscode.l10n.t('TargetName must have a value'))),
})
});

Expand Down
10 changes: 7 additions & 3 deletions src/utils/tarUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@
*--------------------------------------------------------------------------------------------*/

import * as stream from 'stream';
import * as tar from 'tar';
import { getTar } from './lazyPackages';

/**
* Write tarball data containing a single file to this stream, and
* it will unpack it.
* @param destination The destination stream to unpack to
* @returns A stream to write tarball data into
*/
export function tarUnpackStream(destination: NodeJS.WritableStream): NodeJS.WritableStream {
export async function tarUnpackStream(destination: NodeJS.WritableStream): Promise<NodeJS.WritableStream> {
const tar = await getTar();
Comment thread
bwateratmsft marked this conversation as resolved.
Resolved

let entryCounter = 0;
return new tar.Unpack({
filter: () => {
Expand All @@ -39,7 +41,9 @@ export function tarUnpackStream(destination: NodeJS.WritableStream): NodeJS.Writ
* @param uid Optional unix user id specifier
* @returns A stream to read tarball data from
*/
export function tarPackStream(source: Buffer, sourceFileName: string, atime: Date = new Date(), mtime: Date = new Date(), ctime: Date = new Date(), mode?: number, gid?: number, uid?: number): NodeJS.ReadableStream {
export async function tarPackStream(source: Buffer, sourceFileName: string, atime: Date = new Date(), mtime: Date = new Date(), ctime: Date = new Date(), mode?: number, gid?: number, uid?: number): Promise<NodeJS.ReadableStream> {
const tar = await getTar();

const tarPack = new tar.Pack({ portable: true });
const readEntry = new tar.ReadEntry(new tar.Header({
path: sourceFileName,
Expand Down
Loading