UNPKG

@pnp/cli-microsoft365

Version:

Manage Microsoft 365 and SharePoint Framework projects on any platform

55 lines 2.75 kB
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); }; var _AppOpenCommand_instances, _AppOpenCommand_initTelemetry, _AppOpenCommand_initOptions; import { cli } from '../../../cli/cli.js'; import { settingsNames } from '../../../settingsNames.js'; import { browserUtil } from '../../../utils/browserUtil.js'; import AppCommand from '../../base/AppCommand.js'; import commands from '../commands.js'; class AppOpenCommand extends AppCommand { get name() { return commands.OPEN; } get description() { return 'Opens Microsoft Entra app in the Microsoft Entra ID portal'; } constructor() { super(); _AppOpenCommand_instances.add(this); __classPrivateFieldGet(this, _AppOpenCommand_instances, "m", _AppOpenCommand_initTelemetry).call(this); __classPrivateFieldGet(this, _AppOpenCommand_instances, "m", _AppOpenCommand_initOptions).call(this); } async commandAction(logger, args) { try { await this.logOrOpenUrl(args, logger); } catch (err) { this.handleRejectedODataJsonPromise(err); } } async logOrOpenUrl(args, logger) { const previewPrefix = args.options.preview === true ? "preview." : ""; const url = `https://${previewPrefix}portal.azure.com/#blade/Microsoft_AAD_RegisteredApps/ApplicationMenuBlade/Overview/appId/${this.appId}/isMSAApp/`; if (cli.getSettingWithDefaultValue(settingsNames.autoOpenLinksInBrowser, false) === false) { await logger.log(`Use a web browser to open the page ${url}`); return; } await logger.log(`Opening the following page in your browser: ${url}`); await browserUtil.open(url); } } _AppOpenCommand_instances = new WeakSet(), _AppOpenCommand_initTelemetry = function _AppOpenCommand_initTelemetry() { this.telemetry.push((args) => { Object.assign(this.telemetryProperties, { appId: typeof args.options.appId !== 'undefined', preview: typeof args.options.preview !== 'undefined' }); }); }, _AppOpenCommand_initOptions = function _AppOpenCommand_initOptions() { this.options.unshift({ option: '--appId [appId]' }, { option: '--preview' }); }; export default new AppOpenCommand(); //# sourceMappingURL=app-open.js.map