Used shared webpack dev code (#770)
* Used shared webpack dev code * fix * remove ts-loader dep * PR fixes * dev 0.1.7 * fixes * fixes * package lock
This commit is contained in:
Родитель
4a9e5811ac
Коммит
3ee4a3d2a6
|
@ -8,7 +8,7 @@ import { SubscriptionModels } from 'azure-arm-resource';
|
|||
import { ResourceGroup } from "azure-arm-resource/lib/resource/models";
|
||||
import * as vscode from "vscode";
|
||||
import { skus } from '../../constants';
|
||||
import { dockerExplorerProvider } from '../../dockerExtension';
|
||||
import { dockerExplorerProvider } from '../../extension';
|
||||
import { ext } from '../../extensionVariables';
|
||||
import { isValidAzureName } from '../../utils/Azure/common';
|
||||
import { AzureUtilityManager } from '../../utils/azureUtilityManager';
|
||||
|
|
|
@ -2,11 +2,12 @@
|
|||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See LICENSE.md in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Registry } from "azure-arm-containerregistry/lib/models";
|
||||
import * as vscode from "vscode";
|
||||
import { DialogResponses } from "vscode-azureextensionui";
|
||||
import { dockerExplorerProvider } from '../../dockerExtension';
|
||||
import { AzureImageTagNode } from '../../explorer/models/azureRegistryNodes';
|
||||
import { dockerExplorerProvider } from '../../extension';
|
||||
import { ext } from "../../extensionVariables";
|
||||
import * as acrTools from '../../utils/Azure/acrTools';
|
||||
import { AzureImage } from "../../utils/Azure/models/image";
|
||||
|
|
|
@ -2,11 +2,12 @@
|
|||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See LICENSE.md in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Registry } from "azure-arm-containerregistry/lib/models";
|
||||
import { SubscriptionModels } from "azure-arm-resource";
|
||||
import * as vscode from "vscode";
|
||||
import { dockerExplorerProvider } from '../../dockerExtension';
|
||||
import { AzureRegistryNode } from '../../explorer/models/azureRegistryNodes';
|
||||
import { dockerExplorerProvider } from '../../extension';
|
||||
import * as acrTools from '../../utils/Azure/acrTools';
|
||||
import { AzureUtilityManager } from '../../utils/azureUtilityManager';
|
||||
import { nonNullProp } from "../../utils/nonNull";
|
||||
|
|
|
@ -2,10 +2,11 @@
|
|||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See LICENSE.md in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Registry } from "azure-arm-containerregistry/lib/models";
|
||||
import * as vscode from "vscode";
|
||||
import { dockerExplorerProvider } from '../../dockerExtension';
|
||||
import { AzureRepositoryNode } from '../../explorer/models/azureRegistryNodes';
|
||||
import { dockerExplorerProvider } from '../../extension';
|
||||
import * as acrTools from '../../utils/Azure/acrTools';
|
||||
import { Repository } from "../../utils/Azure/models/repository";
|
||||
import { confirmUserIntent, quickPickACRRegistry, quickPickACRRepository } from '../utils/quick-pick-azure';
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
|
||||
import vscode = require('vscode');
|
||||
import { IActionContext } from 'vscode-azureextensionui';
|
||||
import { dockerExplorerProvider } from '../dockerExtension';
|
||||
import { ContainerNode } from '../explorer/models/containerNode';
|
||||
import { RootNode } from '../explorer/models/rootNode';
|
||||
import { dockerExplorerProvider } from '../extension';
|
||||
import { AllStatusFilter, docker, ListContainerDescOptions } from './utils/docker-endpoint';
|
||||
import { quickPickContainerOrAll } from './utils/quick-pick-container';
|
||||
|
||||
|
|
|
@ -3,14 +3,13 @@
|
|||
* Licensed under the MIT License. See LICENSE.md in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { ContainerDesc } from 'dockerode';
|
||||
import vscode = require('vscode');
|
||||
import { IActionContext } from 'vscode-azureextensionui';
|
||||
import { dockerExplorerProvider } from '../dockerExtension';
|
||||
import { ContainerNode } from '../explorer/models/containerNode';
|
||||
import { RootNode } from '../explorer/models/rootNode';
|
||||
import { dockerExplorerProvider } from '../extension';
|
||||
import { docker, ListContainerDescOptions } from './utils/docker-endpoint';
|
||||
import { ContainerItem, quickPickContainer, quickPickContainerOrAll } from './utils/quick-pick-container';
|
||||
import { quickPickContainerOrAll } from './utils/quick-pick-container';
|
||||
|
||||
export async function restartContainer(actionContext: IActionContext, context: RootNode | ContainerNode | undefined): Promise<void> {
|
||||
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
* Licensed under the MIT License. See LICENSE.md in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { dockerExplorerProvider } from '../dockerExtension';
|
||||
import { ContainerNode } from '../explorer/models/containerNode';
|
||||
import { dockerExplorerProvider } from '../extension';
|
||||
import { docker, ListContainerDescOptions } from './utils/docker-endpoint';
|
||||
import { ContainerItem, quickPickContainer, quickPickContainerOrAll } from './utils/quick-pick-container';
|
||||
import { quickPickContainerOrAll } from './utils/quick-pick-container';
|
||||
|
||||
import vscode = require('vscode');
|
||||
import { IActionContext } from 'vscode-azureextensionui';
|
||||
|
|
|
@ -6,8 +6,7 @@
|
|||
'use strict';
|
||||
|
||||
import { CancellationToken, CompletionItem, CompletionItemKind, CompletionItemProvider, Position, TextDocument, Uri } from 'vscode';
|
||||
import { KeyInfo } from '../dockerExtension';
|
||||
import hub = require('../dockerHubSearch');
|
||||
import { KeyInfo } from '../extension';
|
||||
import helper = require('../helpers/suggestSupportHelper');
|
||||
import composeVersions from './dockerComposeKeyInfo';
|
||||
|
||||
|
|
|
@ -6,8 +6,7 @@
|
|||
'use strict';
|
||||
|
||||
import { CancellationToken, Hover, HoverProvider, MarkedString, Position, Range, TextDocument } from 'vscode';
|
||||
import { KeyInfo } from "../dockerExtension";
|
||||
import hub = require('../dockerHubSearch');
|
||||
import { KeyInfo } from "../extension";
|
||||
import suggestHelper = require('../helpers/suggestSupportHelper');
|
||||
import parser = require('../parser');
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* Licensed under the MIT License. See LICENSE.md in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { ComposeVersionKeys, KeyInfo } from "../dockerExtension";
|
||||
import { ComposeVersionKeys, KeyInfo } from "../extension";
|
||||
|
||||
// Define the keys that are shared between all compose file versions,
|
||||
// regardless of the major/minor version (e.g. v1-v2.1+).
|
||||
|
|
|
@ -1,427 +0,0 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See LICENSE.md in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import * as fse from 'fs-extra';
|
||||
import * as path from 'path';
|
||||
import { CoreOptions } from 'request';
|
||||
import * as request from 'request-promise-native';
|
||||
import { RequestPromise } from 'request-promise-native';
|
||||
import * as vscode from 'vscode';
|
||||
import { AzureUserInput, callWithTelemetryAndErrorHandling, createTelemetryReporter, IActionContext, registerCommand as uiRegisterCommand, registerUIExtensionVariables, TelemetryProperties, UserCancelledError } from 'vscode-azureextensionui';
|
||||
import { ConfigurationParams, DidChangeConfigurationNotification, DocumentSelector, LanguageClient, LanguageClientOptions, Middleware, ServerOptions, TransportKind } from 'vscode-languageclient/lib/main';
|
||||
import { viewACRLogs } from "./commands/azureCommands/acr-logs";
|
||||
import { LogContentProvider } from "./commands/azureCommands/acr-logs-utils/logFileManager";
|
||||
import { createRegistry } from './commands/azureCommands/create-registry';
|
||||
import { deleteAzureImage, untagAzureImage } from './commands/azureCommands/delete-image';
|
||||
import { deleteAzureRegistry } from './commands/azureCommands/delete-registry';
|
||||
import { deleteRepository } from './commands/azureCommands/delete-repository';
|
||||
import { pullImageFromAzure, pullRepoFromAzure } from './commands/azureCommands/pull-from-azure';
|
||||
import { quickBuild } from "./commands/azureCommands/quick-build";
|
||||
import { runTask, runTaskFile } from "./commands/azureCommands/run-task";
|
||||
import { showTaskProperties } from "./commands/azureCommands/show-task";
|
||||
import { TaskContentProvider } from "./commands/azureCommands/task-utils/showTaskManager";
|
||||
import { buildImage } from './commands/build-image';
|
||||
import { composeDown, composeRestart, composeUp } from './commands/docker-compose';
|
||||
import inspectImage from './commands/inspect-image';
|
||||
import { openShellContainer } from './commands/open-shell-container';
|
||||
import { pushImage } from './commands/push-image';
|
||||
import { consolidateDefaultRegistrySettings, setRegistryAsDefault } from './commands/registrySettings';
|
||||
import { removeContainer } from './commands/remove-container';
|
||||
import { removeImage } from './commands/remove-image';
|
||||
import { restartContainer } from './commands/restart-container';
|
||||
import { showLogsContainer } from './commands/showlogs-container';
|
||||
import { startAzureCLI, startContainer, startContainerInteractive } from './commands/start-container';
|
||||
import { stopContainer } from './commands/stop-container';
|
||||
import { systemPrune } from './commands/system-prune';
|
||||
import { tagImage } from './commands/tag-image';
|
||||
import { docker } from './commands/utils/docker-endpoint';
|
||||
import { DefaultTerminalProvider } from './commands/utils/TerminalProvider';
|
||||
import { DockerDebugConfigProvider } from './configureWorkspace/configDebugProvider';
|
||||
import { configure, configureApi, ConfigureApiOptions } from './configureWorkspace/configure';
|
||||
import { COMPOSE_FILE_GLOB_PATTERN } from './constants';
|
||||
import { registerDebugConfigurationProvider } from './debugging/coreclr/registerDebugger';
|
||||
import { DockerComposeCompletionItemProvider } from './dockerCompose/dockerComposeCompletionItemProvider';
|
||||
import { DockerComposeHoverProvider } from './dockerCompose/dockerComposeHoverProvider';
|
||||
import composeVersionKeys from './dockerCompose/dockerComposeKeyInfo';
|
||||
import { DockerComposeParser } from './dockerCompose/dockerComposeParser';
|
||||
import { DockerfileCompletionItemProvider } from './dockerfile/dockerfileCompletionItemProvider';
|
||||
import DockerInspectDocumentContentProvider, { SCHEME as DOCKER_INSPECT_SCHEME } from './documentContentProviders/dockerInspect';
|
||||
import { AzureAccountWrapper } from './explorer/deploy/azureAccountWrapper';
|
||||
import * as util from './explorer/deploy/util';
|
||||
import { WebAppCreator } from './explorer/deploy/webAppCreator';
|
||||
import { DockerExplorerProvider } from './explorer/dockerExplorer';
|
||||
import { AzureImageTagNode, AzureRegistryNode, AzureRepositoryNode } from './explorer/models/azureRegistryNodes';
|
||||
import { ContainerNode } from './explorer/models/containerNode';
|
||||
import { connectCustomRegistry, disconnectCustomRegistry } from './explorer/models/customRegistries';
|
||||
import { DockerHubImageTagNode, DockerHubOrgNode, DockerHubRepositoryNode } from './explorer/models/dockerHubNodes';
|
||||
import { ImageNode } from './explorer/models/imageNode';
|
||||
import { NodeBase } from './explorer/models/nodeBase';
|
||||
import { RootNode } from './explorer/models/rootNode';
|
||||
import { browseAzurePortal } from './explorer/utils/browseAzurePortal';
|
||||
import { browseDockerHub, dockerHubLogout } from './explorer/utils/dockerHubUtils';
|
||||
import { ext } from './extensionVariables';
|
||||
import { addUserAgent } from './utils/addUserAgent';
|
||||
import { AzureUtilityManager } from './utils/azureUtilityManager';
|
||||
import { getTrustedCertificates } from './utils/getTrustedCertificates';
|
||||
import { Keytar } from './utils/keytar';
|
||||
import { wrapError } from './utils/wrapError';
|
||||
|
||||
export let dockerExplorerProvider: DockerExplorerProvider;
|
||||
|
||||
export type KeyInfo = { [keyName: string]: string };
|
||||
|
||||
export interface ComposeVersionKeys {
|
||||
All: KeyInfo;
|
||||
v1: KeyInfo;
|
||||
v2: KeyInfo;
|
||||
}
|
||||
|
||||
let client: LanguageClient;
|
||||
|
||||
const DOCUMENT_SELECTOR: DocumentSelector = [
|
||||
{ language: 'dockerfile', scheme: 'file' }
|
||||
];
|
||||
|
||||
function initializeExtensionVariables(ctx: vscode.ExtensionContext): void {
|
||||
if (!ext.ui) {
|
||||
// This allows for standard interactions with the end user (as opposed to test input)
|
||||
ext.ui = new AzureUserInput(ctx.globalState);
|
||||
}
|
||||
ext.context = ctx;
|
||||
ext.outputChannel = util.getOutputChannel();
|
||||
if (!ext.terminalProvider) {
|
||||
ext.terminalProvider = new DefaultTerminalProvider();
|
||||
}
|
||||
ext.reporter = createTelemetryReporter(ctx);
|
||||
if (!ext.keytar) {
|
||||
ext.keytar = Keytar.tryCreate();
|
||||
}
|
||||
|
||||
registerUIExtensionVariables(ext);
|
||||
}
|
||||
|
||||
export async function activateInternal(ctx: vscode.ExtensionContext, perfStats: { loadStartTime: number, loadEndTime: number | undefined }): Promise<void> {
|
||||
perfStats.loadEndTime = Date.now();
|
||||
|
||||
initializeExtensionVariables(ctx);
|
||||
await setRequestDefaults();
|
||||
await callWithTelemetryAndErrorHandling('docker.activate', async function (this: IActionContext): Promise<void> {
|
||||
this.properties.isActivationEvent = 'true';
|
||||
this.measurements.mainFileLoad = (perfStats.loadEndTime - perfStats.loadStartTime) / 1000;
|
||||
|
||||
ctx.subscriptions.push(
|
||||
vscode.languages.registerCompletionItemProvider(
|
||||
DOCUMENT_SELECTOR,
|
||||
new DockerfileCompletionItemProvider(),
|
||||
'.'
|
||||
)
|
||||
);
|
||||
|
||||
const YAML_MODE_ID: vscode.DocumentFilter = {
|
||||
language: 'yaml',
|
||||
scheme: 'file',
|
||||
pattern: COMPOSE_FILE_GLOB_PATTERN
|
||||
};
|
||||
let yamlHoverProvider = new DockerComposeHoverProvider(
|
||||
new DockerComposeParser(),
|
||||
composeVersionKeys.All
|
||||
);
|
||||
ctx.subscriptions.push(
|
||||
vscode.languages.registerHoverProvider(YAML_MODE_ID, yamlHoverProvider)
|
||||
);
|
||||
ctx.subscriptions.push(
|
||||
vscode.languages.registerCompletionItemProvider(
|
||||
YAML_MODE_ID,
|
||||
new DockerComposeCompletionItemProvider(),
|
||||
"."
|
||||
)
|
||||
);
|
||||
|
||||
ctx.subscriptions.push(
|
||||
vscode.workspace.registerTextDocumentContentProvider(
|
||||
DOCKER_INSPECT_SCHEME,
|
||||
new DockerInspectDocumentContentProvider()
|
||||
)
|
||||
);
|
||||
ctx.subscriptions.push(
|
||||
vscode.workspace.registerTextDocumentContentProvider(
|
||||
LogContentProvider.scheme,
|
||||
new LogContentProvider()
|
||||
)
|
||||
);
|
||||
ctx.subscriptions.push(
|
||||
vscode.workspace.registerTextDocumentContentProvider(
|
||||
TaskContentProvider.scheme,
|
||||
new TaskContentProvider()
|
||||
)
|
||||
);
|
||||
|
||||
registerDockerCommands();
|
||||
|
||||
ctx.subscriptions.push(
|
||||
vscode.debug.registerDebugConfigurationProvider(
|
||||
'docker',
|
||||
new DockerDebugConfigProvider()
|
||||
)
|
||||
);
|
||||
registerDebugConfigurationProvider(ctx);
|
||||
|
||||
await consolidateDefaultRegistrySettings();
|
||||
activateLanguageClient(ctx);
|
||||
|
||||
// Start loading the Azure account after we're completely done activating.
|
||||
setTimeout(
|
||||
// Do not wait
|
||||
// tslint:disable-next-line:promise-function-async
|
||||
() => AzureUtilityManager.getInstance().tryGetAzureAccount(),
|
||||
1);
|
||||
});
|
||||
}
|
||||
|
||||
async function setRequestDefaults(): Promise<void> {
|
||||
// Set up the user agent for all direct 'request' calls in the extension (as long as they use ext.request)
|
||||
// ... Trusted root certificate authorities
|
||||
let caList = await getTrustedCertificates();
|
||||
let defaultRequestOptions: CoreOptions = { agentOptions: { ca: caList } };
|
||||
// ... User agent
|
||||
addUserAgent(defaultRequestOptions);
|
||||
let requestWithDefaults = request.defaults(defaultRequestOptions);
|
||||
|
||||
// Wrap 'get' to provide better error message for self-signed certificates
|
||||
let originalGet = <(...args: unknown[]) => RequestPromise>requestWithDefaults.get;
|
||||
// tslint:disable-next-line:no-any
|
||||
async function wrappedGet(this: unknown, ...args: unknown[]): Promise<any> {
|
||||
try {
|
||||
// tslint:disable-next-line: no-unsafe-any
|
||||
return await originalGet.call(this, ...args);
|
||||
} catch (err) {
|
||||
let error = <{ cause?: { code?: string } }>err;
|
||||
|
||||
if (error && error.cause && error.cause.code === 'UNABLE_TO_VERIFY_LEAF_SIGNATURE') {
|
||||
err = wrapError(err, `There was a problem verifying a certificate. This could be caused by a self-signed or corporate certificate. You may need to set the 'docker.importCertificates' setting to true.`)
|
||||
}
|
||||
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
// tslint:disable-next-line:no-any
|
||||
requestWithDefaults.get = <any>wrappedGet;
|
||||
|
||||
ext.request = requestWithDefaults;
|
||||
}
|
||||
|
||||
async function createWebApp(context?: AzureImageTagNode | DockerHubImageTagNode): Promise<void> {
|
||||
assert(!!context, "Should not be available through command palette");
|
||||
|
||||
let azureAccount = await AzureUtilityManager.getInstance().requireAzureAccount();
|
||||
const azureAccountWrapper = new AzureAccountWrapper(ext.context, azureAccount);
|
||||
const wizard = new WebAppCreator(ext.outputChannel, azureAccountWrapper, context);
|
||||
const result = await wizard.run();
|
||||
if (result.status === 'Faulted') {
|
||||
throw result.error;
|
||||
} else if (result.status === 'Cancelled') {
|
||||
throw new UserCancelledError();
|
||||
}
|
||||
}
|
||||
|
||||
// Remove this when https://github.com/Microsoft/vscode-docker/issues/445 fixed
|
||||
function registerCommand(
|
||||
commandId: string,
|
||||
// tslint:disable-next-line: no-any
|
||||
callback: (this: IActionContext, ...args: any[]) => any
|
||||
): void {
|
||||
return uiRegisterCommand(
|
||||
commandId,
|
||||
// tslint:disable-next-line:no-function-expression no-any
|
||||
async function (this: IActionContext, ...args: any[]): Promise<any> {
|
||||
if (args.length) {
|
||||
let properties: {
|
||||
contextValue?: string;
|
||||
} & TelemetryProperties = this.properties;
|
||||
const contextArg = args[0];
|
||||
|
||||
if (contextArg instanceof NodeBase) {
|
||||
properties.contextValue = contextArg.contextValue;
|
||||
} else if (contextArg instanceof vscode.Uri) {
|
||||
properties.contextValue = "Uri";
|
||||
}
|
||||
}
|
||||
|
||||
return callback.call(this, ...args);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// tslint:disable-next-line:max-func-body-length
|
||||
function registerDockerCommands(): void {
|
||||
dockerExplorerProvider = new DockerExplorerProvider();
|
||||
vscode.window.registerTreeDataProvider(
|
||||
'dockerExplorer',
|
||||
dockerExplorerProvider
|
||||
);
|
||||
|
||||
registerCommand('vscode-docker.acr.createRegistry', createRegistry);
|
||||
registerCommand('vscode-docker.acr.deleteImage', deleteAzureImage);
|
||||
registerCommand('vscode-docker.acr.deleteRegistry', deleteAzureRegistry);
|
||||
registerCommand('vscode-docker.acr.deleteRepository', deleteRepository);
|
||||
registerCommand('vscode-docker.acr.pullImage', pullImageFromAzure);
|
||||
registerCommand('vscode-docker.acr.pullRepo', pullRepoFromAzure);
|
||||
registerCommand('vscode-docker.acr.quickBuild', async function (this: IActionContext, item: vscode.Uri | undefined): Promise<void> { await quickBuild(this, item); });
|
||||
registerCommand('vscode-docker.acr.runTask', runTask);
|
||||
registerCommand("vscode-docker.acr.runTaskFile", runTaskFile);
|
||||
registerCommand('vscode-docker.acr.showTask', showTaskProperties);
|
||||
registerCommand('vscode-docker.acr.untagImage', untagAzureImage);
|
||||
registerCommand('vscode-docker.acr.viewLogs', viewACRLogs);
|
||||
|
||||
registerCommand('vscode-docker.api.configure', async function (this: IActionContext, options: ConfigureApiOptions): Promise<void> { await configureApi(this, options); });
|
||||
registerCommand('vscode-docker.browseDockerHub', (context?: DockerHubImageTagNode | DockerHubRepositoryNode | DockerHubOrgNode) => { browseDockerHub(context); });
|
||||
registerCommand('vscode-docker.browseAzurePortal', (context?: AzureRegistryNode | AzureRepositoryNode | AzureImageTagNode) => { browseAzurePortal(context); });
|
||||
|
||||
registerCommand('vscode-docker.compose.down', composeDown);
|
||||
registerCommand('vscode-docker.compose.restart', composeRestart);
|
||||
registerCommand('vscode-docker.compose.up', composeUp);
|
||||
registerCommand('vscode-docker.configure', async function (this: IActionContext): Promise<void> { await configure(this, undefined); });
|
||||
registerCommand('vscode-docker.connectCustomRegistry', connectCustomRegistry);
|
||||
|
||||
registerCommand('vscode-docker.container.open-shell', async function (this: IActionContext, node: ContainerNode | RootNode | undefined): Promise<void> { await openShellContainer(this, node); });
|
||||
registerCommand('vscode-docker.container.remove', async function (this: IActionContext, node: ContainerNode | RootNode | undefined): Promise<void> { await removeContainer(this, node); });
|
||||
registerCommand('vscode-docker.container.restart', async function (this: IActionContext, node: ContainerNode | RootNode | undefined): Promise<void> { await restartContainer(this, node); });
|
||||
registerCommand('vscode-docker.container.show-logs', async function (this: IActionContext, node: ContainerNode | RootNode | undefined): Promise<void> { await showLogsContainer(this, node); });
|
||||
registerCommand('vscode-docker.container.start', async function (this: IActionContext, node: ImageNode | undefined): Promise<void> { await startContainer(this, node); });
|
||||
registerCommand('vscode-docker.container.start.azurecli', async function (this: IActionContext): Promise<void> { await startAzureCLI(this); });
|
||||
registerCommand('vscode-docker.container.start.interactive', async function (this: IActionContext, node: ImageNode | undefined): Promise<void> { await startContainerInteractive(this, node); });
|
||||
registerCommand('vscode-docker.container.stop', async function (this: IActionContext, node: ContainerNode | RootNode | undefined): Promise<void> { await stopContainer(this, node); });
|
||||
|
||||
registerCommand('vscode-docker.createWebApp', async (context?: AzureImageTagNode | DockerHubImageTagNode) => await createWebApp(context));
|
||||
registerCommand('vscode-docker.disconnectCustomRegistry', disconnectCustomRegistry);
|
||||
registerCommand('vscode-docker.dockerHubLogout', dockerHubLogout);
|
||||
registerCommand('vscode-docker.explorer.refresh', () => dockerExplorerProvider.refresh());
|
||||
|
||||
registerCommand('vscode-docker.image.build', async function (this: IActionContext, item: vscode.Uri | undefined): Promise<void> { await buildImage(this, item); });
|
||||
registerCommand('vscode-docker.image.inspect', async function (this: IActionContext, node: ImageNode | undefined): Promise<void> { await inspectImage(this, node); });
|
||||
registerCommand('vscode-docker.image.push', async function (this: IActionContext, node: ImageNode | undefined): Promise<void> { await pushImage(this, node); });
|
||||
registerCommand('vscode-docker.image.remove', async function (this: IActionContext, node: ImageNode | RootNode | undefined): Promise<void> { await removeImage(this, node); });
|
||||
registerCommand('vscode-docker.image.tag', async function (this: IActionContext, node: ImageNode | undefined): Promise<void> { await tagImage(this, node); });
|
||||
|
||||
registerCommand('vscode-docker.setRegistryAsDefault', setRegistryAsDefault);
|
||||
registerCommand('vscode-docker.system.prune', async function (this: IActionContext): Promise<void> { await systemPrune(this); });
|
||||
}
|
||||
|
||||
export async function deactivateInternal(): Promise<void> {
|
||||
if (!client) {
|
||||
return undefined;
|
||||
}
|
||||
// perform cleanup
|
||||
Configuration.dispose();
|
||||
return await client.stop();
|
||||
}
|
||||
|
||||
namespace Configuration {
|
||||
let configurationListener: vscode.Disposable;
|
||||
|
||||
export function computeConfiguration(params: ConfigurationParams): vscode.WorkspaceConfiguration[] {
|
||||
let result: vscode.WorkspaceConfiguration[] = [];
|
||||
for (let item of params.items) {
|
||||
let config: vscode.WorkspaceConfiguration;
|
||||
|
||||
if (item.scopeUri) {
|
||||
config = vscode.workspace.getConfiguration(
|
||||
item.section,
|
||||
client.protocol2CodeConverter.asUri(item.scopeUri)
|
||||
);
|
||||
} else {
|
||||
config = vscode.workspace.getConfiguration(item.section);
|
||||
}
|
||||
result.push(config);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export function initialize(): void {
|
||||
configurationListener = vscode.workspace.onDidChangeConfiguration(
|
||||
(e: vscode.ConfigurationChangeEvent) => {
|
||||
// notify the language server that settings have change
|
||||
client.sendNotification(DidChangeConfigurationNotification.type, {
|
||||
settings: null
|
||||
});
|
||||
|
||||
// Update endpoint and refresh explorer if needed
|
||||
if (e.affectsConfiguration('docker')) {
|
||||
docker.refreshEndpoint();
|
||||
// tslint:disable-next-line: no-floating-promises
|
||||
setRequestDefaults();
|
||||
vscode.commands.executeCommand('vscode-docker.explorer.refresh');
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
export function dispose(): void {
|
||||
if (configurationListener) {
|
||||
// remove this listener when disposed
|
||||
configurationListener.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function activateLanguageClient(ctx: vscode.ExtensionContext): void {
|
||||
// Don't wait
|
||||
callWithTelemetryAndErrorHandling('docker.languageclient.activate', async function (this: IActionContext): Promise<void> {
|
||||
this.properties.isActivationEvent = 'true';
|
||||
let serverModule = ctx.asAbsolutePath(
|
||||
path.join(
|
||||
"dist",
|
||||
"dockerfile-language-server-nodejs",
|
||||
"lib",
|
||||
"server.js"
|
||||
)
|
||||
);
|
||||
assert(true === await fse.pathExists(serverModule), "Could not find language client module");
|
||||
|
||||
let debugOptions = { execArgv: ["--nolazy", "--inspect=6009"] };
|
||||
|
||||
let serverOptions: ServerOptions = {
|
||||
run: {
|
||||
module: serverModule,
|
||||
transport: TransportKind.ipc,
|
||||
args: ["--node-ipc"]
|
||||
},
|
||||
debug: {
|
||||
module: serverModule,
|
||||
transport: TransportKind.ipc,
|
||||
options: debugOptions
|
||||
}
|
||||
};
|
||||
|
||||
let middleware: Middleware = {
|
||||
workspace: {
|
||||
configuration: Configuration.computeConfiguration
|
||||
}
|
||||
};
|
||||
|
||||
let clientOptions: LanguageClientOptions = {
|
||||
documentSelector: DOCUMENT_SELECTOR,
|
||||
synchronize: {
|
||||
fileEvents: vscode.workspace.createFileSystemWatcher("**/.clientrc")
|
||||
},
|
||||
middleware: middleware
|
||||
};
|
||||
|
||||
client = new LanguageClient(
|
||||
"dockerfile-langserver",
|
||||
"Dockerfile Language Server",
|
||||
serverOptions,
|
||||
clientOptions
|
||||
);
|
||||
// tslint:disable-next-line:no-floating-promises
|
||||
client.onReady().then(() => {
|
||||
// attach the VS Code settings listener
|
||||
Configuration.initialize();
|
||||
});
|
||||
client.start();
|
||||
});
|
||||
}
|
|
@ -4,10 +4,8 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
// tslint:disable-next-line:no-require-imports
|
||||
import * as opn from 'opn';
|
||||
import * as vscode from 'vscode';
|
||||
import { parseError } from 'vscode-azureextensionui';
|
||||
import { keytarConstants, PAGE_SIZE } from '../../constants';
|
||||
import { ext } from '../../extensionVariables';
|
||||
import { DockerHubImageTagNode, DockerHubOrgNode, DockerHubRepositoryNode } from '../models/dockerHubNodes';
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See LICENSE.md in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* This is the external face of extension.bundle.js, the main webpack bundle for the extension.
|
||||
* Anything needing to be exposed outside of the extension sources must be exported from here, because
|
||||
* everything else will be in private modules in extension.bundle.js.
|
||||
*/
|
||||
|
||||
// Export activate/deactivate for main.js
|
||||
export { activateInternal, deactivateInternal } from './extension';
|
||||
|
||||
// Exports for tests
|
||||
// The tests are not packaged with the webpack bundle and therefore only have access to code exported from this file.
|
||||
//
|
||||
// The tests should import '../extension.bundle.ts'. At design-time they live in tests/ and so will pick up this file (extension.bundle.ts).
|
||||
// At runtime the tests live in dist/tests and will therefore pick up the main webpack bundle at dist/extension.bundle.js.
|
||||
export { AsyncPool } from './utils/asyncpool';
|
||||
export { wrapError } from './utils/wrapError';
|
||||
export { ext } from './extensionVariables';
|
||||
export { nonNullProp } from './utils/nonNull';
|
||||
export { IKeytar } from './utils/keytar';
|
||||
export { throwDockerConnectionError, internal } from './explorer/utils/dockerConnectionError';
|
||||
export { getImageOrContainerDisplayName } from './explorer/models/getImageOrContainerDisplayName';
|
||||
export { trimWithElipsis } from './explorer/utils/utils';
|
||||
export { isWindows10RS3OrNewer, isWindows10RS4OrNewer } from "./helpers/osVersion";
|
||||
export { LineSplitter } from './debugging/coreclr/lineSplitter';
|
||||
export { CommandLineBuilder } from './debugging/coreclr/commandLineBuilder';
|
||||
export { DockerClient } from './debugging/coreclr/dockerClient';
|
||||
export { LaunchOptions } from './debugging/coreclr/dockerManager';
|
||||
export { DotNetClient } from './debugging/coreclr/dotNetClient';
|
||||
export { FileSystemProvider } from './debugging/coreclr/fsProvider';
|
||||
export { OSProvider } from './debugging/coreclr/osProvider';
|
||||
export { DockerDaemonIsLinuxPrerequisite, DockerfileExistsPrerequisite, DotNetSdkInstalledPrerequisite, LinuxUserInDockerGroupPrerequisite, MacNuGetFallbackFolderSharedPrerequisite } from './debugging/coreclr/prereqManager';
|
||||
export { ProcessProvider } from './debugging/coreclr/processProvider';
|
||||
export { PlatformOS, Platform } from './utils/platform';
|
||||
export { DockerBuildImageOptions } from "./debugging/coreclr/dockerClient";
|
||||
export { compareBuildImageOptions } from "./debugging/coreclr/dockerManager";
|
||||
export { configure, ConfigureApiOptions, ConfigureTelemetryProperties } from './configureWorkspace/configure';
|
||||
export { globAsync } from './helpers/async';
|
||||
export { httpsRequestBinary } from './utils/httpRequest';
|
||||
export { DefaultTerminalProvider } from './commands/utils/TerminalProvider';
|
||||
export { docker } from './commands/utils/docker-endpoint';
|
456
extension.ts
456
extension.ts
|
@ -3,41 +3,425 @@
|
|||
* Licensed under the MIT License. See LICENSE.md in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* This is the entrypoint for extension.js, the main webpack bundle for the extension.
|
||||
* Anything needing to be exposed outside of the extension sources must be exported from here, because
|
||||
* everything else will be in private modules in extension.js.
|
||||
*/
|
||||
import * as assert from 'assert';
|
||||
import * as fse from 'fs-extra';
|
||||
import * as path from 'path';
|
||||
import { CoreOptions } from 'request';
|
||||
import * as request from 'request-promise-native';
|
||||
import { RequestPromise } from 'request-promise-native';
|
||||
import * as vscode from 'vscode';
|
||||
import { AzureUserInput, callWithTelemetryAndErrorHandling, createTelemetryReporter, IActionContext, registerCommand as uiRegisterCommand, registerUIExtensionVariables, TelemetryProperties, UserCancelledError } from 'vscode-azureextensionui';
|
||||
import { ConfigurationParams, DidChangeConfigurationNotification, DocumentSelector, LanguageClient, LanguageClientOptions, Middleware, ServerOptions, TransportKind } from 'vscode-languageclient/lib/main';
|
||||
import { viewACRLogs } from "./commands/azureCommands/acr-logs";
|
||||
import { LogContentProvider } from "./commands/azureCommands/acr-logs-utils/logFileManager";
|
||||
import { createRegistry } from './commands/azureCommands/create-registry';
|
||||
import { deleteAzureImage, untagAzureImage } from './commands/azureCommands/delete-image';
|
||||
import { deleteAzureRegistry } from './commands/azureCommands/delete-registry';
|
||||
import { deleteRepository } from './commands/azureCommands/delete-repository';
|
||||
import { pullImageFromAzure, pullRepoFromAzure } from './commands/azureCommands/pull-from-azure';
|
||||
import { quickBuild } from "./commands/azureCommands/quick-build";
|
||||
import { runTask, runTaskFile } from "./commands/azureCommands/run-task";
|
||||
import { showTaskProperties } from "./commands/azureCommands/show-task";
|
||||
import { TaskContentProvider } from "./commands/azureCommands/task-utils/showTaskManager";
|
||||
import { buildImage } from './commands/build-image';
|
||||
import { composeDown, composeRestart, composeUp } from './commands/docker-compose';
|
||||
import inspectImage from './commands/inspect-image';
|
||||
import { openShellContainer } from './commands/open-shell-container';
|
||||
import { pushImage } from './commands/push-image';
|
||||
import { consolidateDefaultRegistrySettings, setRegistryAsDefault } from './commands/registrySettings';
|
||||
import { removeContainer } from './commands/remove-container';
|
||||
import { removeImage } from './commands/remove-image';
|
||||
import { restartContainer } from './commands/restart-container';
|
||||
import { showLogsContainer } from './commands/showlogs-container';
|
||||
import { startAzureCLI, startContainer, startContainerInteractive } from './commands/start-container';
|
||||
import { stopContainer } from './commands/stop-container';
|
||||
import { systemPrune } from './commands/system-prune';
|
||||
import { tagImage } from './commands/tag-image';
|
||||
import { docker } from './commands/utils/docker-endpoint';
|
||||
import { DefaultTerminalProvider } from './commands/utils/TerminalProvider';
|
||||
import { DockerDebugConfigProvider } from './configureWorkspace/configDebugProvider';
|
||||
import { configure, configureApi, ConfigureApiOptions } from './configureWorkspace/configure';
|
||||
import { COMPOSE_FILE_GLOB_PATTERN } from './constants';
|
||||
import { registerDebugConfigurationProvider } from './debugging/coreclr/registerDebugger';
|
||||
import { DockerComposeCompletionItemProvider } from './dockerCompose/dockerComposeCompletionItemProvider';
|
||||
import { DockerComposeHoverProvider } from './dockerCompose/dockerComposeHoverProvider';
|
||||
import composeVersionKeys from './dockerCompose/dockerComposeKeyInfo';
|
||||
import { DockerComposeParser } from './dockerCompose/dockerComposeParser';
|
||||
import { DockerfileCompletionItemProvider } from './dockerfile/dockerfileCompletionItemProvider';
|
||||
import DockerInspectDocumentContentProvider, { SCHEME as DOCKER_INSPECT_SCHEME } from './documentContentProviders/dockerInspect';
|
||||
import { AzureAccountWrapper } from './explorer/deploy/azureAccountWrapper';
|
||||
import * as util from './explorer/deploy/util';
|
||||
import { WebAppCreator } from './explorer/deploy/webAppCreator';
|
||||
import { DockerExplorerProvider } from './explorer/dockerExplorer';
|
||||
import { AzureImageTagNode, AzureRegistryNode, AzureRepositoryNode } from './explorer/models/azureRegistryNodes';
|
||||
import { ContainerNode } from './explorer/models/containerNode';
|
||||
import { connectCustomRegistry, disconnectCustomRegistry } from './explorer/models/customRegistries';
|
||||
import { DockerHubImageTagNode, DockerHubOrgNode, DockerHubRepositoryNode } from './explorer/models/dockerHubNodes';
|
||||
import { ImageNode } from './explorer/models/imageNode';
|
||||
import { NodeBase } from './explorer/models/nodeBase';
|
||||
import { RootNode } from './explorer/models/rootNode';
|
||||
import { browseAzurePortal } from './explorer/utils/browseAzurePortal';
|
||||
import { browseDockerHub, dockerHubLogout } from './explorer/utils/dockerHubUtils';
|
||||
import { ext } from './extensionVariables';
|
||||
import { addUserAgent } from './utils/addUserAgent';
|
||||
import { AzureUtilityManager } from './utils/azureUtilityManager';
|
||||
import { getTrustedCertificates } from './utils/getTrustedCertificates';
|
||||
import { Keytar } from './utils/keytar';
|
||||
import { wrapError } from './utils/wrapError';
|
||||
|
||||
// Export activate for vscode to call (via entrypoint.js)
|
||||
export { activateInternal, deactivateInternal } from './dockerExtension';
|
||||
export let dockerExplorerProvider: DockerExplorerProvider;
|
||||
|
||||
// Exports for use by the tests, which are not packaged with the webpack bundle and therefore
|
||||
// only have access to code exported from this file. The tests should import '../extension.ts' (this file),
|
||||
// to access these exports, and at runtime they will pick up dist/extension.js.
|
||||
export { AsyncPool } from './utils/asyncpool';
|
||||
export { wrapError } from './utils/wrapError';
|
||||
export { ext } from './extensionVariables';
|
||||
export { nonNullProp } from './utils/nonNull';
|
||||
export { IKeytar } from './utils/keytar';
|
||||
export { throwDockerConnectionError, internal } from './explorer/utils/dockerConnectionError';
|
||||
export { getImageOrContainerDisplayName } from './explorer/models/getImageOrContainerDisplayName';
|
||||
export { trimWithElipsis } from './explorer/utils/utils';
|
||||
export { isWindows10RS3OrNewer, isWindows10RS4OrNewer } from "./helpers/osVersion";
|
||||
export { LineSplitter } from './debugging/coreclr/lineSplitter';
|
||||
export { CommandLineBuilder } from './debugging/coreclr/commandLineBuilder';
|
||||
export { DockerClient } from './debugging/coreclr/dockerClient';
|
||||
export { LaunchOptions } from './debugging/coreclr/dockerManager';
|
||||
export { DotNetClient } from './debugging/coreclr/dotNetClient';
|
||||
export { FileSystemProvider } from './debugging/coreclr/fsProvider';
|
||||
export { OSProvider } from './debugging/coreclr/osProvider';
|
||||
export { DockerDaemonIsLinuxPrerequisite, DockerfileExistsPrerequisite, DotNetSdkInstalledPrerequisite, LinuxUserInDockerGroupPrerequisite, MacNuGetFallbackFolderSharedPrerequisite } from './debugging/coreclr/prereqManager';
|
||||
export { ProcessProvider } from './debugging/coreclr/processProvider';
|
||||
export { PlatformOS, Platform } from './utils/platform';
|
||||
export { DockerBuildImageOptions } from "./debugging/coreclr/dockerClient";
|
||||
export { compareBuildImageOptions } from "./debugging/coreclr/dockerManager";
|
||||
export { configure, ConfigureApiOptions, ConfigureTelemetryProperties } from './configureWorkspace/configure';
|
||||
export { globAsync } from './helpers/async';
|
||||
export { httpsRequestBinary } from './utils/httpRequest';
|
||||
export { DefaultTerminalProvider } from './commands/utils/TerminalProvider';
|
||||
export { docker } from './commands/utils/docker-endpoint';
|
||||
export type KeyInfo = { [keyName: string]: string };
|
||||
|
||||
export interface ComposeVersionKeys {
|
||||
All: KeyInfo;
|
||||
v1: KeyInfo;
|
||||
v2: KeyInfo;
|
||||
}
|
||||
|
||||
let client: LanguageClient;
|
||||
|
||||
const DOCUMENT_SELECTOR: DocumentSelector = [
|
||||
{ language: 'dockerfile', scheme: 'file' }
|
||||
];
|
||||
|
||||
function initializeExtensionVariables(ctx: vscode.ExtensionContext): void {
|
||||
if (!ext.ui) {
|
||||
// This allows for standard interactions with the end user (as opposed to test input)
|
||||
ext.ui = new AzureUserInput(ctx.globalState);
|
||||
}
|
||||
ext.context = ctx;
|
||||
ext.outputChannel = util.getOutputChannel();
|
||||
if (!ext.terminalProvider) {
|
||||
ext.terminalProvider = new DefaultTerminalProvider();
|
||||
}
|
||||
ext.reporter = createTelemetryReporter(ctx);
|
||||
if (!ext.keytar) {
|
||||
ext.keytar = Keytar.tryCreate();
|
||||
}
|
||||
|
||||
registerUIExtensionVariables(ext);
|
||||
}
|
||||
|
||||
export async function activateInternal(ctx: vscode.ExtensionContext, perfStats: { loadStartTime: number, loadEndTime: number | undefined }): Promise<void> {
|
||||
perfStats.loadEndTime = Date.now();
|
||||
|
||||
initializeExtensionVariables(ctx);
|
||||
await setRequestDefaults();
|
||||
await callWithTelemetryAndErrorHandling('docker.activate', async function (this: IActionContext): Promise<void> {
|
||||
this.properties.isActivationEvent = 'true';
|
||||
this.measurements.mainFileLoad = (perfStats.loadEndTime - perfStats.loadStartTime) / 1000;
|
||||
|
||||
ctx.subscriptions.push(
|
||||
vscode.languages.registerCompletionItemProvider(
|
||||
DOCUMENT_SELECTOR,
|
||||
new DockerfileCompletionItemProvider(),
|
||||
'.'
|
||||
)
|
||||
);
|
||||
|
||||
const YAML_MODE_ID: vscode.DocumentFilter = {
|
||||
language: 'yaml',
|
||||
scheme: 'file',
|
||||
pattern: COMPOSE_FILE_GLOB_PATTERN
|
||||
};
|
||||
let yamlHoverProvider = new DockerComposeHoverProvider(
|
||||
new DockerComposeParser(),
|
||||
composeVersionKeys.All
|
||||
);
|
||||
ctx.subscriptions.push(
|
||||
vscode.languages.registerHoverProvider(YAML_MODE_ID, yamlHoverProvider)
|
||||
);
|
||||
ctx.subscriptions.push(
|
||||
vscode.languages.registerCompletionItemProvider(
|
||||
YAML_MODE_ID,
|
||||
new DockerComposeCompletionItemProvider(),
|
||||
"."
|
||||
)
|
||||
);
|
||||
|
||||
ctx.subscriptions.push(
|
||||
vscode.workspace.registerTextDocumentContentProvider(
|
||||
DOCKER_INSPECT_SCHEME,
|
||||
new DockerInspectDocumentContentProvider()
|
||||
)
|
||||
);
|
||||
ctx.subscriptions.push(
|
||||
vscode.workspace.registerTextDocumentContentProvider(
|
||||
LogContentProvider.scheme,
|
||||
new LogContentProvider()
|
||||
)
|
||||
);
|
||||
ctx.subscriptions.push(
|
||||
vscode.workspace.registerTextDocumentContentProvider(
|
||||
TaskContentProvider.scheme,
|
||||
new TaskContentProvider()
|
||||
)
|
||||
);
|
||||
|
||||
registerDockerCommands();
|
||||
|
||||
ctx.subscriptions.push(
|
||||
vscode.debug.registerDebugConfigurationProvider(
|
||||
'docker',
|
||||
new DockerDebugConfigProvider()
|
||||
)
|
||||
);
|
||||
registerDebugConfigurationProvider(ctx);
|
||||
|
||||
await consolidateDefaultRegistrySettings();
|
||||
activateLanguageClient(ctx);
|
||||
|
||||
// Start loading the Azure account after we're completely done activating.
|
||||
setTimeout(
|
||||
// Do not wait
|
||||
// tslint:disable-next-line:promise-function-async
|
||||
() => AzureUtilityManager.getInstance().tryGetAzureAccount(),
|
||||
1);
|
||||
});
|
||||
}
|
||||
|
||||
async function setRequestDefaults(): Promise<void> {
|
||||
// Set up the user agent for all direct 'request' calls in the extension (as long as they use ext.request)
|
||||
// ... Trusted root certificate authorities
|
||||
let caList = await getTrustedCertificates();
|
||||
let defaultRequestOptions: CoreOptions = { agentOptions: { ca: caList } };
|
||||
// ... User agent
|
||||
addUserAgent(defaultRequestOptions);
|
||||
let requestWithDefaults = request.defaults(defaultRequestOptions);
|
||||
|
||||
// Wrap 'get' to provide better error message for self-signed certificates
|
||||
let originalGet = <(...args: unknown[]) => RequestPromise>requestWithDefaults.get;
|
||||
// tslint:disable-next-line:no-any
|
||||
async function wrappedGet(this: unknown, ...args: unknown[]): Promise<any> {
|
||||
try {
|
||||
// tslint:disable-next-line: no-unsafe-any
|
||||
return await originalGet.call(this, ...args);
|
||||
} catch (err) {
|
||||
let error = <{ cause?: { code?: string } }>err;
|
||||
|
||||
if (error && error.cause && error.cause.code === 'UNABLE_TO_VERIFY_LEAF_SIGNATURE') {
|
||||
err = wrapError(err, `There was a problem verifying a certificate. This could be caused by a self-signed or corporate certificate. You may need to set the 'docker.importCertificates' setting to true.`)
|
||||
}
|
||||
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
// tslint:disable-next-line:no-any
|
||||
requestWithDefaults.get = <any>wrappedGet;
|
||||
|
||||
ext.request = requestWithDefaults;
|
||||
}
|
||||
|
||||
async function createWebApp(context?: AzureImageTagNode | DockerHubImageTagNode): Promise<void> {
|
||||
assert(!!context, "Should not be available through command palette");
|
||||
|
||||
let azureAccount = await AzureUtilityManager.getInstance().requireAzureAccount();
|
||||
const azureAccountWrapper = new AzureAccountWrapper(ext.context, azureAccount);
|
||||
const wizard = new WebAppCreator(ext.outputChannel, azureAccountWrapper, context);
|
||||
const result = await wizard.run();
|
||||
if (result.status === 'Faulted') {
|
||||
throw result.error;
|
||||
} else if (result.status === 'Cancelled') {
|
||||
throw new UserCancelledError();
|
||||
}
|
||||
}
|
||||
|
||||
// Remove this when https://github.com/Microsoft/vscode-docker/issues/445 fixed
|
||||
function registerCommand(
|
||||
commandId: string,
|
||||
// tslint:disable-next-line: no-any
|
||||
callback: (this: IActionContext, ...args: any[]) => any
|
||||
): void {
|
||||
return uiRegisterCommand(
|
||||
commandId,
|
||||
// tslint:disable-next-line:no-function-expression no-any
|
||||
async function (this: IActionContext, ...args: any[]): Promise<any> {
|
||||
if (args.length) {
|
||||
let properties: {
|
||||
contextValue?: string;
|
||||
} & TelemetryProperties = this.properties;
|
||||
const contextArg = args[0];
|
||||
|
||||
if (contextArg instanceof NodeBase) {
|
||||
properties.contextValue = contextArg.contextValue;
|
||||
} else if (contextArg instanceof vscode.Uri) {
|
||||
properties.contextValue = "Uri";
|
||||
}
|
||||
}
|
||||
|
||||
return callback.call(this, ...args);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// tslint:disable-next-line:max-func-body-length
|
||||
function registerDockerCommands(): void {
|
||||
dockerExplorerProvider = new DockerExplorerProvider();
|
||||
vscode.window.registerTreeDataProvider(
|
||||
'dockerExplorer',
|
||||
dockerExplorerProvider
|
||||
);
|
||||
|
||||
registerCommand('vscode-docker.acr.createRegistry', createRegistry);
|
||||
registerCommand('vscode-docker.acr.deleteImage', deleteAzureImage);
|
||||
registerCommand('vscode-docker.acr.deleteRegistry', deleteAzureRegistry);
|
||||
registerCommand('vscode-docker.acr.deleteRepository', deleteRepository);
|
||||
registerCommand('vscode-docker.acr.pullImage', pullImageFromAzure);
|
||||
registerCommand('vscode-docker.acr.pullRepo', pullRepoFromAzure);
|
||||
registerCommand('vscode-docker.acr.quickBuild', async function (this: IActionContext, item: vscode.Uri | undefined): Promise<void> { await quickBuild(this, item); });
|
||||
registerCommand('vscode-docker.acr.runTask', runTask);
|
||||
registerCommand("vscode-docker.acr.runTaskFile", runTaskFile);
|
||||
registerCommand('vscode-docker.acr.showTask', showTaskProperties);
|
||||
registerCommand('vscode-docker.acr.untagImage', untagAzureImage);
|
||||
registerCommand('vscode-docker.acr.viewLogs', viewACRLogs);
|
||||
|
||||
registerCommand('vscode-docker.api.configure', async function (this: IActionContext, options: ConfigureApiOptions): Promise<void> { await configureApi(this, options); });
|
||||
registerCommand('vscode-docker.browseDockerHub', (context?: DockerHubImageTagNode | DockerHubRepositoryNode | DockerHubOrgNode) => { browseDockerHub(context); });
|
||||
registerCommand('vscode-docker.browseAzurePortal', (context?: AzureRegistryNode | AzureRepositoryNode | AzureImageTagNode) => { browseAzurePortal(context); });
|
||||
|
||||
registerCommand('vscode-docker.compose.down', composeDown);
|
||||
registerCommand('vscode-docker.compose.restart', composeRestart);
|
||||
registerCommand('vscode-docker.compose.up', composeUp);
|
||||
registerCommand('vscode-docker.configure', async function (this: IActionContext): Promise<void> { await configure(this, undefined); });
|
||||
registerCommand('vscode-docker.connectCustomRegistry', connectCustomRegistry);
|
||||
|
||||
registerCommand('vscode-docker.container.open-shell', async function (this: IActionContext, node: ContainerNode | RootNode | undefined): Promise<void> { await openShellContainer(this, node); });
|
||||
registerCommand('vscode-docker.container.remove', async function (this: IActionContext, node: ContainerNode | RootNode | undefined): Promise<void> { await removeContainer(this, node); });
|
||||
registerCommand('vscode-docker.container.restart', async function (this: IActionContext, node: ContainerNode | RootNode | undefined): Promise<void> { await restartContainer(this, node); });
|
||||
registerCommand('vscode-docker.container.show-logs', async function (this: IActionContext, node: ContainerNode | RootNode | undefined): Promise<void> { await showLogsContainer(this, node); });
|
||||
registerCommand('vscode-docker.container.start', async function (this: IActionContext, node: ImageNode | undefined): Promise<void> { await startContainer(this, node); });
|
||||
registerCommand('vscode-docker.container.start.azurecli', async function (this: IActionContext): Promise<void> { await startAzureCLI(this); });
|
||||
registerCommand('vscode-docker.container.start.interactive', async function (this: IActionContext, node: ImageNode | undefined): Promise<void> { await startContainerInteractive(this, node); });
|
||||
registerCommand('vscode-docker.container.stop', async function (this: IActionContext, node: ContainerNode | RootNode | undefined): Promise<void> { await stopContainer(this, node); });
|
||||
|
||||
registerCommand('vscode-docker.createWebApp', async (context?: AzureImageTagNode | DockerHubImageTagNode) => await createWebApp(context));
|
||||
registerCommand('vscode-docker.disconnectCustomRegistry', disconnectCustomRegistry);
|
||||
registerCommand('vscode-docker.dockerHubLogout', dockerHubLogout);
|
||||
registerCommand('vscode-docker.explorer.refresh', () => dockerExplorerProvider.refresh());
|
||||
|
||||
registerCommand('vscode-docker.image.build', async function (this: IActionContext, item: vscode.Uri | undefined): Promise<void> { await buildImage(this, item); });
|
||||
registerCommand('vscode-docker.image.inspect', async function (this: IActionContext, node: ImageNode | undefined): Promise<void> { await inspectImage(this, node); });
|
||||
registerCommand('vscode-docker.image.push', async function (this: IActionContext, node: ImageNode | undefined): Promise<void> { await pushImage(this, node); });
|
||||
registerCommand('vscode-docker.image.remove', async function (this: IActionContext, node: ImageNode | RootNode | undefined): Promise<void> { await removeImage(this, node); });
|
||||
registerCommand('vscode-docker.image.tag', async function (this: IActionContext, node: ImageNode | undefined): Promise<void> { await tagImage(this, node); });
|
||||
|
||||
registerCommand('vscode-docker.setRegistryAsDefault', setRegistryAsDefault);
|
||||
registerCommand('vscode-docker.system.prune', async function (this: IActionContext): Promise<void> { await systemPrune(this); });
|
||||
}
|
||||
|
||||
export async function deactivateInternal(): Promise<void> {
|
||||
if (!client) {
|
||||
return undefined;
|
||||
}
|
||||
// perform cleanup
|
||||
Configuration.dispose();
|
||||
return await client.stop();
|
||||
}
|
||||
|
||||
namespace Configuration {
|
||||
let configurationListener: vscode.Disposable;
|
||||
|
||||
export function computeConfiguration(params: ConfigurationParams): vscode.WorkspaceConfiguration[] {
|
||||
let result: vscode.WorkspaceConfiguration[] = [];
|
||||
for (let item of params.items) {
|
||||
let config: vscode.WorkspaceConfiguration;
|
||||
|
||||
if (item.scopeUri) {
|
||||
config = vscode.workspace.getConfiguration(
|
||||
item.section,
|
||||
client.protocol2CodeConverter.asUri(item.scopeUri)
|
||||
);
|
||||
} else {
|
||||
config = vscode.workspace.getConfiguration(item.section);
|
||||
}
|
||||
result.push(config);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export function initialize(): void {
|
||||
configurationListener = vscode.workspace.onDidChangeConfiguration(
|
||||
(e: vscode.ConfigurationChangeEvent) => {
|
||||
// notify the language server that settings have change
|
||||
client.sendNotification(DidChangeConfigurationNotification.type, {
|
||||
settings: null
|
||||
});
|
||||
|
||||
// Update endpoint and refresh explorer if needed
|
||||
if (e.affectsConfiguration('docker')) {
|
||||
docker.refreshEndpoint();
|
||||
// tslint:disable-next-line: no-floating-promises
|
||||
setRequestDefaults();
|
||||
vscode.commands.executeCommand('vscode-docker.explorer.refresh');
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
export function dispose(): void {
|
||||
if (configurationListener) {
|
||||
// remove this listener when disposed
|
||||
configurationListener.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function activateLanguageClient(ctx: vscode.ExtensionContext): void {
|
||||
// Don't wait
|
||||
callWithTelemetryAndErrorHandling('docker.languageclient.activate', async function (this: IActionContext): Promise<void> {
|
||||
this.properties.isActivationEvent = 'true';
|
||||
let serverModule = ctx.asAbsolutePath(
|
||||
path.join(
|
||||
"dist",
|
||||
"dockerfile-language-server-nodejs",
|
||||
"lib",
|
||||
"server.js"
|
||||
)
|
||||
);
|
||||
assert(true === await fse.pathExists(serverModule), "Could not find language client module");
|
||||
|
||||
let debugOptions = { execArgv: ["--nolazy", "--inspect=6009"] };
|
||||
|
||||
let serverOptions: ServerOptions = {
|
||||
run: {
|
||||
module: serverModule,
|
||||
transport: TransportKind.ipc,
|
||||
args: ["--node-ipc"]
|
||||
},
|
||||
debug: {
|
||||
module: serverModule,
|
||||
transport: TransportKind.ipc,
|
||||
options: debugOptions
|
||||
}
|
||||
};
|
||||
|
||||
let middleware: Middleware = {
|
||||
workspace: {
|
||||
configuration: Configuration.computeConfiguration
|
||||
}
|
||||
};
|
||||
|
||||
let clientOptions: LanguageClientOptions = {
|
||||
documentSelector: DOCUMENT_SELECTOR,
|
||||
synchronize: {
|
||||
fileEvents: vscode.workspace.createFileSystemWatcher("**/.clientrc")
|
||||
},
|
||||
middleware: middleware
|
||||
};
|
||||
|
||||
client = new LanguageClient(
|
||||
"dockerfile-langserver",
|
||||
"Dockerfile Language Server",
|
||||
serverOptions,
|
||||
clientOptions
|
||||
);
|
||||
// tslint:disable-next-line:no-floating-promises
|
||||
client.onReady().then(() => {
|
||||
// attach the VS Code settings listener
|
||||
Configuration.initialize();
|
||||
});
|
||||
client.start();
|
||||
});
|
||||
}
|
||||
|
|
42
gulpfile.ts
42
gulpfile.ts
|
@ -6,46 +6,12 @@
|
|||
// tslint:disable:no-implicit-dependencies
|
||||
import * as cp from 'child_process';
|
||||
import * as fse from 'fs-extra';
|
||||
import * as glob from 'glob';
|
||||
import * as gulp from 'gulp';
|
||||
import * as decompress from 'gulp-decompress';
|
||||
import * as download from 'gulp-download';
|
||||
import * as os from 'os';
|
||||
import * as path from 'path';
|
||||
import { gulp_installAzureAccount, gulp_webpack } from 'vscode-azureextensiondev';
|
||||
|
||||
const env = process.env;
|
||||
|
||||
function webpack(mode: string): cp.ChildProcess {
|
||||
// without this, webpack can run out of memory in some environments
|
||||
env.NODE_OPTIONS = '--max-old-space-size=8192';
|
||||
return spawn(path.join(__dirname, './node_modules/.bin/webpack'), ['--mode', mode], { stdio: 'inherit', env });
|
||||
}
|
||||
|
||||
/**
|
||||
* Installs the azure account extension before running tests (otherwise our extension would fail to activate)
|
||||
* NOTE: The version isn't super important since we don't actually use the account extension in tests
|
||||
*/
|
||||
function installAzureAccount(): Promise<void> {
|
||||
const version = '0.4.3';
|
||||
const extensionPath = path.join(os.homedir(), `.vscode/extensions/ms-vscode.azure-account-${version}`);
|
||||
const existingExtensions = glob.sync(extensionPath.replace(version, '*'));
|
||||
if (existingExtensions.length === 0) {
|
||||
// tslint:disable-next-line:no-http-string
|
||||
return download(`http://ms-vscode.gallery.vsassets.io/_apis/public/gallery/publisher/ms-vscode/extension/azure-account/${version}/assetbyname/Microsoft.VisualStudio.Services.VSIXPackage`)
|
||||
.pipe(decompress({
|
||||
filter: file => file.path.startsWith('extension/'),
|
||||
map: file => {
|
||||
file.path = file.path.slice(10);
|
||||
return file;
|
||||
}
|
||||
}))
|
||||
.pipe(gulp.dest(extensionPath));
|
||||
} else {
|
||||
console.log('Azure Account extension already installed.');
|
||||
return Promise.resolve();
|
||||
}
|
||||
}
|
||||
|
||||
function test(): cp.ChildProcess {
|
||||
env.DEBUGTELEMETRY = '1';
|
||||
env.CODE_TESTS_WORKSPACE = path.join(__dirname, 'test/test.code-workspace');
|
||||
|
@ -65,6 +31,6 @@ function spawn(command: string, args: string[], options: {}): cp.ChildProcess {
|
|||
return cp.spawn(command, args, options);
|
||||
}
|
||||
|
||||
exports['webpack-dev'] = () => webpack('development');
|
||||
exports['webpack-prod'] = () => webpack('production');
|
||||
exports.test = gulp.series(installAzureAccount, test);
|
||||
exports['webpack-dev'] = () => gulp_webpack('development');
|
||||
exports['webpack-prod'] = () => gulp_webpack('production');
|
||||
exports.test = gulp.series(gulp_installAzureAccount, test);
|
||||
|
|
|
@ -16,7 +16,7 @@ let perfStats = {
|
|||
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
|
||||
const extension = require("./dist/extension");
|
||||
const extension = require("./dist/extension.bundle");
|
||||
|
||||
async function activate(ctx) {
|
||||
return await extension.activateInternal(ctx, perfStats);
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
11
package.json
11
package.json
|
@ -73,7 +73,7 @@
|
|||
"onLanguage:yaml",
|
||||
"onView:dockerExplorer"
|
||||
],
|
||||
"main": "entrypoint",
|
||||
"main": "main",
|
||||
"contributes": {
|
||||
"menus": {
|
||||
"commandPalette": [
|
||||
|
@ -992,19 +992,15 @@
|
|||
"@types/node": "^8.10.34",
|
||||
"@types/request-promise-native": "^1.0.15",
|
||||
"@types/semver": "^5.5.0",
|
||||
"@types/string-replace-webpack-plugin": "^0.1.0",
|
||||
"@types/xml2js": "^0.4.3",
|
||||
"adm-zip": "^0.4.11",
|
||||
"clean-webpack-plugin": "^0.1.19",
|
||||
"copy-webpack-plugin": "^4.5.4",
|
||||
"gulp": "^4.0.0",
|
||||
"gulp-decompress": "^2.0.2",
|
||||
"gulp-download": "^0.0.1",
|
||||
"mocha": "^5.2.0",
|
||||
"mocha-junit-reporter": "^1.18.0",
|
||||
"mocha-multi-reporters": "^1.1.7",
|
||||
"string-replace-webpack-plugin": "^0.1.3",
|
||||
"terser-webpack-plugin": "^1.2.1",
|
||||
"ts-loader": "^5.3.0",
|
||||
"ts-node": "^7.0.1",
|
||||
"tslint": "^5.11.0",
|
||||
"tslint-microsoft-contrib": "^6.0.0",
|
||||
|
@ -1012,7 +1008,8 @@
|
|||
"umd-compat-loader": "^2.1.1",
|
||||
"vsce": "^1.51.1",
|
||||
"vscode": "^1.1.18",
|
||||
"webpack": "^4.25.1",
|
||||
"vscode-azureextensiondev": "0.1.8",
|
||||
"webpack": "^4.29.0",
|
||||
"webpack-cli": "^3.1.2"
|
||||
},
|
||||
"dependencies": {
|
||||
|
|
|
@ -9,7 +9,7 @@ import * as os from 'os';
|
|||
import * as path from 'path';
|
||||
import * as vscode from 'vscode';
|
||||
import { Terminal } from 'vscode';
|
||||
import { DefaultTerminalProvider } from '../extension';
|
||||
import { DefaultTerminalProvider } from '../extension.bundle';
|
||||
|
||||
export interface ITerminalProvider {
|
||||
createTerminal(name: string): Terminal;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
import * as assert from 'assert';
|
||||
|
||||
import { AsyncPool } from '../extension';
|
||||
import { AsyncPool } from '../extension.bundle';
|
||||
|
||||
suite("AsyncPool Tests", () => {
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ import { Uri } from 'vscode';
|
|||
import * as fse from 'fs-extra';
|
||||
import * as AdmZip from 'adm-zip';
|
||||
import * as path from 'path';
|
||||
import { Platform, configure, httpsRequestBinary, ext } from '../extension';
|
||||
import { Platform, configure, httpsRequestBinary, ext } from '../extension.bundle';
|
||||
import { Suite, Context } from 'mocha';
|
||||
import { TestUserInput, IActionContext } from 'vscode-azureextensionui';
|
||||
import { getTestRootFolder, testInEmptyFolder } from './global.test';
|
||||
|
|
|
@ -9,7 +9,7 @@ import * as vscode from 'vscode';
|
|||
import * as fse from 'fs-extra';
|
||||
import * as path from 'path';
|
||||
import { Suite } from 'mocha';
|
||||
import { PlatformOS, Platform, ext, configure, ConfigureTelemetryProperties, ConfigureApiOptions, globAsync } from '../extension';
|
||||
import { PlatformOS, Platform, ext, configure, ConfigureTelemetryProperties, ConfigureApiOptions, globAsync } from '../extension.bundle';
|
||||
import { TestUserInput, IActionContext, TelemetryProperties } from 'vscode-azureextensionui';
|
||||
import { getTestRootFolder, testInEmptyFolder } from './global.test';
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
import * as assertEx from './assertEx';
|
||||
import { commands, OutputChannel, window } from 'vscode';
|
||||
import { ext } from '../extension';
|
||||
import { ext } from '../extension.bundle';
|
||||
import { Suite, Test, Context } from 'mocha';
|
||||
import { TestTerminalProvider } from './TestTerminalProvider';
|
||||
import { TestUserInput } from 'vscode-azureextensionui';
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*--------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { CommandLineBuilder } from '../../../extension';
|
||||
import { CommandLineBuilder } from '../../../extension.bundle';
|
||||
|
||||
suite('debugging/coreclr/CommandLineBuilder', () => {
|
||||
function testBuilder(name: string, builderInitializer: (CommandLineBuilder) => CommandLineBuilder, expected: string, message: string) {
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
*--------------------------------------------------------*/
|
||||
|
||||
import assert = require("assert");
|
||||
import { DockerBuildImageOptions } from "../../../extension";
|
||||
import { compareBuildImageOptions } from "../../../extension";
|
||||
import { DockerBuildImageOptions } from "../../../extension.bundle";
|
||||
import { compareBuildImageOptions } from "../../../extension.bundle";
|
||||
|
||||
suite('debugging/coreclr/dockerManager', () => {
|
||||
suite('compareBuildImageOptions', () => {
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*--------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { LineSplitter } from '../../../extension';
|
||||
import { LineSplitter } from '../../../extension.bundle';
|
||||
|
||||
suite('debugging/coreclr/LineSplitter', () => {
|
||||
const testCase = (name: string, input: string | string[], output: string[]) => {
|
||||
|
|
|
@ -4,14 +4,14 @@
|
|||
|
||||
import * as assert from 'assert';
|
||||
import * as vscode from 'vscode';
|
||||
import { FileSystemProvider } from '../../../extension';
|
||||
import { OSProvider } from '../../../extension';
|
||||
import { ProcessProvider } from '../../../extension';
|
||||
import { MacNuGetFallbackFolderSharedPrerequisite, LinuxUserInDockerGroupPrerequisite, DockerDaemonIsLinuxPrerequisite, DockerfileExistsPrerequisite, DotNetSdkInstalledPrerequisite } from '../../../extension';
|
||||
import { PlatformOS } from '../../../extension';
|
||||
import { DockerClient } from '../../../extension';
|
||||
import { DotNetClient } from '../../../extension';
|
||||
import { LaunchOptions } from '../../../extension';
|
||||
import { FileSystemProvider } from '../../../extension.bundle';
|
||||
import { OSProvider } from '../../../extension.bundle';
|
||||
import { ProcessProvider } from '../../../extension.bundle';
|
||||
import { MacNuGetFallbackFolderSharedPrerequisite, LinuxUserInDockerGroupPrerequisite, DockerDaemonIsLinuxPrerequisite, DockerfileExistsPrerequisite, DotNetSdkInstalledPrerequisite } from '../../../extension.bundle';
|
||||
import { PlatformOS } from '../../../extension.bundle';
|
||||
import { DockerClient } from '../../../extension.bundle';
|
||||
import { DotNetClient } from '../../../extension.bundle';
|
||||
import { LaunchOptions } from '../../../extension.bundle';
|
||||
|
||||
suite('debugging/coreclr/prereqManager', () => {
|
||||
suite('DockerDaemonIsLinuxPrerequisite', () => {
|
||||
|
@ -217,7 +217,7 @@ suite('debugging/coreclr/prereqManager', () => {
|
|||
|
||||
let wasFileExistsCalled = false;
|
||||
|
||||
const fsProvider = <FileSystemProvider> {
|
||||
const fsProvider = <FileSystemProvider>{
|
||||
fileExists: (path: string) => {
|
||||
wasFileExistsCalled = true;
|
||||
|
||||
|
@ -253,7 +253,7 @@ suite('debugging/coreclr/prereqManager', () => {
|
|||
|
||||
const prereq = new DockerfileExistsPrerequisite(fsProvider, showErrorMessage, executeCommand);
|
||||
|
||||
const options = <LaunchOptions> {
|
||||
const options = <LaunchOptions>{
|
||||
build: {
|
||||
dockerfile
|
||||
}
|
||||
|
@ -264,7 +264,7 @@ suite('debugging/coreclr/prereqManager', () => {
|
|||
assert.equal(result, dockerfileExists, 'The prerequisite should return `true` when the Dockerfile exists.');
|
||||
assert.equal(wasFileExistsCalled, true, 'The Dockerfile should have been tested for existence.');
|
||||
assert.equal(wasShowErrorMessageCalled, !dockerfileExists, 'The user should be shown an error when the Dockerfile does not exist.');
|
||||
assert.equal(wasCommandExecuted, !dockerfileExists && userElectsToScaffold === true, 'The scaffold command should be executed only if the Dockerfile does not exist and the user elects to scaffold.');
|
||||
assert.equal(wasCommandExecuted, !dockerfileExists && userElectsToScaffold === true, 'The scaffold command should be executed only if the Dockerfile does not exist and the user elects to scaffold.');
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { ext, throwDockerConnectionError, internal } from '../extension';
|
||||
import { ext, throwDockerConnectionError, internal } from '../extension.bundle';
|
||||
import { Suite, Test, Context } from 'mocha';
|
||||
import { parseError, IActionContext } from 'vscode-azureextensionui';
|
||||
import { testUrl } from './testUrl';
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* Licensed under the MIT License. See LICENSE.md in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { docker } from '../extension';
|
||||
import { docker } from '../extension.bundle';
|
||||
import { EngineInfo } from "dockerode";
|
||||
|
||||
let info: EngineInfo | undefined;
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { getImageOrContainerDisplayName } from '../extension';
|
||||
import { getImageOrContainerDisplayName } from '../extension.bundle';
|
||||
|
||||
suite('getImageOrContainerDisplayName', () => {
|
||||
function genTest(fullName: string, trim: boolean, max: number, expected: string): void {
|
||||
|
|
|
@ -8,7 +8,7 @@ import * as path from "path";
|
|||
import * as fse from "fs-extra";
|
||||
import mocha = require("mocha");
|
||||
import * as assert from 'assert';
|
||||
import { ext } from "../extension";
|
||||
import { ext } from "../extension.bundle";
|
||||
import { TestKeytar } from "../test/testKeytar";
|
||||
|
||||
export namespace constants {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
import * as assert from 'assert';
|
||||
import { Suite, Test, Context } from 'mocha';
|
||||
import { nonNullProp } from '../extension';
|
||||
import { nonNullProp } from '../extension.bundle';
|
||||
|
||||
suite("nonNull", async function (this: Suite): Promise<void> {
|
||||
type TestSubscription = {
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* Licensed under the MIT License. See LICENSE.md in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IKeytar } from "../extension";
|
||||
import { IKeytar } from "../extension.bundle";
|
||||
|
||||
export class TestKeytar implements IKeytar {
|
||||
private _services: Map<string, Map<string, string>> = new Map<string, Map<string, string>>();
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { ITestCallbackContext } from "mocha";
|
||||
import { ext, wrapError } from "../extension";
|
||||
import { ext, wrapError } from "../extension.bundle";
|
||||
import { Uri } from "vscode";
|
||||
|
||||
export async function testUrl(url: string): Promise<void> {
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* Licensed under the MIT License. See LICENSE.md in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { trimWithElipsis } from "../extension";
|
||||
import { trimWithElipsis } from "../extension.bundle";
|
||||
import * as assert from 'assert';
|
||||
|
||||
suite('trimWithElipsis', () => {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { ext, isWindows10RS4OrNewer, isWindows10RS3OrNewer } from "../extension";
|
||||
import { ext, isWindows10RS4OrNewer, isWindows10RS3OrNewer } from "../extension.bundle";
|
||||
|
||||
suite("windowsVersion", () => {
|
||||
function testIsWindows10RS4OrNewer(release: string, expectedResult: boolean): void {
|
||||
|
|
|
@ -5,288 +5,156 @@
|
|||
|
||||
//@ts-check
|
||||
|
||||
// Using webpack helps reduce the install and startup time of large extensions by reducing the large number of files into a much smaller set
|
||||
// Full webpack documentation: [https://webpack.js.org/configuration/]().
|
||||
// See https://github.com/Microsoft/vscode-azuretools/wiki/webpack for guidance
|
||||
|
||||
'use strict';
|
||||
|
||||
const path = require('path');
|
||||
const process = require('process');
|
||||
const webpack = require('webpack');
|
||||
const fse = require('fs-extra');
|
||||
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
||||
const CleanWebpackPlugin = require('clean-webpack-plugin');
|
||||
const StringReplacePlugin = require("string-replace-webpack-plugin");
|
||||
const TerserPlugin = require('terser-webpack-plugin');
|
||||
|
||||
const packageLock = fse.readJSONSync('./package-lock.json');
|
||||
const dev = require("vscode-azureextensiondev");
|
||||
|
||||
let DEBUG_WEBPACK = !!process.env.DEBUG_WEBPACK;
|
||||
|
||||
const externalModules = [
|
||||
// Modules that we can't webpack for some reason.
|
||||
// Keep this list small, because all the subdependencies will also have to not be webpacked.
|
||||
let config = dev.getDefaultWebpackConfig({
|
||||
projectRoot: __dirname,
|
||||
verbosity: DEBUG_WEBPACK ? 'debug' : 'normal',
|
||||
|
||||
// has binary
|
||||
'clipboardy',
|
||||
externalNodeModules: [
|
||||
// Modules that we can't easily webpack for some reason.
|
||||
// These and their dependencies will be copied into node_modules rather than placed in the bundle
|
||||
// Keep this list small, because all the subdependencies will also be excluded
|
||||
|
||||
// has binary
|
||||
'win-ca'
|
||||
];
|
||||
|
||||
// External modules and all their dependencies and subdependencies (these will not be webpacked)
|
||||
const externalModulesClosure = getDependencies(externalModules);
|
||||
if (DEBUG_WEBPACK) {
|
||||
console.log('externalModulesClosure:', externalModulesClosure);
|
||||
}
|
||||
|
||||
/**@type {import('webpack').Configuration}*/
|
||||
const config = {
|
||||
// vscode extensions run in a Node.js context, see https://webpack.js.org/configuration/node/
|
||||
target: 'node',
|
||||
context: __dirname,
|
||||
node: {
|
||||
// For __dirname and __filename, use the path to the packed .js file (true would mean the relative path to the source file)
|
||||
__dirname: false,
|
||||
__filename: false
|
||||
},
|
||||
entry: {
|
||||
// has binary
|
||||
'win-ca'
|
||||
],
|
||||
entries: {
|
||||
// Note: Each entry is a completely separate Node.js application that cannot interact with any
|
||||
// of the others, and that individually includes all dependencies necessary (i.e. common
|
||||
// dependencies will have a copy in each entry file, no sharing).
|
||||
|
||||
// The entrypoint of this extension, see https://webpack.js.org/configuration/entry-context/
|
||||
extension: './extension.ts',
|
||||
|
||||
// Separate module for the language server (doesn't share any code with extension.js)
|
||||
'./dockerfile-language-server-nodejs/lib/server': './node_modules/dockerfile-language-server-nodejs/lib/server.js'
|
||||
},
|
||||
output: {
|
||||
// The bundles are stored in the 'dist' folder (check package.json), see https://webpack.js.org/configuration/output/
|
||||
path: path.resolve(__dirname, 'dist'),
|
||||
filename: '[name].js',
|
||||
libraryTarget: "commonjs2",
|
||||
devtoolModuleFilenameTemplate: "../[resource-path]"
|
||||
},
|
||||
devtool: 'source-map',
|
||||
externals: [
|
||||
|
||||
externals:
|
||||
{
|
||||
// ./getCoreNodeModule.js (path from keytar.ts) uses a dynamic require which can't be webpacked
|
||||
'./getCoreNodeModule': 'commonjs getCoreNodeModule',
|
||||
|
||||
'win-ca/fallback': 'commonjs win-ca/fallback',
|
||||
}, // end of externals
|
||||
|
||||
loaderRules: [
|
||||
{
|
||||
// Modules that cannot be webpack'ed, see https://webpack.js.org/configuration/externals/
|
||||
// Fix error:
|
||||
// > WARNING in ./node_modules/engine.io/lib/server.js 67:43-65
|
||||
// > Critical dependency: the request of a dependency is an expression
|
||||
// in this code:
|
||||
// var WebSocketServer = (this.wsEngine ? require(this.wsEngine) : require('ws')).Server;
|
||||
test: /engine\.io[/\\]lib[/\\]server.js$/,
|
||||
loader: StringReplacePlugin.replace({
|
||||
replacements: [
|
||||
{
|
||||
pattern: /var WebSocketServer = \(this.wsEngine \? require\(this\.wsEngine\) : require\('ws'\)\)\.Server;/ig,
|
||||
replacement: function (match, offset, string) {
|
||||
// Since we're not using the wsEngine option, we'll just require it to not be set and use only the `require('ws')` call.
|
||||
return `if (!!this.wsEngine) {
|
||||
throw new Error('wsEngine option not supported with current webpack settings');
|
||||
}
|
||||
var WebSocketServer = require('ws').Server;`;
|
||||
}
|
||||
}
|
||||
]
|
||||
})
|
||||
},
|
||||
|
||||
// the vscode-module is created on-the-fly and must be excluded.
|
||||
vscode: 'commonjs vscode',
|
||||
{
|
||||
// Fix warning:
|
||||
// > WARNING in ./node_modules/cross-spawn/index.js
|
||||
// > Module not found: Error: Can't resolve 'spawn-sync' in 'C:\Users\<user>\Repos\vscode-cosmosdb\node_modules\cross-spawn'
|
||||
// > @ ./node_modules/cross-spawn/index.js
|
||||
// in this code:
|
||||
// cpSpawnSync = require('spawn-sync'); // eslint-disable-line global-require
|
||||
test: /cross-spawn[/\\]index\.js$/,
|
||||
loader: StringReplacePlugin.replace({
|
||||
replacements: [
|
||||
{
|
||||
pattern: /cpSpawnSync = require\('spawn-sync'\);/ig,
|
||||
replacement: function (match, offset, string) {
|
||||
// The code in question only applies to Node 0.10 or less (see comments in code), so just throw an error
|
||||
return `throw new Error("This shouldn't happen"); // MODIFIED`;
|
||||
}
|
||||
}
|
||||
]
|
||||
})
|
||||
},
|
||||
|
||||
// util/getCoreNodeModule.js uses a dynamic require which can't be webpacked
|
||||
'./getCoreNodeModule': 'commonjs getCoreNodeModule',
|
||||
{
|
||||
// Unpack UMD module headers used in some modules since webpack doesn't
|
||||
// handle them.
|
||||
test: /dockerfile-language-service|vscode-languageserver-types/,
|
||||
use: { loader: 'umd-compat-loader' }
|
||||
},
|
||||
|
||||
'win-ca/fallback': 'commonjs win-ca/fallback',
|
||||
|
||||
// Pull the rest automatically from externalModulesClosure
|
||||
...getExternalsEntries()
|
||||
{
|
||||
// Fix error in win-ca: Module parse failed: 'return' outside of function (5:2)
|
||||
//
|
||||
// if (process.platform !== 'win32') {
|
||||
// return; <<<<<<<<<<
|
||||
// }
|
||||
test: /win-ca[/\\]lib[/\\]index.js$/,
|
||||
loader: StringReplacePlugin.replace({
|
||||
replacements: [
|
||||
{
|
||||
pattern: /return;/ig,
|
||||
replacement: function (match, offset, string) {
|
||||
return `// Don't need platform check - we do that before calling the module`;
|
||||
}
|
||||
}
|
||||
]
|
||||
})
|
||||
},
|
||||
{
|
||||
// Fix error in mac-ca: Module parse failed: 'return' outside of function (7:2)
|
||||
//
|
||||
// if (process.platform !== 'darwin') {
|
||||
// module.exports.all = () => [];
|
||||
// module.exports.each = () => {};
|
||||
// return; <<<<<<<<<
|
||||
// }
|
||||
test: /mac-ca[/\\]index.js$/,
|
||||
loader: StringReplacePlugin.replace({
|
||||
replacements: [
|
||||
{
|
||||
pattern: /return;/ig,
|
||||
replacement: function (match, offset, string) {
|
||||
return `// Don't need platform check - we do that before calling the module`;
|
||||
}
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
||||
],
|
||||
optimization: {
|
||||
minimizer: [
|
||||
new TerserPlugin({
|
||||
terserOptions: {
|
||||
// https://github.com/webpack-contrib/terser-webpack-plugin/
|
||||
], // end of loaderRules
|
||||
|
||||
// Without this, parseError() will not recognize user cancelled errors. Also makes debugging easier in production.
|
||||
keep_classnames: true
|
||||
}
|
||||
}),
|
||||
],
|
||||
},
|
||||
plugins: [
|
||||
// Clean the dist folder before webpacking
|
||||
new CleanWebpackPlugin(
|
||||
['dist'],
|
||||
{
|
||||
root: __dirname,
|
||||
verbose: true,
|
||||
}),
|
||||
|
||||
// Copy files to dist folder where the runtime can find them
|
||||
new CopyWebpackPlugin([
|
||||
// getCoreNodeModule.js -> dist/node_modules/getCoreNodeModule.js
|
||||
{ from: './utils/getCoreNodeModule.js', to: 'node_modules' },
|
||||
|
||||
// Test files -> dist/test (skipped during packaging)
|
||||
{ from: './out/test', to: 'test' }
|
||||
]),
|
||||
|
||||
// External node modules (can't be webpacked) -> dist/node_modules (where they can be found by extension.js)
|
||||
getExternalsCopyEntry(),
|
||||
|
||||
// Replace vscode-languageserver/lib/files.js with a modified version that doesn't have webpack issues
|
||||
new webpack.NormalModuleReplacementPlugin(
|
||||
/[/\\]vscode-languageserver[/\\]lib[/\\]files\.js/,
|
||||
require.resolve('./build/vscode-languageserver-files-stub.js')
|
||||
),
|
||||
|
||||
// Solve critical dependency issue in ./node_modules/ms-rest/lib/serviceClient.js (request of a dependency is an expression)
|
||||
// for this line:
|
||||
//
|
||||
// let data = require(packageJsonPath);
|
||||
//
|
||||
new webpack.ContextReplacementPlugin(
|
||||
// Whenever there is a dynamic require that webpack can't analyze at all (i.e. resourceRegExp=/^\./), ...
|
||||
/^\./,
|
||||
(context) => {
|
||||
// ... and the call was from within node_modules/ms-rest/lib...
|
||||
if (/node_modules[/\\]ms-rest[/\\]lib/.test(context.context)) {
|
||||
/* CONSIDER: Figure out how to make this work properly.
|
||||
|
||||
// ... tell webpack that the call may be loading any of the package.json files from the 'node_modules/azure-arm*' folders
|
||||
// so it will include those in the package to be available for lookup at runtime
|
||||
context.request = path.resolve(__dirname, 'node_modules');
|
||||
context.regExp = /azure-arm.*package\.json/;
|
||||
*/
|
||||
|
||||
// In the meantime, just ignore the error by telling webpack we've solved the critical dependency issue.
|
||||
// The consequences of ignoring this error are that
|
||||
// the Azure SDKs (e.g. azure-arm-resource) don't get their info stamped into the user agent info for their calls.
|
||||
for (const d of context.dependencies) {
|
||||
if (d.critical) { d.critical = false; }
|
||||
}
|
||||
}
|
||||
}),
|
||||
|
||||
// An instance of the StringReplacePlugin plugin must be present for it to work (its use is configured in modules).
|
||||
//
|
||||
// StringReplacePlugin allows you to specific parts of a file by regexp replacement to get around webpack issues such as dynamic imports.
|
||||
// This is different from ContextReplacementPlugin, which is simply meant to help webpack find files referred to by a dynamic import (i.e. it
|
||||
// assumes they can be found by simply knowing the correct the path).
|
||||
new StringReplacePlugin()
|
||||
],
|
||||
resolve: {
|
||||
// Support reading TypeScript and JavaScript files, see https://github.com/TypeStrong/ts-loader
|
||||
// These will be automatically transpiled while being placed into dist/extension.js
|
||||
extensions: ['.ts', '.js']
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.ts$/,
|
||||
exclude: /node_modules/,
|
||||
use: [{
|
||||
// Note: the TS loader will transpile the .ts file directly during webpack, it doesn't use the out folder.
|
||||
// CONSIDER: awesome-typescript-loader (faster?)
|
||||
loader: 'ts-loader'
|
||||
}]
|
||||
},
|
||||
|
||||
{
|
||||
// Unpack UMD module headers used in some modules since webpack doesn't
|
||||
// handle them.
|
||||
test: /dockerfile-language-service|vscode-languageserver-types/,
|
||||
use: { loader: 'umd-compat-loader' }
|
||||
},
|
||||
|
||||
{
|
||||
// Fix error in win-ca: Module parse failed: 'return' outside of function (5:2)
|
||||
//
|
||||
// if (process.platform !== 'win32') {
|
||||
// return; <<<<<<<<<<
|
||||
// }
|
||||
test: /win-ca[/\\]lib[/\\]index.js$/,
|
||||
loader: StringReplacePlugin.replace({
|
||||
replacements: [
|
||||
{
|
||||
pattern: /return;/ig,
|
||||
replacement: function (match, offset, string) {
|
||||
return `// Don't need platform check - we do that before calling the module`;
|
||||
}
|
||||
}
|
||||
]
|
||||
})
|
||||
},
|
||||
{
|
||||
// Fix error in mac-ca: Module parse failed: 'return' outside of function (7:2)
|
||||
//
|
||||
// if (process.platform !== 'darwin') {
|
||||
// module.exports.all = () => [];
|
||||
// module.exports.each = () => {};
|
||||
// return; <<<<<<<<<
|
||||
// }
|
||||
test: /mac-ca[/\\]index.js$/,
|
||||
loader: StringReplacePlugin.replace({
|
||||
replacements: [
|
||||
{
|
||||
pattern: /return;/ig,
|
||||
replacement: function (match, offset, string) {
|
||||
return `// Don't need platform check - we do that before calling the module`;
|
||||
}
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
||||
|
||||
// Note: If you use`vscode-nls` to localize your extension than you likely also use`vscode-nls-dev` to create language bundles at build time.
|
||||
// To support webpack, a loader has been added to vscode-nls-dev .Add the section below to the`modules/rules` configuration.
|
||||
// {
|
||||
// // vscode-nls-dev loader:
|
||||
// // * rewrite nls-calls
|
||||
// loader: 'vscode-nls-dev/lib/webpack-loader',
|
||||
// options: {
|
||||
// base: path.join(__dirname, 'src')
|
||||
// }
|
||||
// }
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
function getExternalsEntries() {
|
||||
let externals = {};
|
||||
for (let moduleName of externalModulesClosure) {
|
||||
// e.g.
|
||||
// '<clipboardy>': 'commonjs <clipboardy>',
|
||||
externals[moduleName] = `commonjs ${moduleName}`;
|
||||
}
|
||||
|
||||
return externals;
|
||||
}
|
||||
|
||||
function getExternalsCopyEntry() {
|
||||
// e.g.
|
||||
// new CopyWebpackPlugin([
|
||||
// { from: './node_modules/clipboardy', to: 'node_modules/clipboardy' }
|
||||
// ...
|
||||
// ])
|
||||
let patterns = [];
|
||||
for (let moduleName of externalModulesClosure) {
|
||||
patterns.push({
|
||||
from: `./node_modules/${moduleName}`,
|
||||
to: `node_modules/${moduleName}`
|
||||
});
|
||||
}
|
||||
|
||||
return new CopyWebpackPlugin(patterns);
|
||||
}
|
||||
|
||||
function getDependencies(modules) {
|
||||
let set = new Set();
|
||||
|
||||
for (let module of modules) {
|
||||
set.add(module);
|
||||
let depEntry = packageLock.dependencies[module];
|
||||
if (!depEntry) {
|
||||
throw new Error(`Could not find package-lock entry for ${module}`);
|
||||
}
|
||||
|
||||
if (depEntry.requires) {
|
||||
let requiredModules = Object.getOwnPropertyNames(depEntry.requires);
|
||||
let subdeps = getDependencies(requiredModules);
|
||||
for (let subdep of subdeps) {
|
||||
set.add(subdep);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Array.from(set);
|
||||
}
|
||||
// Copy files to dist folder where the runtime can find them
|
||||
new CopyWebpackPlugin([
|
||||
// getCoreNodeModule.js -> dist/node_modules/getCoreNodeModule.js
|
||||
{ from: './utils/getCoreNodeModule.js', to: 'node_modules' }
|
||||
])
|
||||
]
|
||||
});
|
||||
|
||||
if (DEBUG_WEBPACK) {
|
||||
console.log('Config:', config);
|
||||
}
|
||||
|
||||
module.exports = config;
|
||||
|
|
Загрузка…
Ссылка в новой задаче