Add option to debug without webpack (#920)

This commit is contained in:
Eric Jizba 2019-05-06 17:17:31 +00:00 коммит произвёл GitHub
Родитель 9674a3239c
Коммит 2016688ce2
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
19 изменённых файлов: 129 добавлений и 119 удалений

48
.vscode/launch.json поставляемый
Просмотреть файл

@ -11,12 +11,31 @@
"--extensionDevelopmentPath=${workspaceFolder}"
],
"env": {
"AZCODE_DOCKER_IGNORE_BUNDLE": "1",
"DEBUGTELEMETRY": "1"
},
"stopOnEntry": false,
"sourceMaps": true,
"outFiles": [
"${workspaceFolder}/../dist/**/*.js"
"${workspaceFolder}/out/**/*.js"
],
"preLaunchTask": "npm: compile"
},
{
"name": "Launch Extension (webpack)",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}"
],
"env": {
"DEBUGTELEMETRY": "1"
},
"stopOnEntry": false,
"sourceMaps": true,
"outFiles": [
"${workspaceFolder}/out/**/*.js"
],
"preLaunchTask": "npm: pretest"
},
@ -25,6 +44,30 @@
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"${workspaceFolder}/test/test.code-workspace",
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test"
],
"stopOnEntry": false,
"sourceMaps": true,
"outFiles": [
"${workspaceFolder}/out/**/*.js"
],
"preLaunchTask": "npm: compile",
"env": {
"AZCODE_DOCKER_IGNORE_BUNDLE": "1",
"MOCHA_grep": "", // RegExp of tests to run (empty means all)
"MOCHA_enableTimeouts": "0", // Disable time-outs
"DEBUGTELEMETRY": "1",
"NODE_DEBUG": ""
}
},
{
"name": "Launch Tests (webpack)",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"${workspaceFolder}/test/test.code-workspace",
"--extensionDevelopmentPath=${workspaceFolder}",
@ -32,6 +75,9 @@
],
"stopOnEntry": false,
"sourceMaps": true,
"outFiles": [
"${workspaceFolder}/dist/**/*.js"
],
"preLaunchTask": "npm: pretest",
"env": {
"MOCHA_grep": "", // RegExp of tests to run (empty means all)

23
.vscode/tasks.json поставляемый
Просмотреть файл

@ -1,33 +1,16 @@
// Available variables which can be used inside of strings.
// ${workspaceFolder}: the root folder of the team
// ${file}: the current opened file
// ${fileBasename}: the current opened file's basename
// ${fileDirname}: the current opened file's dirname
// ${fileExtname}: the current opened file's extension
// ${cwd}: the current working directory of the spawned process
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// Also: https://raw.githubusercontent.com/Microsoft/vscode-tslint/master/tslint-tests/.vscode/tasks.json
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "npm",
"type": "shell",
"command": "npm",
"type": "npm",
"script": "compile",
"group": {
"kind": "build",
"isDefault": true
},
"args": [
"run",
"compile",
"--loglevel",
"silent"
],
"isBackground": true,
"presentation": {
"reveal": "never"
"reveal": "silent"
},
"problemMatcher": "$tsc-watch"
},

Просмотреть файл

@ -3,12 +3,8 @@
* Licensed under the MIT License. See LICENSE.md in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as path from 'path';
export const configPrefix: string = 'docker';
export const imagesPath: string = path.join(__dirname, '../images');
//AsyncPool Constants
export const MAX_CONCURRENT_REQUESTS = 8;
export const MAX_CONCURRENT_SUBSCRIPTON_REQUESTS = 5;

Просмотреть файл

@ -5,17 +5,16 @@
import * as ContainerModels from 'azure-arm-containerregistry/lib/models';
import { SubscriptionModels } from 'azure-arm-resource';
import * as path from 'path';
import * as vscode from 'vscode';
import { callWithTelemetryAndErrorHandling, IActionContext } from 'vscode-azureextensionui';
import { imagesPath } from '../../constants';
import { AzureAccount } from '../../typings/azure-account.api';
import { getImagesByRepository, getRepositoriesByRegistry } from '../../utils/Azure/acrTools';
import { AzureImage } from '../../utils/Azure/models/image';
import { Repository } from '../../utils/Azure/models/repository';
import { getLoginServer } from '../../utils/nonNull';
import { treeUtils } from '../../utils/treeUtils';
import { formatTag } from './commonRegistryUtils';
import { IconPath, NodeBase } from './nodeBase';
import { NodeBase } from './nodeBase';
import { TaskRootNode } from './taskNode';
export class AzureRegistryNode extends NodeBase {
@ -29,10 +28,7 @@ export class AzureRegistryNode extends NodeBase {
}
public readonly contextValue: string = 'azureRegistryNode';
public readonly iconPath: IconPath = {
light: path.join(imagesPath, 'light', 'Registry_16x.svg'),
dark: path.join(imagesPath, 'dark', 'Registry_16x.svg')
};
public readonly iconPath: treeUtils.IThemedIconPath = treeUtils.getThemedIconPath('Registry_16x');
public getTreeItem(): vscode.TreeItem {
return {
@ -91,10 +87,7 @@ export class AzureRepositoryNode extends NodeBase {
public static readonly contextValue: string = 'azureRepositoryNode';
public readonly contextValue: string = AzureRepositoryNode.contextValue;
public readonly iconPath: { light: string | vscode.Uri; dark: string | vscode.Uri } = {
light: path.join(imagesPath, 'light', 'Repository_16x.svg'),
dark: path.join(imagesPath, 'dark', 'Repository_16x.svg')
};
public readonly iconPath: treeUtils.IThemedIconPath = treeUtils.getThemedIconPath('Repository_16x');
public getTreeItem(): vscode.TreeItem {
return {

Просмотреть файл

@ -4,7 +4,8 @@
*--------------------------------------------------------------------------------------------*/
import * as vscode from 'vscode';
import { IconPath, NodeBase } from './nodeBase';
import { treeUtils } from '../../utils/treeUtils';
import { NodeBase } from './nodeBase';
export type ContainerNodeContextValue = 'stoppedLocalContainerNode' | 'runningLocalContainerNode';
@ -14,7 +15,7 @@ export class ContainerNode extends NodeBase {
public readonly label: string,
public readonly containerDesc: Docker.ContainerDesc,
public readonly contextValue: ContainerNodeContextValue,
public readonly iconPath: IconPath
public readonly iconPath: treeUtils.IThemedIconPath
) {
super(label)
}

Просмотреть файл

@ -6,7 +6,7 @@
import * as path from 'path';
import * as vscode from 'vscode';
import { callWithTelemetryAndErrorHandling, IActionContext, parseError } from 'vscode-azureextensionui';
import { imagesPath } from '../../constants';
import { treeUtils } from '../../utils/treeUtils';
import { formatTag, getCatalog, getTags, registryRequest } from './commonRegistryUtils';
import { CustomRegistry } from './customRegistries';
import { NodeBase } from './nodeBase';
@ -18,10 +18,7 @@ export class CustomRegistryNode extends NodeBase {
public static readonly contextValue: string = 'customRegistryNode';
public contextValue: string = CustomRegistryNode.contextValue;
public iconPath: string | vscode.Uri | { light: string | vscode.Uri; dark: string | vscode.Uri } = {
light: path.join(imagesPath, 'light', 'Registry_16x.svg'),
dark: path.join(imagesPath, 'dark', 'Registry_16x.svg')
};
public readonly iconPath: treeUtils.IThemedIconPath = treeUtils.getThemedIconPath('Registry_16x');
constructor(
public registryName: string,
@ -70,10 +67,7 @@ export class CustomRegistryNode extends NodeBase {
export class CustomRepositoryNode extends NodeBase {
public static readonly contextValue: string = 'customRepository';
public contextValue: string = CustomRepositoryNode.contextValue;
public iconPath: string | vscode.Uri | { light: string | vscode.Uri; dark: string | vscode.Uri } = {
light: path.join(imagesPath, 'light', 'Repository_16x.svg'),
dark: path.join(imagesPath, 'dark', 'Repository_16x.svg')
};
public readonly iconPath: treeUtils.IThemedIconPath = treeUtils.getThemedIconPath('Repository_16x');
constructor(
public readonly repositoryName: string, // e.g. 'hello-world' or 'registry'

Просмотреть файл

@ -3,11 +3,11 @@
* Licensed under the MIT License. See LICENSE.md in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as path from 'path';
import * as vscode from 'vscode';
import { callWithTelemetryAndErrorHandling, IActionContext } from 'vscode-azureextensionui';
import { imagesPath, MAX_CONCURRENT_REQUESTS } from '../../constants';
import { MAX_CONCURRENT_REQUESTS } from '../../constants';
import { AsyncPool } from '../../utils/asyncpool';
import { treeUtils } from '../../utils/treeUtils';
import * as dockerHub from '../utils/dockerHubUtils';
import { formatTag } from './commonRegistryUtils';
import { NodeBase } from './nodeBase';
@ -30,10 +30,7 @@ export class DockerHubOrgNode extends NodeBase {
public readonly contextValue: string = DockerHubOrgNode.contextValue;
public readonly label: string = this.namespace;
public iconPath: string | vscode.Uri | { light: string | vscode.Uri; dark: string | vscode.Uri } = {
light: path.join(imagesPath, 'light', 'Registry_16x.svg'),
dark: path.join(imagesPath, 'dark', 'Registry_16x.svg')
};
public readonly iconPath: treeUtils.IThemedIconPath = treeUtils.getThemedIconPath('Registry_16x');
public getTreeItem(): vscode.TreeItem {
return {
@ -86,10 +83,7 @@ export class DockerHubRepositoryNode extends NodeBase {
public static readonly contextValue: string = 'dockerHubRepositoryNode';
public readonly contextValue: string = DockerHubRepositoryNode.contextValue;
public iconPath: string | vscode.Uri | { light: string | vscode.Uri; dark: string | vscode.Uri } = {
light: path.join(imagesPath, 'light', 'Repository_16x.svg'),
dark: path.join(imagesPath, 'dark', 'Repository_16x.svg')
};
public readonly iconPath: treeUtils.IThemedIconPath = treeUtils.getThemedIconPath('Repository_16x');
public repository: dockerHub.RepositoryInfo;
public userName: string;
public password: string;

Просмотреть файл

@ -3,10 +3,9 @@
* Licensed under the MIT License. See LICENSE.md in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as path from 'path';
import * as vscode from 'vscode';
import { parseError } from 'vscode-azureextensionui';
import { imagesPath } from '../../constants';
import { treeUtils } from '../../utils/treeUtils';
import { NodeBase } from './nodeBase';
export type IconPath = string | vscode.Uri | { light: string | vscode.Uri; dark: string | vscode.Uri } | vscode.ThemeIcon;
@ -15,7 +14,7 @@ export class ErrorNode extends NodeBase {
public static readonly getImagesErrorContextValue: string = 'ErrorNode.getImages';
public static readonly getContainersErrorContextValue: string = 'ErrorNode.getContainers';
public readonly iconPath: IconPath = path.join(imagesPath, 'warning.svg');
public readonly iconPath: string = treeUtils.getIconPath('warning');
constructor(error: unknown, public readonly contextValue: string) {
super(parseError(error).message);

Просмотреть файл

@ -3,9 +3,8 @@
* Licensed under the MIT License. See LICENSE.md in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as path from 'path';
import * as vscode from 'vscode';
import { imagesPath } from '../../constants';
import { treeUtils } from '../../utils/treeUtils';
import { ImageNode } from './imageNode';
import { NodeBase } from './nodeBase';
@ -28,10 +27,7 @@ export class ImageGroupNode extends NodeBase {
label: this.label,
collapsibleState: vscode.TreeItemCollapsibleState.Collapsed,
contextValue: this.contextValue,
iconPath: {
light: path.join(imagesPath, 'light', this.iconName),
dark: path.join(imagesPath, 'dark', this.iconName)
}
iconPath: treeUtils.getThemedIconPath(this.iconName)
}
}

Просмотреть файл

@ -4,8 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import * as vscode from 'vscode';
export type IconPath = string | vscode.Uri | { light: string | vscode.Uri; dark: string | vscode.Uri } | vscode.ThemeIcon;
import { treeUtils } from '../../utils/treeUtils';
export abstract class NodeBase {
public readonly label: string;
@ -28,5 +27,5 @@ export abstract class NodeBase {
return [];
}
public iconPath?: IconPath;
public iconPath?: string | vscode.Uri | treeUtils.IThemedIconPath | vscode.ThemeIcon;
}

Просмотреть файл

@ -4,14 +4,13 @@
*--------------------------------------------------------------------------------------------*/
import * as assert from 'assert';
import * as path from 'path';
import * as vscode from 'vscode';
import { callWithTelemetryAndErrorHandling, IActionContext } from 'vscode-azureextensionui';
import { docker, ListContainerDescOptions as GetContainerDescOptions } from '../../commands/utils/docker-endpoint';
import { imagesPath } from '../../constants';
import { ext, ImageGrouping } from '../../extensionVariables';
import { AzureAccount } from '../../typings/azure-account.api';
import { AzureUtilityManager } from '../../utils/azureUtilityManager';
import { treeUtils } from '../../utils/treeUtils';
import { showDockerConnectionError } from '../utils/dockerConnectionError';
import { ContainerNode, ContainerNodeContextValue } from './containerNode';
import { ErrorNode } from './errorNode';
@ -19,7 +18,7 @@ import { getContainerLabel } from './getContainerLabel';
import { getImageLabel } from './getImageLabel';
import { ImageGroupNode } from './imageGroupNode';
import { ImageNode } from './imageNode';
import { IconPath, NodeBase } from './nodeBase';
import { NodeBase } from './nodeBase';
import { RegistryRootNode } from './registryRootNode';
const imageFilters = {
@ -199,17 +198,17 @@ export class RootNode extends NodeBase {
case ImageGrouping.ImageId:
groupLabelTemplate = '{shortImageId}';
leafLabelTemplate = '{fullTag} ({createdSince})';
groupIconName = 'ApplicationGroup_16x.svg';
groupIconName = 'ApplicationGroup_16x';
break;
case ImageGrouping.Repository:
groupLabelTemplate = '{repository}';
leafLabelTemplate = '{tag} ({createdSince})';
groupIconName = 'Repository_16x.svg';
groupIconName = 'Repository_16x';
break;
case ImageGrouping.RepositoryName:
groupLabelTemplate = '{repositoryName}';
leafLabelTemplate = '{fullTag} ({createdSince})';
groupIconName = 'ApplicationGroup_16x.svg';
groupIconName = 'ApplicationGroup_16x';
break;
default:
assert(`Unexpected groupImagesBy ${ext.groupImagesBy}`);
@ -343,7 +342,7 @@ export class RootNode extends NodeBase {
const containerNodes: ContainerNode[] = [];
let containers: Docker.ContainerDesc[];
let contextValue: ContainerNodeContextValue;
let iconPath: IconPath;
let iconPath: treeUtils.IThemedIconPath;
try {
containers = await docker.getContainerDescriptors(containerFilters);
@ -359,29 +358,17 @@ export class RootNode extends NodeBase {
case "dead":
case "exited":
case "created":
iconPath = {
light: path.join(imagesPath, 'light', 'StatusStop_16x.svg'),
dark: path.join(imagesPath, 'dark', 'StatusStop_16x.svg'),
};
iconPath = treeUtils.getThemedIconPath('StatusStop_16x');
break;
case "paused":
iconPath = {
light: path.join(imagesPath, 'light', 'StatusPause_16x.svg'),
dark: path.join(imagesPath, 'dark', 'StatusPause_16x.svg'),
};
iconPath = treeUtils.getThemedIconPath('StatusPause_16x');
break;
case "restarting":
iconPath = {
light: path.join(imagesPath, 'light', 'Restart_16x.svg'),
dark: path.join(imagesPath, 'dark', 'Restart_16x.svg'),
};
iconPath = treeUtils.getThemedIconPath('Restart_16x');
break;
case "running":
default:
iconPath = {
light: path.join(imagesPath, 'light', 'StatusRun_16x.svg'),
dark: path.join(imagesPath, 'dark', 'StatusRun_16x.svg'),
};
iconPath = treeUtils.getThemedIconPath('StatusRun_16x');
}
// Determine contextValue
@ -390,10 +377,7 @@ export class RootNode extends NodeBase {
} else if (me.isContainerUnhealthy(container)) {
contextValue = "runningLocalContainerNode";
// Override icon from above
iconPath = {
light: path.join(imagesPath, 'light', 'StatusWarning_16x.svg'),
dark: path.join(imagesPath, 'dark', 'StatusWarning_16x.svg'),
};
iconPath = treeUtils.getThemedIconPath('StatusWarning_16x');
} else {
contextValue = "runningLocalContainerNode";
}

Просмотреть файл

@ -1,13 +1,17 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See LICENSE.md in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import ContainerRegistryManagementClient from 'azure-arm-containerregistry';
import * as ContainerModels from 'azure-arm-containerregistry/lib/models';
import { SubscriptionModels } from 'azure-arm-resource';
import * as path from 'path';
import * as vscode from 'vscode';
import { callWithTelemetryAndErrorHandling, IActionContext } from 'vscode-azureextensionui';
import { imagesPath } from '../../constants';
import { AzureAccount } from '../../typings/azure-account.api';
import * as acrTools from '../../utils/Azure/acrTools';
import { AzureUtilityManager } from '../../utils/azureUtilityManager';
import { treeUtils } from '../../utils/treeUtils';
import { openExternal } from '../utils/openExternal';
import { NodeBase } from './nodeBase';
@ -28,10 +32,7 @@ export class TaskRootNode extends NodeBase {
public readonly contextValue: string = 'taskRootNode';
public name: string;
public readonly iconPath: { light: string | vscode.Uri; dark: string | vscode.Uri } = {
light: path.join(imagesPath, 'light', 'tasks_light.svg'),
dark: path.join(imagesPath, 'dark', 'tasks_dark.svg')
};
public readonly iconPath: treeUtils.IThemedIconPath = treeUtils.getThemedIconPath('tasks');
public getTreeItem(): vscode.TreeItem {
return {

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 1.6 KiB

После

Ширина:  |  Высота:  |  Размер: 1.6 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 1.6 KiB

После

Ширина:  |  Высота:  |  Размер: 1.6 KiB

Просмотреть файл

@ -16,7 +16,9 @@ let perfStats = {
Object.defineProperty(exports, "__esModule", { value: true });
const extension = require("./dist/extension.bundle");
const ignoreBundle = !/^(false|0)?$/i.test(process.env.AZCODE_DOCKER_IGNORE_BUNDLE || '');
const extensionPath = ignoreBundle ? "./out/extension" : "./dist/extension.bundle";
const extension = require(extensionPath);
async function activate(ctx) {
return await extension.activateInternal(ctx, perfStats);

Просмотреть файл

@ -3,31 +3,24 @@
* Licensed under the MIT License. See LICENSE.md in the project root for license information.
*--------------------------------------------------------------------------------------------*/
"use strict";
// Our util/getCoreNodeModule.js file uses a dynamic require that depends on the environment and so has to be excluded
// from webpack'ing, and we'll just copy it to the distribution folder.
//
// Since webpack shouldn't have to depend on npm build to transpile .ts -> .js, we keep this file in .js.
Object.defineProperty(exports, "__esModule", { value: true });
const vscode = require("vscode");
import * as vscode from 'vscode';
/**
* Returns a node module installed with VSCode, or undefined if it fails.
*/
function getCoreNodeModule(moduleName) {
export function getCoreNodeModule<T>(moduleName: string): T | undefined {
try {
// tslint:disable-next-line:non-literal-require no-unsafe-any
return require(`${vscode.env.appRoot}/node_modules.asar/${moduleName}`);
} catch (err) {
// ignore
}
catch (err) { }
try {
// tslint:disable-next-line:non-literal-require no-unsafe-any
return require(`${vscode.env.appRoot}/node_modules/${moduleName}`);
} catch (err) {
// ignore
}
catch (err) { }
return undefined;
}
exports.getCoreNodeModule = getCoreNodeModule;

Просмотреть файл

@ -45,7 +45,7 @@ export interface IKeytar {
*/
function getKeytarModule(): typeof keytarType {
// tslint:disable-next-line: no-unsafe-any
const keytar = <typeof keytarType | undefined>getCoreNodeModule('keytar');
const keytar = getCoreNodeModule<typeof keytarType>('keytar');
if (!keytar) {
throw new Error("Internal error: Could not find keytar module for reading and writing passwords");
} else {

29
utils/treeUtils.ts Normal file
Просмотреть файл

@ -0,0 +1,29 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as path from 'path';
import { ext } from '../extensionVariables';
export namespace treeUtils {
export interface IThemedIconPath {
light: string;
dark: string;
}
export function getIconPath(iconName: string): string {
return path.join(getImagesPath(), `${iconName}.svg`);
}
export function getThemedIconPath(iconName: string): IThemedIconPath {
return {
light: path.join(getImagesPath(), 'light', `${iconName}.svg`),
dark: path.join(getImagesPath(), 'dark', `${iconName}.svg`)
};
}
function getImagesPath(): string {
return ext.context.asAbsolutePath('images');
}
}

Просмотреть файл

@ -148,7 +148,7 @@ let config = dev.getDefaultWebpackConfig({
// 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' }
{ from: './out/utils/getCoreNodeModule.js', to: 'node_modules' }
])
]
});