push neon reactor
This commit is contained in:
+92
@@ -0,0 +1,92 @@
|
||||
/*!
|
||||
* Copyright (C) Microsoft Corporation. All rights reserved.
|
||||
*/
|
||||
import * as prompts from '@clack/prompts';
|
||||
import { isCancel } from '@clack/prompts';
|
||||
import { printWarning } from './Utils/ConsoleOutput.js';
|
||||
/**
|
||||
* Prompts the user for text input. Exits the process if the user cancels.
|
||||
*/
|
||||
export async function promptText(options) {
|
||||
const result = await prompts.text(options);
|
||||
if (isCancel(result)) {
|
||||
printWarning('Operation cancelled by user.');
|
||||
process.exit(0);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* Prompts the user for confirmation. Exits the process if the user cancels.
|
||||
*/
|
||||
export async function promptConfirm(options) {
|
||||
const result = await prompts.confirm(options);
|
||||
if (isCancel(result)) {
|
||||
printWarning('Operation cancelled by user.');
|
||||
process.exit(0);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
export function createDefaultStringOption(options) {
|
||||
const { flags, env, message, initialValue, description, default: defaultValue } = options;
|
||||
return {
|
||||
flags,
|
||||
env,
|
||||
description,
|
||||
default: defaultValue,
|
||||
customPrompt: async () => {
|
||||
return await promptText({ message, initialValue });
|
||||
},
|
||||
};
|
||||
}
|
||||
export function isGuid(value) {
|
||||
const guidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
||||
return guidRegex.test(value);
|
||||
}
|
||||
export function createPlayUrl(region, environmentId, appId, localAppUrl, localConnectionsUrl) {
|
||||
const baseUrl = _getBaseUrl(region);
|
||||
const playUrl = `${baseUrl}/play/e/${environmentId}/app/${appId}`;
|
||||
const queryParams = [];
|
||||
if (localAppUrl) {
|
||||
queryParams.push(`_localAppUrl=${localAppUrl}`);
|
||||
}
|
||||
if (localConnectionsUrl) {
|
||||
queryParams.push(`_localConnectionUrl=${localConnectionsUrl}`);
|
||||
}
|
||||
return queryParams.length > 0 ? `${playUrl}?${queryParams.join('&')}` : playUrl;
|
||||
}
|
||||
export function getAuthority(region, tenantId) {
|
||||
switch (region) {
|
||||
case 'gcchigh':
|
||||
case 'dod':
|
||||
return `https://login.microsoftonline.us/${tenantId || 'organizations'}`;
|
||||
case 'mooncake':
|
||||
return `https://login.partner.microsoftonline.cn/${tenantId || 'organizations'}`;
|
||||
default:
|
||||
return `https://login.microsoftonline.com/${tenantId || 'organizations'}`;
|
||||
}
|
||||
}
|
||||
function _getBaseUrl(region) {
|
||||
switch (region) {
|
||||
case 'dev':
|
||||
return 'https://apps.dev.powerapps.com';
|
||||
case 'test':
|
||||
return 'https://apps.test.powerapps.com';
|
||||
case 'preprod':
|
||||
return 'https://apps.preprod.powerapps.com';
|
||||
case 'preview':
|
||||
return 'https://apps.preview.powerapps.com';
|
||||
case 'prod':
|
||||
return 'https://apps.powerapps.com';
|
||||
case 'gccmoderate':
|
||||
return 'https://apps.gov.powerapps.us';
|
||||
case 'gcchigh':
|
||||
return 'https://apps.high.powerapps.us';
|
||||
case 'dod':
|
||||
return 'https://play.apps.appsplatform.us';
|
||||
case 'mooncake':
|
||||
return 'https://apps.powerapps.cn';
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=CliUtils.js.map
|
||||
Reference in New Issue
Block a user