Fixes #217: Adopt the usage of ASAR in VSCode

This commit is contained in:
Alex Dima 2018-02-23 16:00:58 +01:00
Родитель 782f0f30bb
Коммит 2e42683e5f
7 изменённых файлов: 28 добавлений и 10 удалений

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

@ -1,3 +1,6 @@
## 0.0.25 - 23 Feb 2018
* Fixes [#217](https://github.com/Microsoft/vscode-docker/issues/217) to adopt the usage of ASAR in VS Code
## 0.0.24 - 02 Feb 2018 ## 0.0.24 - 02 Feb 2018
* Fixes [#189](https://github.com/Microsoft/vscode-docker/issues/189) to provide friendly errors when Docker is not running * Fixes [#189](https://github.com/Microsoft/vscode-docker/issues/189) to provide friendly errors when Docker is not running
* Fixes [#200](https://github.com/Microsoft/vscode-docker/issues/200) to provide two new options `dockerComposeBuild` and `dockerComposeDetached` control how `docker-compose` is launched * Fixes [#200](https://github.com/Microsoft/vscode-docker/issues/200) to provide two new options `dockerComposeBuild` and `dockerComposeDetached` control how `docker-compose` is launched

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

@ -1,13 +1,14 @@
import vscode = require('vscode'); import vscode = require('vscode');
import { reporter } from '../telemetry/telemetry'; import { reporter } from '../telemetry/telemetry';
import { docker } from './utils/docker-endpoint'; import { docker } from './utils/docker-endpoint';
import { getCoreNodeModule } from '../explorer/utils/utils';
const teleCmdId: string = 'vscode-docker.system.prune'; const teleCmdId: string = 'vscode-docker.system.prune';
export async function systemPrune() { export async function systemPrune() {
const configOptions: vscode.WorkspaceConfiguration = vscode.workspace.getConfiguration('docker'); const configOptions: vscode.WorkspaceConfiguration = vscode.workspace.getConfiguration('docker');
const terminal = vscode.window.createTerminal("docker system prune"); const terminal = vscode.window.createTerminal("docker system prune");
const semver = require(`${vscode.env.appRoot}/node_modules/semver`); const semver = getCoreNodeModule(`semver`);
try { try {

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

@ -12,6 +12,7 @@ import { NodeBase } from './nodeBase';
import { RegistryType } from './registryType'; import { RegistryType } from './registryType';
import { ServiceClientCredentials } from 'ms-rest'; import { ServiceClientCredentials } from 'ms-rest';
import { SubscriptionClient, ResourceManagementClient, SubscriptionModels } from 'azure-arm-resource'; import { SubscriptionClient, ResourceManagementClient, SubscriptionModels } from 'azure-arm-resource';
import { getCoreNodeModule } from '../utils/utils';
const ContainerRegistryManagement = require('azure-arm-containerregistry'); const ContainerRegistryManagement = require('azure-arm-containerregistry');
@ -26,11 +27,7 @@ export class RegistryRootNode extends NodeBase {
public readonly azureAccount?: AzureAccount public readonly azureAccount?: AzureAccount
) { ) {
super(label); super(label);
try { this._keytar = getCoreNodeModule(`keytar`);
this._keytar = require(`${vscode.env.appRoot}/node_modules/keytar`);
} catch (e) {
// unable to find keytar
}
this._azureAccount = azureAccount; this._azureAccount = azureAccount;

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

@ -3,6 +3,7 @@ import * as keytarType from 'keytar';
import * as opn from 'opn'; import * as opn from 'opn';
import request = require('request-promise'); import request = require('request-promise');
import { DockerHubRepositoryNode, DockerHubImageNode, DockerHubOrgNode } from '../models/dockerHubNodes'; import { DockerHubRepositoryNode, DockerHubImageNode, DockerHubOrgNode } from '../models/dockerHubNodes';
import { getCoreNodeModule } from './utils';
let _token: Token; let _token: Token;
@ -79,7 +80,7 @@ export interface Image {
export function dockerHubLogout(): void { export function dockerHubLogout(): void {
const keytar: typeof keytarType = require(`${vscode.env.appRoot}/node_modules/keytar`); const keytar: typeof keytarType = getCoreNodeModule(`keytar`);
if (keytar) { if (keytar) {
keytar.deletePassword('vscode-docker', 'dockerhub.token'); keytar.deletePassword('vscode-docker', 'dockerhub.token');
keytar.deletePassword('vscode-docker', 'dockerhub.password'); keytar.deletePassword('vscode-docker', 'dockerhub.password');

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

@ -1,3 +1,4 @@
import * as vscode from 'vscode';
export function trimWithElipsis(str: string, max: number = 10): string { export function trimWithElipsis(str: string, max: number = 10): string {
const elipsis: string = "..."; const elipsis: string = "...";
@ -11,4 +12,19 @@ export function trimWithElipsis(str: string, max: number = 10): string {
const back: string = str.substr(len - (len / 2) + (-0.5 * (max - len - 3))); const back: string = str.substr(len - (len / 2) + (-0.5 * (max - len - 3)));
return front + elipsis + back; return front + elipsis + back;
} }
/**
* Returns a node module installed with VSCode, or null if it fails.
*/
export function getCoreNodeModule(moduleName: string) {
try {
return require(`${vscode.env.appRoot}/node_modules.asar/${moduleName}`);
} catch (err) { }
try {
return require(`${vscode.env.appRoot}/node_modules/${moduleName}`);
} catch (err) { }
return null;
}

2
package-lock.json сгенерированный
Просмотреть файл

@ -1,6 +1,6 @@
{ {
"name": "vscode-docker", "name": "vscode-docker",
"version": "0.0.24", "version": "0.0.25",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

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

@ -1,6 +1,6 @@
{ {
"name": "vscode-docker", "name": "vscode-docker",
"version": "0.0.24", "version": "0.0.25",
"publisher": "PeterJausovec", "publisher": "PeterJausovec",
"displayName": "Docker", "displayName": "Docker",
"description": "Adds syntax highlighting, commands, hover tips, and linting for Dockerfile and docker-compose files.", "description": "Adds syntax highlighting, commands, hover tips, and linting for Dockerfile and docker-compose files.",