diff --git a/lib/PowerShell/Constants.js b/lib/PowerShell/Constants.js index 49ab99a7..e47bba72 100644 --- a/lib/PowerShell/Constants.js +++ b/lib/PowerShell/Constants.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); class Constants { } -exports.Constants = Constants; +exports.default = Constants; Constants.prefix = "az_"; Constants.moduleName = "Az.Accounts"; Constants.versionPattern = /[0-9]\.[0-9]\.[0-9]/; diff --git a/lib/PowerShell/ServicePrincipalLogin.js b/lib/PowerShell/ServicePrincipalLogin.js index ef4e60e6..9dadd9e3 100644 --- a/lib/PowerShell/ServicePrincipalLogin.js +++ b/lib/PowerShell/ServicePrincipalLogin.js @@ -23,7 +23,7 @@ const core = __importStar(require("@actions/core")); const Utils_1 = __importDefault(require("./Utilities/Utils")); const PowerShellToolRunner_1 = __importDefault(require("./Utilities/PowerShellToolRunner")); const ScriptBuilder_1 = __importDefault(require("./Utilities/ScriptBuilder")); -const Constants_1 = require("./Constants"); +const Constants_1 = __importDefault(require("./Constants")); class ServicePrincipalLogin { constructor(servicePrincipalId, servicePrincipalKey, tenantId, subscriptionId) { this.servicePrincipalId = servicePrincipalId; @@ -34,14 +34,14 @@ class ServicePrincipalLogin { initialize() { return __awaiter(this, void 0, void 0, function* () { Utils_1.default.setPSModulePath(); - const azLatestVersion = yield Utils_1.default.getLatestModule(Constants_1.Constants.moduleName); + const azLatestVersion = yield Utils_1.default.getLatestModule(Constants_1.default.moduleName); core.debug(`Az Module version used: ${azLatestVersion}`); - Utils_1.default.setPSModulePath(`${Constants_1.Constants.prefix}${azLatestVersion}`); + Utils_1.default.setPSModulePath(`${Constants_1.default.prefix}${azLatestVersion}`); }); } login() { return __awaiter(this, void 0, void 0, function* () { - PowerShellToolRunner_1.default.init(); + yield PowerShellToolRunner_1.default.init(); const scriptBuilder = new ScriptBuilder_1.default(); const script = scriptBuilder.getScript(ServicePrincipalLogin.scheme, this.tenantId, this.servicePrincipalId, this.servicePrincipalKey, this.subscriptionId, ServicePrincipalLogin.environment, ServicePrincipalLogin.scopeLevel); PowerShellToolRunner_1.default.executePowerShellCommand(script); @@ -49,6 +49,6 @@ class ServicePrincipalLogin { } } exports.ServicePrincipalLogin = ServicePrincipalLogin; -ServicePrincipalLogin.environment = Constants_1.Constants.environment; -ServicePrincipalLogin.scopeLevel = Constants_1.Constants.scopeLevel; -ServicePrincipalLogin.scheme = Constants_1.Constants.scheme; +ServicePrincipalLogin.environment = Constants_1.default.environment; +ServicePrincipalLogin.scopeLevel = Constants_1.default.scopeLevel; +ServicePrincipalLogin.scheme = Constants_1.default.scheme; diff --git a/lib/PowerShell/Utilities/Utils.js b/lib/PowerShell/Utilities/Utils.js index d23b998e..70dba97b 100644 --- a/lib/PowerShell/Utilities/Utils.js +++ b/lib/PowerShell/Utilities/Utils.js @@ -20,7 +20,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { }; Object.defineProperty(exports, "__esModule", { value: true }); const os = __importStar(require("os")); -const Constants_1 = require("../Constants"); +const Constants_1 = __importDefault(require("../Constants")); const PowerShellToolRunner_1 = __importDefault(require("./PowerShellToolRunner")); class Utils { static getLatestModule(moduleName) { @@ -37,7 +37,7 @@ class Utils { } } }; - PowerShellToolRunner_1.default.init(); + yield PowerShellToolRunner_1.default.init(); yield PowerShellToolRunner_1.default.executePowerShellCommand(`(Get-Module -Name ${moduleName} -ListAvailable | Sort-Object Version -Descending | Select-Object -First 1).Version.ToString()`, options); if (!Utils.isValidVersion(output.trim())) { return ""; @@ -46,7 +46,7 @@ class Utils { }); } static isValidVersion(version) { - return !!version.match(Constants_1.Constants.versionPattern); + return !!version.match(Constants_1.default.versionPattern); } static setPSModulePath(azPSVersion = "") { let modulePath = ""; diff --git a/src/PowerShell/Constants.ts b/src/PowerShell/Constants.ts index f8f6036a..2e85a96e 100644 --- a/src/PowerShell/Constants.ts +++ b/src/PowerShell/Constants.ts @@ -1,4 +1,4 @@ -export class Constants { +export default class Constants { static readonly prefix: string = "az_"; static readonly moduleName: string = "Az.Accounts"; static readonly versionPattern = /[0-9]\.[0-9]\.[0-9]/; diff --git a/src/PowerShell/ServicePrincipalLogin.ts b/src/PowerShell/ServicePrincipalLogin.ts index 5b291c0a..7760e97c 100644 --- a/src/PowerShell/ServicePrincipalLogin.ts +++ b/src/PowerShell/ServicePrincipalLogin.ts @@ -3,7 +3,7 @@ import * as core from '@actions/core'; import Utils from './Utilities/Utils'; import PowerShellToolRunner from './Utilities/PowerShellToolRunner'; import ScriptBuilder from './Utilities/ScriptBuilder'; -import { Constants } from './Constants'; +import Constants from './Constants'; export class ServicePrincipalLogin implements IAzurePowerShellSession { static readonly environment: string = Constants.environment; @@ -29,7 +29,7 @@ export class ServicePrincipalLogin implements IAzurePowerShellSession { } async login() { - PowerShellToolRunner.init(); + await PowerShellToolRunner.init(); const scriptBuilder: ScriptBuilder = new ScriptBuilder(); const script: string = scriptBuilder.getScript(ServicePrincipalLogin.scheme, this.tenantId, this.servicePrincipalId, this.servicePrincipalKey, this.subscriptionId, ServicePrincipalLogin.environment, ServicePrincipalLogin.scopeLevel); diff --git a/src/PowerShell/Utilities/Utils.ts b/src/PowerShell/Utilities/Utils.ts index a3e62590..9d0efca3 100644 --- a/src/PowerShell/Utilities/Utils.ts +++ b/src/PowerShell/Utilities/Utils.ts @@ -2,7 +2,7 @@ import * as os from 'os'; import * as exec from '@actions/exec'; import * as io from '@actions/io'; -import { Constants } from '../Constants'; +import Constants from '../Constants'; import PowerShellToolRunner from './PowerShellToolRunner'; export default class Utils { @@ -19,7 +19,7 @@ export default class Utils { } } }; - PowerShellToolRunner.init(); + await PowerShellToolRunner.init(); await PowerShellToolRunner.executePowerShellCommand(`(Get-Module -Name ${moduleName} -ListAvailable | Sort-Object Version -Descending | Select-Object -First 1).Version.ToString()`, options); if(!Utils.isValidVersion(output.trim())) { return "";