Switch to VS Code built-in clipboard API (#272)

This commit is contained in:
Ray Fang 2019-02-19 15:09:22 +08:00 коммит произвёл GitHub
Родитель 8297a61bda
Коммит 6435914026
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
8 изменённых файлов: 146 добавлений и 936 удалений

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

@ -17,3 +17,4 @@ tslint.json
out/**
webpack.config.js
node_modules/**
scripts/**

1009
package-lock.json сгенерированный

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -7,7 +7,7 @@
"aiKey": "0caaff90-cc1c-4def-b64c-3ef33615bc9b",
"icon": "logo.png",
"engines": {
"vscode": "^1.26.0"
"vscode": "^1.30.0"
},
"license": "SEE LICENSE IN LICENSE.txt",
"repository": {
@ -66,7 +66,7 @@
"onCommand:azure-iot-toolkit.getModule",
"onCommand:azure-iot-toolkit.copyModuleConnectionString"
],
"main": "./dist/scripts/extension",
"main": "./dist/extension",
"contributes": {
"views": {
"explorer": [
@ -584,7 +584,7 @@
{
"command": "azure-iot-toolkit.editDistributedTracingMode",
"when": "never"
},
},
{
"command": "azure-iot-toolkit.editDistributedTracingSamplingRate",
"when": "never"
@ -684,7 +684,7 @@
"@types/fs-extra": "^5.0.4",
"@types/mocha": "^2.2.32",
"@types/node": "^10.12.3",
"copy-webpack-plugin": "^4.6.0",
"@types/terser-webpack-plugin": "^1.2.0",
"fail-on-errors-webpack-plugin": "^3.0.0",
"mocha": "^5.1.1",
"rimraf": "^2.6.2",
@ -692,11 +692,10 @@
"terser-webpack-plugin": "^1.2.1",
"ts-loader": "^5.3.1",
"tslint": "^4.5.1",
"typescript": "^2.2.1",
"vscode": "^1.1.22",
"typescript": "^3.0.0",
"vscode": "^1.1.29",
"webpack": "^4.27.1",
"webpack-cli": "^3.1.2",
"webpack-permissions-plugin": "^1.0.0"
"webpack-cli": "^3.1.2"
},
"dependencies": {
"@azure/event-hubs": "^1.0.8",
@ -706,7 +705,6 @@
"azure-iot-device": "^1.8.1",
"azure-iot-device-mqtt": "^1.8.1",
"azure-iothub": "^1.8.1",
"clipboardy": "^1.1.4",
"fs-extra": "^7.0.0",
"ms-rest": "^2.3.2",
"ms-rest-azure": "^2.5.5",

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

@ -119,12 +119,12 @@ export class AzureIoTExplorer {
return this._iotHubResourceExplorer.selectIoTHub(outputChannel, subscriptionId);
}
public copyIoTHubConnectionString(): void {
this._iotHubResourceExplorer.copyIoTHubConnectionString();
public async copyIoTHubConnectionString() {
await this._iotHubResourceExplorer.copyIoTHubConnectionString();
}
public copyDeviceConnectionString(deviceItem: DeviceItem): void {
this._iotHubResourceExplorer.copyDeviceConnectionString(deviceItem);
public async copyDeviceConnectionString(deviceItem: DeviceItem) {
await this._iotHubResourceExplorer.copyDeviceConnectionString(deviceItem);
}
public replaceConnectionString(event: vscode.TextDocumentChangeEvent): void {
@ -179,7 +179,7 @@ export class AzureIoTExplorer {
this._iotHubModuleExplorer.getModule(moduleItem);
}
public copyModuleConnectionString(moduleItem: ModuleItem): void {
this._iotHubModuleExplorer.copyModuleConnectionString(moduleItem);
public async copyModuleConnectionString(moduleItem: ModuleItem) {
await this._iotHubModuleExplorer.copyModuleConnectionString(moduleItem);
}
}

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

@ -112,12 +112,12 @@ export function activate(context: vscode.ExtensionContext) {
azureIoTExplorer.selectIoTHub();
});
let copyIoTHubConnectionString = vscode.commands.registerCommand("azure-iot-toolkit.copyIoTHubConnectionString", () => {
azureIoTExplorer.copyIoTHubConnectionString();
let copyIoTHubConnectionString = vscode.commands.registerCommand("azure-iot-toolkit.copyIoTHubConnectionString", async () => {
await azureIoTExplorer.copyIoTHubConnectionString();
});
let copyDeviceConnectionString = vscode.commands.registerCommand("azure-iot-toolkit.copyDeviceConnectionString", (deviceNode: DeviceNode) => {
azureIoTExplorer.copyDeviceConnectionString(deviceNode ? deviceNode.deviceItem : undefined);
let copyDeviceConnectionString = vscode.commands.registerCommand("azure-iot-toolkit.copyDeviceConnectionString", async (deviceNode: DeviceNode) => {
await azureIoTExplorer.copyDeviceConnectionString(deviceNode ? deviceNode.deviceItem : undefined);
});
context.subscriptions.push(vscode.commands.registerCommand("azure-iot-toolkit.createEdgeDevice", async () => {
@ -169,8 +169,8 @@ export function activate(context: vscode.ExtensionContext) {
azureIoTExplorer.getModule(moduleItemNode ? moduleItemNode.moduleItem : undefined);
}));
context.subscriptions.push(vscode.commands.registerCommand("azure-iot-toolkit.copyModuleConnectionString", (moduleItemNode: ModuleItemNode) => {
azureIoTExplorer.copyModuleConnectionString(moduleItemNode ? moduleItemNode.moduleItem : undefined);
context.subscriptions.push(vscode.commands.registerCommand("azure-iot-toolkit.copyModuleConnectionString", async (moduleItemNode: ModuleItemNode) => {
await azureIoTExplorer.copyModuleConnectionString(moduleItemNode ? moduleItemNode.moduleItem : undefined);
}));
vscode.workspace.onDidChangeTextDocument((event) => azureIoTExplorer.replaceConnectionString(event));

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

@ -3,7 +3,6 @@
"use strict";
import * as iothub from "azure-iothub";
import * as clipboardy from "clipboardy";
import * as vscode from "vscode";
import { BaseExplorer } from "./baseExplorer";
import { Constants } from "./constants";
@ -77,10 +76,10 @@ export class IotHubModuleExplorer extends BaseExplorer {
});
}
public copyModuleConnectionString(moduleItem: ModuleItem) {
public async copyModuleConnectionString(moduleItem: ModuleItem) {
TelemetryClient.sendEvent("AZ.Copy.ModuleConnectionString");
if (moduleItem.connectionString) {
clipboardy.write(moduleItem.connectionString);
await vscode.env.clipboard.writeText(moduleItem.connectionString);
}
}

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

@ -4,7 +4,6 @@
"use strict";
import { IotHubClient } from "azure-arm-iothub";
import { ResourceManagementClient, ResourceModels, SubscriptionClient } from "azure-arm-resource";
import * as clipboardy from "clipboardy";
import * as vscode from "vscode";
import { IotHubDescription } from "../node_modules/azure-arm-iothub/lib/models";
import { AzureAccount } from "./azure-account.api";
@ -153,18 +152,18 @@ export class IoTHubResourceExplorer extends BaseExplorer {
}
}
public copyIoTHubConnectionString() {
public async copyIoTHubConnectionString() {
TelemetryClient.sendEvent("AZ.Copy.IotHubConnectionString");
const iotHubConnectionString = Utility.getConnectionStringWithId(Constants.IotHubConnectionStringKey);
if (iotHubConnectionString) {
clipboardy.write(iotHubConnectionString);
await vscode.env.clipboard.writeText(iotHubConnectionString);
}
}
public async copyDeviceConnectionString(deviceItem: DeviceItem) {
deviceItem = await Utility.getInputDevice(deviceItem, "AZ.Copy.DeviceConnectionString");
if (deviceItem && deviceItem.connectionString) {
clipboardy.write(deviceItem.connectionString);
await vscode.env.clipboard.writeText(deviceItem.connectionString);
}
}
@ -194,7 +193,7 @@ export class IoTHubResourceExplorer extends BaseExplorer {
}});
const sasToken = sasTokenFunction(connectionString, parseFloat(expiryInHours));
clipboardy.write(sasToken);
await vscode.env.clipboard.writeText(sasToken);
this._outputChannel.show();
this.outputLine("SASToken", `SAS token for [${target}] is generated and copied to clipboard:`);
this._outputChannel.appendLine(sasToken);

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

@ -7,9 +7,7 @@
'use strict';
const copyWebpackPlugin = require('copy-webpack-plugin');
const failOnErrorsPlugin = require('fail-on-errors-webpack-plugin');
const permissionsPlugin = require('webpack-permissions-plugin');
const terserWebpackPlugin = require('terser-webpack-plugin');
const path = require('path');
const webpack = require('webpack');
@ -22,10 +20,10 @@ const config = {
},
entry: './src/extension.ts', // the entry point of this extension, 📖 -> https://webpack.js.org/configuration/entry-context/
output: { // the bundle is stored in the 'dist' folder (check package.json), 📖 -> https://webpack.js.org/configuration/output/
path: path.resolve(__dirname, 'dist', 'scripts'), // the clipboardy package ships with binaries in the fallbacks folder and reference them with "../fallbacks/*"
path: path.resolve(__dirname, 'dist'),
filename: 'extension.js',
libraryTarget: "commonjs2",
devtoolModuleFilenameTemplate: "../../[resource-path]",
devtoolModuleFilenameTemplate: "../[resource-path]",
},
devtool: 'source-map',
externals: {
@ -61,10 +59,6 @@ const config = {
]
},
plugins: [
new copyWebpackPlugin([{
from: 'node_modules/clipboardy/fallbacks',
to: '../fallbacks' // copy clipboardy binaries to the parent folder of scripts
}]),
// Ignore all locale files of moment.js, which can save 50KB
// https://webpack.js.org/plugins/ignore-plugin/#ignore-moment-locales
new webpack.IgnorePlugin(/^\.\/locale$/, /[\/\\]moment$/),
@ -93,14 +87,6 @@ const config = {
new failOnErrorsPlugin({
failOnErrors: true,
failOnWarnings: true,
}),
new permissionsPlugin({
buildFiles: [
{
path: path.resolve(__dirname, 'dist', 'fallbacks', 'linux', 'xsel'), // chmod +x dist/fallbacks/linux/xsel
fileMode: '775'
}
]
})
],
optimization: {