Socket
Socket
Sign inDemoInstall

@microsoft/vscode-azext-utils

Package Overview
Dependencies
Maintainers
10
Versions
87
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@microsoft/vscode-azext-utils - npm Package Compare versions

Comparing version 0.5.2-alpha.0 to 0.5.2

0

activity.d.ts

@@ -0,0 +0,0 @@ import { AzureResourcesExtensionApi } from '@microsoft/vscode-azureresources-api';

@@ -0,0 +0,0 @@ MIT License

4

out/src/activityLog/Activity.js

@@ -17,3 +17,3 @@ "use strict";

exports.ActivityBase = exports.ActivityStatus = void 0;
const uuid_1 = require("uuid");
const crypto_1 = require("crypto");
const vscode_1 = require("vscode");

@@ -37,3 +37,3 @@ const parseError_1 = require("../parseError");

this.cancellationTokenSource = new vscode_1.CancellationTokenSource();
this.id = (0, uuid_1.v4)();
this.id = (0, crypto_1.randomUUID)();
this.task = task;

@@ -40,0 +40,0 @@ this.onStart = this._onStartEmitter.event;

@@ -7,14 +7,22 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.createAzExtOutputChannel = void 0;
exports.createAzExtOutputChannel = exports.createAzExtLogOutputChannel = void 0;
const vscode_1 = require("vscode");
function createAzExtLogOutputChannel(name) {
return new AzExtLogOutputChannel(name);
}
exports.createAzExtLogOutputChannel = createAzExtLogOutputChannel;
function createAzExtOutputChannel(name, extensionPrefix) {
return new AzExtOutputChannel(name, extensionPrefix);
const outputChannel = new AzExtOutputChannel(name);
outputChannel.extensionPrefix = extensionPrefix;
return outputChannel;
}
exports.createAzExtOutputChannel = createAzExtOutputChannel;
class AzExtOutputChannel {
constructor(name, extensionPrefix) {
constructor(name) {
this.name = name;
this.extensionPrefix = extensionPrefix;
this._outputChannel = vscode_1.window.createOutputChannel(this.name);
this._outputChannel = this.createOutputChannel(name);
}
createOutputChannel(name) {
return vscode_1.window.createOutputChannel(name);
}
append(value) {

@@ -26,7 +34,9 @@ this._outputChannel.append(value);

}
appendLog(value, options) {
shouldIncludeTimestamps() {
const enableOutputTimestampsSetting = 'enableOutputTimestamps';
const projectConfiguration = vscode_1.workspace.getConfiguration(this.extensionPrefix);
const result = projectConfiguration.get(enableOutputTimestampsSetting);
if (!result) {
return !!projectConfiguration.get(enableOutputTimestampsSetting);
}
appendLog(value, options) {
if (!this.shouldIncludeTimestamps()) {
this.appendLine(value);

@@ -57,2 +67,34 @@ }

}
class AzExtLogOutputChannel extends AzExtOutputChannel {
constructor(name) {
super(name);
this.onDidChangeLogLevel = this._outputChannel.onDidChangeLogLevel;
}
get logLevel() {
return this._outputChannel.logLevel;
}
shouldIncludeTimestamps() {
return false;
}
createOutputChannel(name) {
return vscode_1.window.createOutputChannel(name, {
log: true,
});
}
trace(message, ...args) {
this._outputChannel.trace(message, ...args);
}
debug(message, ...args) {
this._outputChannel.debug(message, ...args);
}
info(message, ...args) {
this._outputChannel.info(message, ...args);
}
warn(message, ...args) {
this._outputChannel.warn(message, ...args);
}
error(error, ...args) {
this._outputChannel.error(error, ...args);
}
}
//# sourceMappingURL=AzExtOutputChannel.js.map

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -1,113 +0,132 @@

// /*---------------------------------------------------------------------------------------------
// * Copyright (c) Microsoft Corporation. All rights reserved.
// * Licensed under the MIT License. See License.md in the project root for license information.
// *--------------------------------------------------------------------------------------------*/
// import * as vscode from 'vscode';
// import * as tas from 'vscode-tas-client';
// import { IActionContext, IExperimentationServiceAdapter } from '../index';
// import { IInternalTelemetryReporter } from './createTelemetryReporter';
// import { ext } from './extensionVariables';
// import { getPackageInfo } from './getPackageInfo';
// import { registerTelemetryHandler } from './index';
// export async function createExperimentationService(ctx: vscode.ExtensionContext, targetPopulation?: tas.TargetPopulation): Promise<IExperimentationServiceAdapter> {
// const result: ExperimentationServiceAdapter = new ExperimentationServiceAdapter();
// const { extensionId, extensionVersion } = getPackageInfo(ctx);
// if (targetPopulation === undefined) {
// if (ctx.extensionMode !== vscode.ExtensionMode.Production) {
// // Extension is being debugged
// targetPopulation = tas.TargetPopulation.Team;
// } else if (/alpha/ig.test(extensionVersion)) {
// // Extension version has "alpha"
// targetPopulation = tas.TargetPopulation.Insiders;
// } else if (/Insiders/ig.test(vscode.env.appName)) {
// // Running in VSCode Insiders
// targetPopulation = tas.TargetPopulation.Insiders;
// } else {
// targetPopulation = tas.TargetPopulation.Public;
// }
// }
// try {
// result.wrappedExperimentationService = await tas.getExperimentationServiceAsync(
// extensionId,
// extensionVersion,
// targetPopulation,
// new ExperimentationTelemetry(ext._internalReporter, ctx),
// ctx.globalState
// );
// } catch {
// // Best effort
// }
// return result;
// }
// class ExperimentationServiceAdapter implements IExperimentationServiceAdapter {
// public wrappedExperimentationService?: tas.IExperimentationService;
// /**
// * @deprecated Use `getCachedTreatmentVariable<boolean>('flight-name') instead
// */
// public async isCachedFlightEnabled(flight: string): Promise<boolean> {
// if (!this.wrappedExperimentationService) {
// return false;
// }
// return !!(await this.getCachedTreatmentVariable<boolean>(flight));
// }
// /**
// * @deprecated Use `getLiveTreatmentVariable<boolean>('flight-name') instead
// */
// public async isLiveFlightEnabled(flight: string): Promise<boolean> {
// if (!this.wrappedExperimentationService) {
// return false;
// }
// return !!(await this.getLiveTreatmentVariable<boolean>(flight));
// }
// public async getCachedTreatmentVariable<T extends string | number | boolean>(name: string): Promise<T | undefined> {
// if (!this.wrappedExperimentationService) {
// return Promise.resolve(undefined);
// }
// return Promise.resolve(this.wrappedExperimentationService.getTreatmentVariable<T>('vscode', name));
// }
// public async getLiveTreatmentVariable<T extends string | number | boolean>(name: string): Promise<T | undefined> {
// if (!this.wrappedExperimentationService) {
// return undefined;
// }
// return this.wrappedExperimentationService.getTreatmentVariableAsync('vscode', name);
// }
// }
// class ExperimentationTelemetry implements tas.IExperimentationTelemetry {
// private readonly sharedProperties: { [key: string]: string } = {};
// public constructor(private readonly telemetryReporter: IInternalTelemetryReporter, context: vscode.ExtensionContext) {
// context.subscriptions.push(registerTelemetryHandler((actionContext: IActionContext) => this.handleTelemetry(actionContext)));
// }
// /**
// * Implements `postEvent` for `IExperimentationTelemetry`.
// * @param eventName The name of the event
// * @param props The properties to attach to the event
// */
// public postEvent(eventName: string, props: Map<string, string>): void {
// const properties: { [key: string]: string } = {};
// for (const key of props.keys()) {
// properties[key] = <string>props.get(key);
// }
// Object.assign(properties, this.sharedProperties);
// // Treat the TAS query event as activation
// if (/query-expfeature/i.test(eventName)) {
// properties.isActivationEvent = 'true';
// }
// this.telemetryReporter.sendTelemetryErrorEvent(eventName, properties);
// }
// /**
// * Implements `setSharedProperty` for `IExperimentationTelemetry`
// * @param name The name of the property
// * @param value The value of the property
// */
// public setSharedProperty(name: string, value: string): void {
// this.sharedProperties[name] = value;
// }
// /**
// * Implements a telemetry handler that adds the shared properties to the event
// * @param actionContext The action context
// */
// public handleTelemetry(actionContext: IActionContext): void {
// Object.assign(actionContext.telemetry.properties, this.sharedProperties);
// }
// }
"use strict";
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.md in the project root for license information.
*--------------------------------------------------------------------------------------------*/
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.createExperimentationService = void 0;
const vscode = require("vscode");
const tas = require("vscode-tas-client");
const extensionVariables_1 = require("./extensionVariables");
const getPackageInfo_1 = require("./getPackageInfo");
const index_1 = require("./index");
function createExperimentationService(ctx, targetPopulation) {
return __awaiter(this, void 0, void 0, function* () {
const result = new ExperimentationServiceAdapter();
const { extensionId, extensionVersion } = (0, getPackageInfo_1.getPackageInfo)(ctx);
if (targetPopulation === undefined) {
if (ctx.extensionMode !== vscode.ExtensionMode.Production) {
// Extension is being debugged
targetPopulation = tas.TargetPopulation.Team;
}
else if (/alpha/ig.test(extensionVersion)) {
// Extension version has "alpha"
targetPopulation = tas.TargetPopulation.Insiders;
}
else if (/Insiders/ig.test(vscode.env.appName)) {
// Running in VSCode Insiders
targetPopulation = tas.TargetPopulation.Insiders;
}
else {
targetPopulation = tas.TargetPopulation.Public;
}
}
try {
result.wrappedExperimentationService = yield tas.getExperimentationServiceAsync(extensionId, extensionVersion, targetPopulation, new ExperimentationTelemetry(extensionVariables_1.ext._internalReporter, ctx), ctx.globalState);
}
catch (_a) {
// Best effort
}
return result;
});
}
exports.createExperimentationService = createExperimentationService;
class ExperimentationServiceAdapter {
/**
* @deprecated Use `getCachedTreatmentVariable<boolean>('flight-name') instead
*/
isCachedFlightEnabled(flight) {
return __awaiter(this, void 0, void 0, function* () {
if (!this.wrappedExperimentationService) {
return false;
}
return !!(yield this.getCachedTreatmentVariable(flight));
});
}
/**
* @deprecated Use `getLiveTreatmentVariable<boolean>('flight-name') instead
*/
isLiveFlightEnabled(flight) {
return __awaiter(this, void 0, void 0, function* () {
if (!this.wrappedExperimentationService) {
return false;
}
return !!(yield this.getLiveTreatmentVariable(flight));
});
}
getCachedTreatmentVariable(name) {
return __awaiter(this, void 0, void 0, function* () {
if (!this.wrappedExperimentationService) {
return Promise.resolve(undefined);
}
return Promise.resolve(this.wrappedExperimentationService.getTreatmentVariable('vscode', name));
});
}
getLiveTreatmentVariable(name) {
return __awaiter(this, void 0, void 0, function* () {
if (!this.wrappedExperimentationService) {
return undefined;
}
return this.wrappedExperimentationService.getTreatmentVariableAsync('vscode', name);
});
}
}
class ExperimentationTelemetry {
constructor(telemetryReporter, context) {
this.telemetryReporter = telemetryReporter;
this.sharedProperties = {};
context.subscriptions.push((0, index_1.registerTelemetryHandler)((actionContext) => this.handleTelemetry(actionContext)));
}
/**
* Implements `postEvent` for `IExperimentationTelemetry`.
* @param eventName The name of the event
* @param props The properties to attach to the event
*/
postEvent(eventName, props) {
const properties = {};
for (const key of props.keys()) {
properties[key] = props.get(key);
}
Object.assign(properties, this.sharedProperties);
// Treat the TAS query event as activation
if (/query-expfeature/i.test(eventName)) {
properties.isActivationEvent = 'true';
}
this.telemetryReporter.sendTelemetryErrorEvent(eventName, properties);
}
/**
* Implements `setSharedProperty` for `IExperimentationTelemetry`
* @param name The name of the property
* @param value The value of the property
*/
setSharedProperty(name, value) {
this.sharedProperties[name] = value;
}
/**
* Implements a telemetry handler that adds the shared properties to the event
* @param actionContext The action context
*/
handleTelemetry(actionContext) {
Object.assign(actionContext.telemetry.properties, this.sharedProperties);
}
}
//# sourceMappingURL=createExperimentationService.js.map

@@ -8,5 +8,5 @@ "use strict";

exports.createTelemetryReporter = void 0;
const extension_telemetry_1 = require("@vscode/extension-telemetry");
const process = require("process");
const vscode = require("vscode");
const extension_telemetry_1 = require("@vscode/extension-telemetry");
const DebugReporter_1 = require("./DebugReporter");

@@ -13,0 +13,0 @@ const getPackageInfo_1 = require("./getPackageInfo");

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -21,15 +21,14 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.registerReportIssueCommand = exports.maskValue = exports.callWithMaskHandling = exports.addExtensionValueToMask = exports.registerUIExtensionVariables = exports.createAzExtOutputChannel = exports.apiUtils = void 0;
// re-export api types and utils
var vscode_azureresources_api_1 = require("@microsoft/vscode-azureresources-api");
Object.defineProperty(exports, "apiUtils", { enumerable: true, get: function () { return vscode_azureresources_api_1.apiUtils; } });
exports.apiUtils = exports.registerReportIssueCommand = exports.maskValue = exports.callWithMaskHandling = exports.addExtensionValueToMask = exports.registerUIExtensionVariables = exports.createExperimentationService = exports.createAzExtLogOutputChannel = exports.createAzExtOutputChannel = void 0;
__exportStar(require("./activityLog/activities/ExecuteActivity"), exports);
__exportStar(require("./activityLog/Activity"), exports);
var AzExtOutputChannel_1 = require("./AzExtOutputChannel");
Object.defineProperty(exports, "createAzExtOutputChannel", { enumerable: true, get: function () { return AzExtOutputChannel_1.createAzExtOutputChannel; } });
Object.defineProperty(exports, "createAzExtLogOutputChannel", { enumerable: true, get: function () { return AzExtOutputChannel_1.createAzExtLogOutputChannel; } });
__exportStar(require("./AzExtTreeFileSystem"), exports);
//export { createExperimentationService } from './createExperimentationService';
__exportStar(require("./DialogResponses"), exports);
__exportStar(require("./activityLog/Activity"), exports);
__exportStar(require("./activityLog/activities/ExecuteActivity"), exports);
__exportStar(require("./callWithTelemetryAndErrorHandling"), exports);
__exportStar(require("./createApiProvider"), exports);
var createExperimentationService_1 = require("./createExperimentationService");
Object.defineProperty(exports, "createExperimentationService", { enumerable: true, get: function () { return createExperimentationService_1.createExperimentationService; } });
__exportStar(require("./DialogResponses"), exports);
__exportStar(require("./errors"), exports);

@@ -70,3 +69,3 @@ __exportStar(require("./extensionUserAgent"), exports);

__exportStar(require("./utils/credentialUtils"), exports);
// export * from './utils/findFreePort';
__exportStar(require("./utils/findFreePort"), exports);
__exportStar(require("./utils/nonNull"), exports);

@@ -80,3 +79,6 @@ __exportStar(require("./utils/openUrl"), exports);

__exportStar(require("./wizard/DeleteConfirmationStep"), exports);
// re-export api types and utils
var vscode_azureresources_api_1 = require("@microsoft/vscode-azureresources-api");
Object.defineProperty(exports, "apiUtils", { enumerable: true, get: function () { return vscode_azureresources_api_1.apiUtils; } });
// NOTE: The auto-fix action "source.organizeImports" does weird things with this file, but there doesn't seem to be a way to disable it on a per-file basis so we'll just let it happen
//# sourceMappingURL=index.js.map

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -8,2 +8,4 @@ "use strict";

exports.parseError = void 0;
/* eslint-disable */
const htmlToText = require("html-to-text");
const localize_1 = require("./localize");

@@ -61,3 +63,3 @@ const parseJson_1 = require("./utils/parseJson");

message || (message = (0, localize_1.localize)('unknownError', 'Unknown Error'));
//message = parseIfHtml(message);
message = parseIfHtml(message);
// Azure storage SDK errors are presented in XML

@@ -97,27 +99,26 @@ // https://github.com/Azure/azure-sdk-for-js/issues/6927

}
// function parseIfHtml(message: string): string {
// if (/<html/i.test(message)) {
// try {
// var headerOptions = { leadingLineBreaks: 1, trailingLineBreaks: 1, uppercase: false };
// return htmlToText.convert(
// message,
// {
// selectors: [
// { selector: 'h1', options: headerOptions },
// { selector: 'h2', options: headerOptions },
// { selector: 'h3', options: headerOptions },
// { selector: 'h4', options: headerOptions },
// { selector: 'h5', options: headerOptions },
// { selector: 'h6', options: headerOptions },
// { selector: 'img', format: 'skip' },
// { selector: 'table', options: { uppercaseHeaderCells: false } }
// ],
// wordwrap: false
// });
// } catch (err) {
// // ignore
// }
// }
// return message;
// }
function parseIfHtml(message) {
if (/<html/i.test(message)) {
try {
var headerOptions = { leadingLineBreaks: 1, trailingLineBreaks: 1, uppercase: false };
return htmlToText.convert(message, {
selectors: [
{ selector: 'h1', options: headerOptions },
{ selector: 'h2', options: headerOptions },
{ selector: 'h3', options: headerOptions },
{ selector: 'h4', options: headerOptions },
{ selector: 'h5', options: headerOptions },
{ selector: 'h6', options: headerOptions },
{ selector: 'img', format: 'skip' },
{ selector: 'table', options: { uppercaseHeaderCells: false } }
],
wordwrap: false
});
}
catch (err) {
// ignore
}
}
return message;
}
function parseIfXml(message) {

@@ -124,0 +125,0 @@ const matches = message.match(/<Message>(.*)<\/Message>/si);

@@ -21,7 +21,4 @@ "use strict";

const RecursiveQuickPickStep_1 = require("../contextValue/RecursiveQuickPickStep");
const getLastNode_1 = require("../getLastNode");
const errors_1 = require("../../errors");
const AzureWizard_1 = require("../../wizard/AzureWizard");
const CompatibilityRecursiveQuickPickStep_1 = require("../contextValue/compatibility/CompatibilityRecursiveQuickPickStep");
const vscode_azureresources_api_1 = require("@microsoft/vscode-azureresources-api");
const runQuickPickWizard_1 = require("../runQuickPickWizard");
function azureResourceExperience(context, tdp, resourceTypes, childItemFilter) {

@@ -54,6 +51,3 @@ return __awaiter(this, void 0, void 0, function* () {

}
// Fill in the `pickedNodes` property
const wizardContext = Object.assign({}, context);
wizardContext.pickedNodes = [];
const wizard = new AzureWizard_1.AzureWizard(wizardContext, {
return yield (0, runQuickPickWizard_1.runQuickPickWizard)(context, {
hideStepCount: true,

@@ -63,10 +57,2 @@ promptSteps: promptSteps,

});
yield wizard.prompt();
const lastPickedItem = (0, getLastNode_1.getLastNode)(wizardContext);
if (!lastPickedItem) {
throw new errors_1.NoResourceFoundError(wizardContext);
}
else {
return (!context.dontUnwrap && (0, vscode_azureresources_api_1.isWrapper)(lastPickedItem)) ? lastPickedItem.unwrap() : lastPickedItem;
}
});

@@ -73,0 +59,0 @@ }

@@ -13,11 +13,11 @@ "use strict";

exports.PickTreeItemWithCompatibility = void 0;
const vscode_azureresources_api_1 = require("@microsoft/vscode-azureresources-api");
const errors_1 = require("../../../errors");
const azureResourceExperience_1 = require("../azureResourceExperience");
const subscriptionExperience_1 = require("../subscriptionExperience");
const isAzExtTreeItem_1 = require("../../../tree/isAzExtTreeItem");
const credentialUtils_1 = require("../../../utils/credentialUtils");
const CompatibilityRecursiveQuickPickStep_1 = require("../../contextValue/compatibility/CompatibilityRecursiveQuickPickStep");
const AzureWizard_1 = require("../../../wizard/AzureWizard");
const CompatibilityRecursiveQuickPickStep_1 = require("../../contextValue/compatibility/CompatibilityRecursiveQuickPickStep");
const getLastNode_1 = require("../../getLastNode");
const azureResourceExperience_1 = require("../azureResourceExperience");
const subscriptionExperience_1 = require("../subscriptionExperience");
const errors_1 = require("../../../errors");
const vscode_azureresources_api_1 = require("@microsoft/vscode-azureresources-api");
var PickTreeItemWithCompatibility;

@@ -24,0 +24,0 @@ (function (PickTreeItemWithCompatibility) {

@@ -18,6 +18,3 @@ "use strict";

const RecursiveQuickPickStep_1 = require("../contextValue/RecursiveQuickPickStep");
const getLastNode_1 = require("../getLastNode");
const errors_1 = require("../../errors");
const AzureWizard_1 = require("../../wizard/AzureWizard");
const vscode_azureresources_api_1 = require("@microsoft/vscode-azureresources-api");
const runQuickPickWizard_1 = require("../runQuickPickWizard");
function contextValueExperience(context, tdp, contextValueFilter) {

@@ -31,17 +28,6 @@ return __awaiter(this, void 0, void 0, function* () {

];
// Fill in the `pickedNodes` property
const wizardContext = Object.assign({}, context);
wizardContext.pickedNodes = [];
const wizard = new AzureWizard_1.AzureWizard(wizardContext, {
return yield (0, runQuickPickWizard_1.runQuickPickWizard)(context, {
hideStepCount: true,
promptSteps: promptSteps,
});
yield wizard.prompt();
const lastPickedItem = (0, getLastNode_1.getLastNode)(wizardContext);
if (!lastPickedItem) {
throw new errors_1.NoResourceFoundError(wizardContext);
}
else {
return (0, vscode_azureresources_api_1.isWrapper)(lastPickedItem) ? lastPickedItem.unwrap() : lastPickedItem;
}
});

@@ -48,0 +34,0 @@ }

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -21,7 +21,7 @@ "use strict";

const getLastNode_1 = require("./getLastNode");
function runQuickPickWizard(context, wizardOptions) {
function runQuickPickWizard(context, wizardOptions, startingNode) {
return __awaiter(this, void 0, void 0, function* () {
// Fill in the `pickedNodes` property
const wizardContext = Object.assign({}, context);
wizardContext.pickedNodes = [];
wizardContext.pickedNodes = startingNode ? [startingNode] : [];
const wizard = new AzureWizard_1.AzureWizard(wizardContext, Object.assign({ hideStepCount: true, showLoadingPrompt: true }, wizardOptions));

@@ -28,0 +28,0 @@ yield wizard.prompt();

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -17,2 +17,5 @@ "use strict";

exports.registerReportIssueCommand = exports.cacheIssueForCommand = void 0;
const dayjs = require("dayjs");
// eslint-disable-next-line import/no-internal-modules
const relativeTime = require("dayjs/plugin/relativeTime");
const localize_1 = require("./localize");

@@ -22,3 +25,3 @@ const registerCommand_1 = require("./registerCommand");

const nonNull_1 = require("./utils/nonNull");
// dayjs.extend(relativeTime);
dayjs.extend(relativeTime);
let cachedIssues;

@@ -53,3 +56,3 @@ function cacheIssueForCommand(issue) {

description: i.error.errorType,
//detail: `${i.callbackId} - ${dayjs(i.time).fromNow()}`,
detail: `${i.callbackId} - ${dayjs(i.time).fromNow()}`,
data: i

@@ -56,0 +59,0 @@ };

@@ -71,3 +71,3 @@ "use strict";

}
const simpleLink = yield createNewIssueLinkFromBody(body);
const simpleLink = createNewIssueLinkFromBody(body);
if (simpleLink.length <= exports.maxUrlLength) {

@@ -83,7 +83,5 @@ return simpleLink;

function createNewIssueLinkFromBody(issueBody) {
return __awaiter(this, void 0, void 0, function* () {
const { extensionName, bugsUrl } = yield (0, getPackageInfo_1.getPackageInfo)();
const baseUrl = bugsUrl || `https://github.com/Microsoft/${extensionName}/issues`;
return `${baseUrl}/new?body=${encodeURIComponent(issueBody)}`;
});
const { extensionName, bugsUrl } = (0, getPackageInfo_1.getPackageInfo)();
const baseUrl = bugsUrl || `https://github.com/Microsoft/${extensionName}/issues`;
return `${baseUrl}/new?body=${encodeURIComponent(issueBody)}`;
}

@@ -90,0 +88,0 @@ function createBodyDetail(detailName, detail) {

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -174,5 +174,5 @@ "use strict";

function convertToUri(resource) {
return typeof resource === 'string' ? vscode_1.Uri.parse(resource) : resource;
return typeof resource === 'string' ? vscode_1.Uri.file(resource) : resource;
}
})(AzExtFsExtra = exports.AzExtFsExtra || (exports.AzExtFsExtra = {}));
//# sourceMappingURL=AzExtFsExtra.js.map

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -1,61 +0,77 @@

// /*---------------------------------------------------------------------------------------------
// * Copyright (c) Microsoft Corporation. All rights reserved.
// * Licensed under the MIT License. See License.txt in the project root for license information.
// *--------------------------------------------------------------------------------------------*/
// import * as net from 'net';
// import { randomUtils } from './randomUtils';
// const DefaultTimeout = 500; // Spend at most 500 ms
// const DefaultMaxAttempts = 25; // On at most 25 attempts
// const MinRandomPort = 10000;
// const MaxRandomPort = 64000;
// /**
// * Finds an available port.
// * NOTE: If another listener is on '0.0.0.0', this will take the '127.0.0.1' allocation from them!
// * @param startPort (Optional) The first port to try. By default, a random port from 10000 (inclusive) to 64000 (exclusive)
// * @param maxAttempts (Optional) The maximum number of attempts. 25, by default.
// * @param timeout (Optional) The maximum time to spend. 500 ms, by default.
// * Adapted from https://github.com/microsoft/vscode/blob/0bf30719729d76dc3db934ac2e04eed892a9ae7e/src/vs/base/node/ports.ts#L150-L191.
// * Notable differences: Arguments are optional; if a port attempted is taken, the attempt count is added to it for the next try, this will scan out of a range of taken ports faster
// */
// export async function findFreePort(startPort: number = 0, maxAttempts: number = DefaultMaxAttempts, timeout: number = DefaultTimeout): Promise<number> {
// // If a start port isn't given, the default is set to 0, and the `||=` will overwrite it with a random value
// startPort ||= randomUtils.getRandomInteger(MinRandomPort, MaxRandomPort);
// let resolved: boolean = false;
// let timeoutHandle: NodeJS.Timeout | undefined = undefined;
// let countTried: number = 1;
// const server = net.createServer({ pauseOnConnect: true });
// function doResolve(port: number, resolve: (port: number) => void) {
// if (!resolved) {
// resolved = true;
// server.removeAllListeners();
// server.close();
// if (timeoutHandle) {
// clearTimeout(timeoutHandle);
// }
// resolve(port);
// }
// }
// return new Promise<number>(resolve => {
// timeoutHandle = setTimeout(() => {
// doResolve(0, resolve);
// }, timeout);
// server.on('listening', () => {
// doResolve(startPort, resolve);
// });
// server.on('error', err => {
// // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any
// if (err && ((<any>err).code === 'EADDRINUSE' || (<any>err).code === 'EACCES') && (countTried < maxAttempts)) {
// startPort += countTried;
// countTried++;
// server.listen(startPort, '127.0.0.1');
// } else {
// doResolve(0, resolve);
// }
// });
// server.on('close', () => {
// doResolve(0, resolve);
// });
// server.listen(startPort, '127.0.0.1');
// });
// }
"use strict";
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.findFreePort = void 0;
const net = require("net");
const randomUtils_1 = require("./randomUtils");
const DefaultTimeout = 500; // Spend at most 500 ms
const DefaultMaxAttempts = 25; // On at most 25 attempts
const MinRandomPort = 10000;
const MaxRandomPort = 64000;
/**
* Finds an available port.
* NOTE: If another listener is on '0.0.0.0', this will take the '127.0.0.1' allocation from them!
* @param startPort (Optional) The first port to try. By default, a random port from 10000 (inclusive) to 64000 (exclusive)
* @param maxAttempts (Optional) The maximum number of attempts. 25, by default.
* @param timeout (Optional) The maximum time to spend. 500 ms, by default.
* Adapted from https://github.com/microsoft/vscode/blob/0bf30719729d76dc3db934ac2e04eed892a9ae7e/src/vs/base/node/ports.ts#L150-L191.
* Notable differences: Arguments are optional; if a port attempted is taken, the attempt count is added to it for the next try, this will scan out of a range of taken ports faster
*/
function findFreePort(startPort = 0, maxAttempts = DefaultMaxAttempts, timeout = DefaultTimeout) {
return __awaiter(this, void 0, void 0, function* () {
// If a start port isn't given, the default is set to 0, and the `||=` will overwrite it with a random value
startPort || (startPort = randomUtils_1.randomUtils.getRandomInteger(MinRandomPort, MaxRandomPort));
let resolved = false;
let timeoutHandle = undefined;
let countTried = 1;
const server = net.createServer({ pauseOnConnect: true });
function doResolve(port, resolve) {
if (!resolved) {
resolved = true;
server.removeAllListeners();
server.close();
if (timeoutHandle) {
clearTimeout(timeoutHandle);
}
resolve(port);
}
}
return new Promise(resolve => {
timeoutHandle = setTimeout(() => {
doResolve(0, resolve);
}, timeout);
server.on('listening', () => {
doResolve(startPort, resolve);
});
server.on('error', err => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any
if (err && (err.code === 'EADDRINUSE' || err.code === 'EACCES') && (countTried < maxAttempts)) {
startPort += countTried;
countTried++;
server.listen(startPort, '127.0.0.1');
}
else {
doResolve(0, resolve);
}
});
server.on('close', () => {
doResolve(0, resolve);
});
server.listen(startPort, '127.0.0.1');
});
});
}
exports.findFreePort = findFreePort;
//# sourceMappingURL=findFreePort.js.map

@@ -0,0 +0,0 @@ "use strict";

@@ -8,2 +8,3 @@ "use strict";

exports.nonNullValueAndProp = exports.nonNullOrEmptyValue = exports.nonNullValue = exports.nonNullProp = void 0;
const util_1 = require("util");
/**

@@ -22,3 +23,3 @@ * Retrieves a property by name from an object and checks that it's not null and not undefined. It is strongly typed

function nonNullValue(value, propertyNameOrMessage) {
if (isNullOrUndefined(value)) {
if ((0, util_1.isNullOrUndefined)(value)) {
throw new Error('Internal error: Expected value to be neither null nor undefined'

@@ -50,5 +51,2 @@ + (propertyNameOrMessage ? `: ${propertyNameOrMessage}` : ''));

exports.nonNullValueAndProp = nonNullValueAndProp;
function isNullOrUndefined(value) {
return value === null || value === undefined;
}
//# sourceMappingURL=nonNull.js.map

@@ -17,7 +17,8 @@ "use strict";

exports.openUrl = void 0;
const vscode = require("vscode");
const open = require("open");
function openUrl(url) {
return __awaiter(this, void 0, void 0, function* () {
// Using this functionality is blocked by https://github.com/Microsoft/vscode/issues/85930
yield vscode.commands.executeCommand('vscode.open', vscode.Uri.parse(url));
// await vscode.commands.executeCommand('vscode.open', vscode.Uri.parse(url));
yield open(url);
});

@@ -24,0 +25,0 @@ }

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

{
"name": "@microsoft/vscode-azext-utils",
"author": "Microsoft Corporation",
"version": "0.5.2-alpha.0",
"version": "0.5.2",
"description": "Common UI tools for developing Azure extensions for VS Code",

@@ -37,11 +37,9 @@ "tags": [

"@vscode/extension-telemetry": "^0.6.2",
"crypto-randomuuid": "^1.0.0",
"dayjs": "^1.11.2",
"escape-string-regexp": "^2.0.0",
"html-to-text": "^8.2.0",
"open": "^8.0.4",
"semver": "^7.3.7",
"text-encoding": "^0.7.0",
"uuid": "^9.0.0",
"vscode-nls": "^5.0.1",
"vscode-tas-client": "^0.1.47",
"vscode-uri": "^3.0.6"
"vscode-tas-client": "^0.1.47"
},

@@ -56,3 +54,3 @@ "devDependencies": {

"@types/semver": "^7.3.9",
"@types/vscode": "1.64.0",
"@types/vscode": "1.76.0",
"@typescript-eslint/eslint-plugin": "^5.53.0",

@@ -59,0 +57,0 @@ "@vscode/test-electron": "^2.1.5",

@@ -51,2 +51,68 @@ # VSCode Azure SDK for Node.js - UI Tools (Preview)

## Pick tree items (Azure Resources API V2)
The Azure Resources API exposes a `TreeDataProvider` for both the Azure resources view and the Workspace resources view. `azureResourceTreeDataProvider` and `workspaceResourceTreeDataProvider` are exposed by the Azure Resources API.
We've created a set of utilities to provide a tree node picking experience that uses quick pick steps in a wizards.
#### Pick an Azure subscription
```ts
const subscription = await subscriptionExperience(context, api.resources.azureResourceTreeDataProvider);
```
#### Pick an Azure resource
```ts
// pick an Azure Resource, in this case a Function App
const functionApp = await azureResourceExperience(context, api.resources.azureResourceTreeDataProvider, AzExtResourceType.FunctionApp);
```
#### Pick a descendent of an Azure resource
```ts
// pick an Azure Resource, in this case a Function App, and then select a descendant of the Function App, in this case an App Setting item
const functionAppAppSetting = await azureResourceExperience(context, api.resources.azureResourceTreeDataProvider, AzExtResourceType.FunctionApp, {
include: ['appSettingContextValue']
});
```
#### Pick a workspace item
```ts
// pick an item based on context value
const item = await contextValueExperience(context, api.resources.workspaceResourceTreeDataProvider, {
include: ['itemContextValue']
});
```
### Run a wizard with custom pick steps
If you more granular control over the quick pick steps in the wizard, you can use `runQuickPickWizard` to run a fully customizable quick pick wizard. Here's an example of picking a Function App using `runQuickPickWizard`.
```ts
import { runQuickPickWizard, QuickPickAzureSubscriptionStep, QuickPickGroupStep, QuickPickAzureResourceStep } from '@microsoft/vscode-azext-utils';
const tdp = ext.rgApiV2.resources.azureResourceTreeDataProvider;
const functionApp = await runQuickPickWizard(context, {
promptSteps: [
// first step: pick a subscription
new QuickPickAzureSubscriptionStep(tdp),
// second step: pick a group, if we are grouped by resource type, pick function apps automatically
new QuickPickGroupStep(tdp, {
groupType: [AzExtResourceType.FunctionApp],
}),
// third step: pick a resource, in this case a function app
new QuickPickAzureResourceStep(tdp, {
resourceTypes: [AzExtResourceType.FunctionApp],
skipIfOne: false,
}, {
placeHolder: 'Select a Function App',
}),
]
});
```
## Azure Extension Tree Data Provider

@@ -53,0 +119,0 @@

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc