initial commit
This commit is contained in:
Родитель
d1470c246c
Коммит
83322ae85f
|
@ -0,0 +1,5 @@
|
|||
# Change Log
|
||||
All notable changes to the "vscode-azurelogin" extension will be documented in this file.
|
||||
|
||||
## [0.0.1]
|
||||
- Initial release
|
36
LICENSE
36
LICENSE
|
@ -1,21 +1,23 @@
|
|||
MIT License
|
||||
Visual Studio Code Extension for Azure Login
|
||||
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
MIT License
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE
|
64
README.md
64
README.md
|
@ -1,14 +1,50 @@
|
|||
|
||||
# Contributing
|
||||
|
||||
This project welcomes contributions and suggestions. Most contributions require you to agree to a
|
||||
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
|
||||
the rights to use your contribution. For details, visit https://cla.microsoft.com.
|
||||
|
||||
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide
|
||||
a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions
|
||||
provided by the bot. You will only need to do this once across all repos using our CLA.
|
||||
|
||||
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
|
||||
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
|
||||
contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
|
||||
# Azure Login README
|
||||
|
||||
## Features
|
||||
|
||||
### Login
|
||||
|
||||
Calling the login method will result in an "authentication code" being automatically copied to the clipboard, and a browser being launched, which allows you to interactively authenticate with Azure. Once the login is complete, an Azure "service principal" is auto-created and persisted to disk, so that subsequent calls to login won't require re-authenticating. This allows your own apps to behave similarly to tools such as the Az CLI, without too much effort.
|
||||
|
||||
If you'd like to specify an exact Azure identity you can set the following environment variables (or [extension settings](Extension Settings)), which provide interop with other Azure management tools such as Serverless and Terraform:
|
||||
|
||||
* `azureSubId` / `ARM_SUBSRIPTION_ID`: The ID of the Azure subscription that you'd like to manage resources within
|
||||
* `azureServicePrincipalClientId` / `ARM_CLIENT_ID`: The name of the service principal
|
||||
* `azureServicePrincipalPassword` / `ARM_CLIENT_SECRET`: The password of the service principal
|
||||
* `azureServicePrincipalTenantId` / `ARM_TENANT_ID`: The ID of the tenant that the service principal was created in
|
||||
|
||||
### Logout
|
||||
|
||||
### Show Subscriptions
|
||||
|
||||
### Use Subscription
|
||||
|
||||
## Requirements
|
||||
|
||||
## Extension Settings
|
||||
|
||||
This extension contributes the following settings:
|
||||
|
||||
* `azureLogin.azureSubId`: The ID of the Azure subscription that you'd like to manage resources within
|
||||
* `azureLogin.azureServicePrincipalClientId`: The name of the service principal
|
||||
* `azureLogin.azureServicePrincipalPassword`: The password of the service principal
|
||||
* `azureLogin.azureServicePrincipalTenantId`: The ID of the tenant that the service principal
|
||||
|
||||
## Known Issues
|
||||
|
||||
## Contributing
|
||||
|
||||
This project welcomes contributions and suggestions. Most contributions require you to agree to a
|
||||
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
|
||||
the rights to use your contribution. For details, visit https://cla.microsoft.com.
|
||||
|
||||
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide
|
||||
a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions
|
||||
provided by the bot. You will only need to do this once across all repos using our CLA.
|
||||
|
||||
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
|
||||
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
|
||||
contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
|
||||
|
||||
## License
|
||||
[MIT](LICENSE)
|
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 434 B |
|
@ -0,0 +1,64 @@
|
|||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const telemetry_1 = require("./telemetry");
|
||||
const vscode = require("vscode");
|
||||
const { azLogin, azLogout } = require("az-login");
|
||||
const teleCmdId = '';
|
||||
function login() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let teleCmdId = 'vscode-azurelogin.login';
|
||||
const signInMessage = 'The code {0} has been copied to your clipboard. Click Login and paste in the code to authenticate.';
|
||||
const { credentials } = yield azLogin({ interactiveLoginHandler: (code, message) => {
|
||||
vscode.window.showInformationMessage(message);
|
||||
} });
|
||||
if (telemetry_1.reporter) {
|
||||
telemetry_1.reporter.sendTelemetryEvent('command', {
|
||||
command: teleCmdId
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
exports.login = login;
|
||||
function logout() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let teleCmdId = 'vscode-azurelogin.logout';
|
||||
yield azLogout();
|
||||
if (telemetry_1.reporter) {
|
||||
telemetry_1.reporter.sendTelemetryEvent('command', {
|
||||
command: teleCmdId
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
exports.logout = logout;
|
||||
function showSubscriptions() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let teleCmdId = 'vscode-azurelogin.showSubscriptions';
|
||||
if (telemetry_1.reporter) {
|
||||
telemetry_1.reporter.sendTelemetryEvent('command', {
|
||||
command: teleCmdId
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
exports.showSubscriptions = showSubscriptions;
|
||||
function useSubscription(sub) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let teleCmdId = 'vscode-azurelogin.useSubscription';
|
||||
if (telemetry_1.reporter) {
|
||||
telemetry_1.reporter.sendTelemetryEvent('command', {
|
||||
command: teleCmdId
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
exports.useSubscription = useSubscription;
|
||||
//# sourceMappingURL=azurelogin.js.map
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"azurelogin.js","sourceRoot":"","sources":["../../src/azurelogin.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAuC;AACvC,iCAAiC;AACjC,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAElD,MAAM,SAAS,GAAW,EAAE,CAAC;AAE7B;;QACI,IAAI,SAAS,GAAG,yBAAyB,CAAC;QAC1C,MAAM,aAAa,GAAG,oGAAoG,CAAC;QAE3H,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,OAAO,CAAC,EAAE,uBAAuB,EAAE,CAAC,IAAI,EAAE,OAAO;gBAC3E,MAAM,CAAC,MAAM,CAAC,sBAAsB,CAAC,OAAO,CAAC,CAAC;YAClD,CAAC,EAAC,CAAC,CAAC;QAEJ,EAAE,CAAC,CAAC,oBAAQ,CAAC,CAAC,CAAC;YACX,oBAAQ,CAAC,kBAAkB,CAAC,SAAS,EAAE;gBACnC,OAAO,EAAE,SAAS;aACrB,CAAC,CAAC;QACP,CAAC;IACL,CAAC;CAAA;AAbD,sBAaC;AAED;;QACI,IAAI,SAAS,GAAG,0BAA0B,CAAC;QAE3C,MAAM,QAAQ,EAAE,CAAC;QAEjB,EAAE,CAAC,CAAC,oBAAQ,CAAC,CAAC,CAAC;YACX,oBAAQ,CAAC,kBAAkB,CAAC,SAAS,EAAE;gBACnC,OAAO,EAAE,SAAS;aACrB,CAAC,CAAC;QACP,CAAC;IACL,CAAC;CAAA;AAVD,wBAUC;AACD;;QACI,IAAI,SAAS,GAAG,qCAAqC,CAAC;QAEtD,EAAE,CAAC,CAAC,oBAAQ,CAAC,CAAC,CAAC;YACX,oBAAQ,CAAC,kBAAkB,CAAC,SAAS,EAAE;gBACnC,OAAO,EAAE,SAAS;aACrB,CAAC,CAAC;QACP,CAAC;IACL,CAAC;CAAA;AARD,8CAQC;AACD,yBAAsC,GAAW;;QAC7C,IAAI,SAAS,GAAG,mCAAmC,CAAC;QAEpD,EAAE,CAAC,CAAC,oBAAQ,CAAC,CAAC,CAAC;YACX,oBAAQ,CAAC,kBAAkB,CAAC,SAAS,EAAE;gBACnC,OAAO,EAAE,SAAS;aACrB,CAAC,CAAC;QACP,CAAC;IACL,CAAC;CAAA;AARD,0CAQC"}
|
|
@ -0,0 +1,18 @@
|
|||
'use strict';
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const vscode = require("vscode");
|
||||
const azurelogin_1 = require("./azurelogin");
|
||||
const telemetry_1 = require("./telemetry");
|
||||
;
|
||||
function activate(context) {
|
||||
context.subscriptions.push(new telemetry_1.Reporter(context));
|
||||
context.subscriptions.push(vscode.commands.registerCommand('vscode-azurelogin.login', azurelogin_1.login));
|
||||
context.subscriptions.push(vscode.commands.registerCommand('vscode-azurelogin.logout', azurelogin_1.logout));
|
||||
context.subscriptions.push(vscode.commands.registerCommand('vscode-azurelogin.showSubscriptions', azurelogin_1.showSubscriptions));
|
||||
context.subscriptions.push(vscode.commands.registerCommand('vscode-azurelogin.useSubscription', azurelogin_1.useSubscription));
|
||||
}
|
||||
exports.activate = activate;
|
||||
function deactivate() {
|
||||
}
|
||||
exports.deactivate = deactivate;
|
||||
//# sourceMappingURL=extension.js.map
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"extension.js","sourceRoot":"","sources":["../../src/extension.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,iCAAiC;AACjC,6CAAiF;AACjF,2CAAuC;AAOtC,CAAC;AAEF,kBAAyB,OAAgC;IACrD,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,oBAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;IAElD,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAC,yBAAyB,EAAE,kBAAK,CAAC,CAAC,CAAC;IAC9F,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAC,0BAA0B,EAAE,mBAAM,CAAC,CAAC,CAAC;IAChG,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAC,qCAAqC,EAAE,8BAAiB,CAAC,CAAC,CAAC;IACtH,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAC,mCAAmC,EAAE,4BAAe,CAAC,CAAC,CAAC;AACtH,CAAC;AAPD,4BAOC;AAED;AACA,CAAC;AADD,gCACC"}
|
|
@ -0,0 +1,24 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const vscode_extension_telemetry_1 = require("vscode-extension-telemetry");
|
||||
const vscode = require("vscode");
|
||||
class Reporter extends vscode.Disposable {
|
||||
constructor(ctx) {
|
||||
super(() => exports.reporter.dispose());
|
||||
let packageInfo = getPackageInfo(ctx);
|
||||
exports.reporter = packageInfo && new vscode_extension_telemetry_1.default(packageInfo.name, packageInfo.version, packageInfo.aiKey);
|
||||
}
|
||||
}
|
||||
exports.Reporter = Reporter;
|
||||
function getPackageInfo(context) {
|
||||
let extensionPackage = require(context.asAbsolutePath('./package.json'));
|
||||
if (extensionPackage) {
|
||||
return {
|
||||
name: extensionPackage.name,
|
||||
version: extensionPackage.version,
|
||||
aiKey: extensionPackage.aiKey
|
||||
};
|
||||
}
|
||||
return;
|
||||
}
|
||||
//# sourceMappingURL=telemetry.js.map
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"telemetry.js","sourceRoot":"","sources":["../../src/telemetry.ts"],"names":[],"mappings":";;AAAA,2EAA2D;AAC3D,iCAAkC;AAIlC,cAAsB,SAAQ,MAAM,CAAC,UAAU;IAE3C,YAAY,GAA4B;QAEpC,KAAK,CAAC,MAAM,gBAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;QAEhC,IAAI,WAAW,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC;QACtC,gBAAQ,GAAG,WAAW,IAAI,IAAI,oCAAiB,CAAC,WAAW,CAAC,IAAI,EAAE,WAAW,CAAC,OAAO,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC;IAE9G,CAAC;CACJ;AAVD,4BAUC;AAQD,wBAAwB,OAAgC;IACpD,IAAI,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,gBAAgB,CAAC,CAAC,CAAC;IACzE,EAAE,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC;QACnB,MAAM,CAAC;YACH,IAAI,EAAE,gBAAgB,CAAC,IAAI;YAC3B,OAAO,EAAE,gBAAgB,CAAC,OAAO;YACjC,KAAK,EAAE,gBAAgB,CAAC,KAAK;SAChC,CAAC;IACN,CAAC;IACD,MAAM,CAAC;AACX,CAAC"}
|
|
@ -0,0 +1,17 @@
|
|||
"use strict";
|
||||
//
|
||||
// Note: This example test is leveraging the Mocha test framework.
|
||||
// Please refer to their documentation on https://mochajs.org/ for help.
|
||||
//
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
// The module 'assert' provides assertion methods from node
|
||||
const assert = require("assert");
|
||||
// Defines a Mocha test suite to group tests of similar kind together
|
||||
suite("Extension Tests", () => {
|
||||
// Defines a Mocha unit test
|
||||
test("Something 1", () => {
|
||||
assert.equal(-1, [1, 2, 3].indexOf(5));
|
||||
assert.equal(-1, [1, 2, 3].indexOf(0));
|
||||
});
|
||||
});
|
||||
//# sourceMappingURL=extension.test.js.map
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"extension.test.js","sourceRoot":"","sources":["../../test/extension.test.ts"],"names":[],"mappings":";AAAA,EAAE;AACF,kEAAkE;AAClE,wEAAwE;AACxE,EAAE;;AAEF,2DAA2D;AAC3D,iCAAiC;AAOjC,qEAAqE;AACrE,KAAK,CAAC,iBAAiB,EAAE;IAErB,4BAA4B;IAC5B,IAAI,CAAC,aAAa,EAAE;QAChB,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;QACvC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3C,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@ -0,0 +1,20 @@
|
|||
//
|
||||
// PLEASE DO NOT MODIFY / DELETE UNLESS YOU KNOW WHAT YOU ARE DOING
|
||||
//
|
||||
// This file is providing the test runner to use when running extension tests.
|
||||
// By default the test runner in use is Mocha based.
|
||||
//
|
||||
// You can provide your own test runner if you want to override it by exporting
|
||||
// a function run(testRoot: string, clb: (error:Error) => void) that the extension
|
||||
// host can call to run the tests. The test runner is expected to use console.log
|
||||
// to report the results back to the caller. When the tests are finished, return
|
||||
// a possible error to the callback or null if none.
|
||||
var testRunner = require('vscode/lib/testrunner');
|
||||
// You can directly control Mocha options by uncommenting the following lines
|
||||
// See https://github.com/mochajs/mocha/wiki/Using-mocha-programmatically#set-options for more info
|
||||
testRunner.configure({
|
||||
ui: 'tdd',
|
||||
useColors: true // colored output from test results
|
||||
});
|
||||
module.exports = testRunner;
|
||||
//# sourceMappingURL=index.js.map
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../test/index.ts"],"names":[],"mappings":"AAAA,EAAE;AACF,mEAAmE;AACnE,EAAE;AACF,8EAA8E;AAC9E,oDAAoD;AACpD,EAAE;AACF,+EAA+E;AAC/E,kFAAkF;AAClF,iFAAiF;AACjF,gFAAgF;AAChF,oDAAoD;AAEpD,IAAI,UAAU,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;AAElD,6EAA6E;AAC7E,mGAAmG;AACnG,UAAU,CAAC,SAAS,CAAC;IACjB,EAAE,EAAE,KAAK;IACT,SAAS,EAAE,IAAI,CAAC,mCAAmC;CACtD,CAAC,CAAC;AAEH,MAAM,CAAC,OAAO,GAAG,UAAU,CAAC"}
|
|
@ -0,0 +1,101 @@
|
|||
{
|
||||
"name": "vscode-azurelogin",
|
||||
"displayName": "Azure Login",
|
||||
"description": "A common Login and Subscription management extension for VS Code.",
|
||||
"license": "SEE LICENSE IN LICENSE",
|
||||
"icon": "images/azurelogin.png",
|
||||
"repository": {
|
||||
"url": "https://github.com/microsoft/vscode-azurelogin.git"
|
||||
},
|
||||
"homepage": "https://github.com/Microsoft/vscode-azurelogin/blob/master/README.md",
|
||||
"galleryBanner": {
|
||||
"color": "#1289B9",
|
||||
"theme": "dark"
|
||||
},
|
||||
"aiKey": "AIF-d9b70cd4-b9f9-4d70-929b-a071c400b217",
|
||||
"version": "0.0.1",
|
||||
"publisher": "chrisdias",
|
||||
"engines": {
|
||||
"vscode": "^1.13.0"
|
||||
},
|
||||
"categories": [
|
||||
"Other"
|
||||
],
|
||||
"keywords": [
|
||||
"azure"
|
||||
],
|
||||
"activationEvents": [
|
||||
"onCommand:vscode-azurelogin.login",
|
||||
"onCommand:vscode-azurelogin.logout",
|
||||
"onCommand:vscode-azurelogin.showSubscriptions",
|
||||
"onCommand:vscode-azurelogin.useSubscription"
|
||||
],
|
||||
"main": "./out/src/extension",
|
||||
"contributes": {
|
||||
"commands": [
|
||||
{
|
||||
"command": "vscode-azurelogin.login",
|
||||
"title": "Login",
|
||||
"category": "Azure"
|
||||
},
|
||||
{
|
||||
"command": "vscode-azurelogin.logout",
|
||||
"title": "Logout",
|
||||
"category": "Azure"
|
||||
},
|
||||
{
|
||||
"command": "vscode-azurelogin.showSubcriptions",
|
||||
"title": "Subscriptions",
|
||||
"category": "Azure"
|
||||
},
|
||||
{
|
||||
"command": "vscode-azurelogin.useSubscription",
|
||||
"title": "Use Subscription",
|
||||
"category": "Azure"
|
||||
}
|
||||
]
|
||||
},
|
||||
"configuration": {
|
||||
"type": "object",
|
||||
"title": "Azure Login Configuration Options",
|
||||
"properties": {
|
||||
"azureLogin.azureSubId": {
|
||||
"type": "string",
|
||||
"default": "",
|
||||
"description": "The ID of the Azure subscription that you'd like to manage resources within."
|
||||
},
|
||||
"azureLogin.azureServicePrincipalClientId": {
|
||||
"type": "string",
|
||||
"default": "",
|
||||
"description": "The name of the service principal."
|
||||
},
|
||||
"azureLogin.azureServicePrincipalPassword": {
|
||||
"type": "string",
|
||||
"default": "",
|
||||
"description": "The password of the service principal."
|
||||
},
|
||||
"azureLogin.azureServicePrincipalTenantId": {
|
||||
"type": "string",
|
||||
"default": "",
|
||||
"description": "The ID of the tenant that the service principal."
|
||||
}
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"vscode:prepublish": "tsc -p ./",
|
||||
"compile": "tsc -watch -p ./",
|
||||
"postinstall": "node ./node_modules/vscode/bin/install",
|
||||
"test": "node ./node_modules/vscode/bin/test"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^2.0.3",
|
||||
"vscode": "^1.0.0",
|
||||
"mocha": "^2.3.3",
|
||||
"@types/node": "^6.0.40",
|
||||
"@types/mocha": "^2.2.32",
|
||||
"vscode-extension-telemetry": "^0.0.6"
|
||||
},
|
||||
"dependencies": {
|
||||
"az-login": "^0.3.0"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
import { reporter } from './telemetry';
|
||||
import * as vscode from "vscode";
|
||||
const { azLogin, azLogout } = require("az-login");
|
||||
|
||||
const teleCmdId: string = '';
|
||||
|
||||
export async function login() {
|
||||
let teleCmdId = 'vscode-azurelogin.login';
|
||||
const signInMessage = 'The code {0} has been copied to your clipboard. Click Login and paste in the code to authenticate.';
|
||||
|
||||
const { credentials } = await azLogin({ interactiveLoginHandler: (code, message) => {
|
||||
vscode.window.showInformationMessage(message);
|
||||
}});
|
||||
|
||||
if (reporter) {
|
||||
reporter.sendTelemetryEvent('command', {
|
||||
command: teleCmdId
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export async function logout() {
|
||||
let teleCmdId = 'vscode-azurelogin.logout';
|
||||
|
||||
await azLogout();
|
||||
|
||||
if (reporter) {
|
||||
reporter.sendTelemetryEvent('command', {
|
||||
command: teleCmdId
|
||||
});
|
||||
}
|
||||
}
|
||||
export async function showSubscriptions() {
|
||||
let teleCmdId = 'vscode-azurelogin.showSubscriptions';
|
||||
|
||||
if (reporter) {
|
||||
reporter.sendTelemetryEvent('command', {
|
||||
command: teleCmdId
|
||||
});
|
||||
}
|
||||
}
|
||||
export async function useSubscription(sub: string) {
|
||||
let teleCmdId = 'vscode-azurelogin.useSubscription';
|
||||
|
||||
if (reporter) {
|
||||
reporter.sendTelemetryEvent('command', {
|
||||
command: teleCmdId
|
||||
});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
'use strict';
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
import { login, logout, showSubscriptions, useSubscription } from './azurelogin';
|
||||
import { Reporter } from './telemetry';
|
||||
|
||||
export type KeyInfo = { [keyName: string]: string; };
|
||||
export interface ComposeVersionKeys {
|
||||
All: KeyInfo,
|
||||
v1: KeyInfo,
|
||||
v2: KeyInfo
|
||||
};
|
||||
|
||||
export function activate(context: vscode.ExtensionContext) {
|
||||
context.subscriptions.push(new Reporter(context));
|
||||
|
||||
context.subscriptions.push(vscode.commands.registerCommand('vscode-azurelogin.login', login));
|
||||
context.subscriptions.push(vscode.commands.registerCommand('vscode-azurelogin.logout', logout));
|
||||
context.subscriptions.push(vscode.commands.registerCommand('vscode-azurelogin.showSubscriptions', showSubscriptions));
|
||||
context.subscriptions.push(vscode.commands.registerCommand('vscode-azurelogin.useSubscription', useSubscription));
|
||||
}
|
||||
|
||||
export function deactivate() {
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
import TelemetryReporter from 'vscode-extension-telemetry';
|
||||
import vscode = require('vscode');
|
||||
|
||||
export var reporter: TelemetryReporter;
|
||||
|
||||
export class Reporter extends vscode.Disposable {
|
||||
|
||||
constructor(ctx: vscode.ExtensionContext) {
|
||||
|
||||
super(() => reporter.dispose());
|
||||
|
||||
let packageInfo = getPackageInfo(ctx);
|
||||
reporter = packageInfo && new TelemetryReporter(packageInfo.name, packageInfo.version, packageInfo.aiKey);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
interface IPackageInfo {
|
||||
name: string;
|
||||
version: string;
|
||||
aiKey: string;
|
||||
}
|
||||
|
||||
function getPackageInfo(context: vscode.ExtensionContext): IPackageInfo {
|
||||
let extensionPackage = require(context.asAbsolutePath('./package.json'));
|
||||
if (extensionPackage) {
|
||||
return {
|
||||
name: extensionPackage.name,
|
||||
version: extensionPackage.version,
|
||||
aiKey: extensionPackage.aiKey
|
||||
};
|
||||
}
|
||||
return;
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
//
|
||||
// Note: This example test is leveraging the Mocha test framework.
|
||||
// Please refer to their documentation on https://mochajs.org/ for help.
|
||||
//
|
||||
|
||||
// The module 'assert' provides assertion methods from node
|
||||
import * as assert from 'assert';
|
||||
|
||||
// You can import and use all API from the 'vscode' module
|
||||
// as well as import your extension to test it
|
||||
import * as vscode from 'vscode';
|
||||
import * as myExtension from '../src/extension';
|
||||
|
||||
// Defines a Mocha test suite to group tests of similar kind together
|
||||
suite("Extension Tests", () => {
|
||||
|
||||
// Defines a Mocha unit test
|
||||
test("Something 1", () => {
|
||||
assert.equal(-1, [1, 2, 3].indexOf(5));
|
||||
assert.equal(-1, [1, 2, 3].indexOf(0));
|
||||
});
|
||||
});
|
|
@ -0,0 +1,22 @@
|
|||
//
|
||||
// PLEASE DO NOT MODIFY / DELETE UNLESS YOU KNOW WHAT YOU ARE DOING
|
||||
//
|
||||
// This file is providing the test runner to use when running extension tests.
|
||||
// By default the test runner in use is Mocha based.
|
||||
//
|
||||
// You can provide your own test runner if you want to override it by exporting
|
||||
// a function run(testRoot: string, clb: (error:Error) => void) that the extension
|
||||
// host can call to run the tests. The test runner is expected to use console.log
|
||||
// to report the results back to the caller. When the tests are finished, return
|
||||
// a possible error to the callback or null if none.
|
||||
|
||||
var testRunner = require('vscode/lib/testrunner');
|
||||
|
||||
// You can directly control Mocha options by uncommenting the following lines
|
||||
// See https://github.com/mochajs/mocha/wiki/Using-mocha-programmatically#set-options for more info
|
||||
testRunner.configure({
|
||||
ui: 'tdd', // the TDD UI is being used in extension.test.ts (suite, test, etc.)
|
||||
useColors: true // colored output from test results
|
||||
});
|
||||
|
||||
module.exports = testRunner;
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"outDir": "out",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"sourceMap": true,
|
||||
"rootDir": "."
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
".vscode-test"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
# Welcome to your first VS Code Extension
|
||||
|
||||
## What's in the folder
|
||||
* This folder contains all of the files necessary for your extension
|
||||
* `package.json` - this is the manifest file in which you declare your extension and command.
|
||||
The sample plugin registers a command and defines its title and command name. With this information
|
||||
VS Code can show the command in the command palette. It doesn’t yet need to load the plugin.
|
||||
* `src/extension.ts` - this is the main file where you will provide the implementation of your command.
|
||||
The file exports one function, `activate`, which is called the very first time your extension is
|
||||
activated (in this case by executing the command). Inside the `activate` function we call `registerCommand`.
|
||||
We pass the function containing the implementation of the command as the second parameter to
|
||||
`registerCommand`.
|
||||
|
||||
## Get up and running straight away
|
||||
* press `F5` to open a new window with your extension loaded
|
||||
* run your command from the command palette by pressing (`Ctrl+Shift+P` or `Cmd+Shift+P` on Mac) and typing `Hello World`
|
||||
* set breakpoints in your code inside `src/extension.ts` to debug your extension
|
||||
* find output from your extension in the debug console
|
||||
|
||||
## Make changes
|
||||
* you can relaunch the extension from the debug toolbar after changing code in `src/extension.ts`
|
||||
* you can also reload (`Ctrl+R` or `Cmd+R` on Mac) the VS Code window with your extension to load your changes
|
||||
|
||||
## Explore the API
|
||||
* you can open the full set of our API when you open the file `node_modules/vscode/vscode.d.ts`
|
||||
|
||||
## Run tests
|
||||
* open the debug viewlet (`Ctrl+Shift+D` or `Cmd+Shift+D` on Mac) and from the launch configuration dropdown pick `Launch Tests`
|
||||
* press `F5` to run the tests in a new window with your extension loaded
|
||||
* see the output of the test result in the debug console
|
||||
* make changes to `test/extension.test.ts` or create new test files inside the `test` folder
|
||||
* by convention, the test runner will only consider files matching the name pattern `**.test.ts`
|
||||
* you can create folders inside the `test` folder to structure your tests any way you want
|
Загрузка…
Ссылка в новой задаче