-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathinteractive.ts
More file actions
108 lines (95 loc) · 2.91 KB
/
interactive.ts
File metadata and controls
108 lines (95 loc) · 2.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import { cliux, messageHandler } from '@contentstack/cli-utilities';
export const askRegions = async (): Promise<string> => {
return cliux.inquire<string>({
type: 'list',
name: 'selectedRegion',
message: 'CLI_CONFIG_SELECT_REGION',
choices: [
{ name: 'NA', value: 'NA' },
{ name: 'EU', value: 'EU' },
{ name: 'AWS-NA', value: 'AWS-NA' },
{ name: 'AWS-EU', value: 'AWS-EU' },
{ name: 'AZURE-NA', value: 'AZURE-NA' },
{ name: 'AZURE-EU', value: 'AZURE-EU' },
{ name: 'GCP-NA', value: 'GCP-NA' },
{ name: 'GCP-EU', value: 'GCP-EU' },
{ name: 'Custom', value: 'custom' },
{ name: 'Exit', value: 'exit' },
],
});
};
export const askCustomRegion = async (): Promise<any> => {
const name = await cliux.inquire<string>({
type: 'input',
name: 'name',
message: 'CLI_CONFIG_INQUIRE_REGION_NAME',
});
const cma = await cliux.inquire<string>({
type: 'input',
name: 'cma',
message: 'CLI_CONFIG_INQUIRE_REGION_CMA',
});
const cda = await cliux.inquire<string>({
type: 'input',
name: 'cda',
message: 'CLI_CONFIG_INQUIRE_REGION_CDA',
});
const uiHost = await cliux.inquire<string>({
type: 'input',
name: 'ui-host',
message: 'CLI_CONFIG_INQUIRE_REGION_UI_HOST',
});
return { name, cma, cda, uiHost };
};
export async function askStackAPIKey(): Promise<string> {
return await cliux.inquire<string>({
type: 'input',
message: 'CLI_CONFIG_INQUIRE_API_KEY',
name: 'stack-api-key',
validate: inquireRequireFieldValidation,
});
}
export async function askBaseBranch(): Promise<string> {
return await cliux.inquire<string>({
type: 'input',
message: 'CLI_CONFIG_INQUIRE_BASE_BRANCH',
name: 'base-branch',
validate: inquireRequireFieldValidation,
});
}
export async function askConfirmation(): Promise<boolean> {
return await cliux.inquire<boolean>({
type: 'confirm',
message: 'Are you sure you want to remove this configuration ?',
name: 'config_remove_confirmation',
});
}
export function inquireRequireFieldValidation(input: string): string | boolean {
if (!input || input.trim() === '') {
return messageHandler.parse('CLI_BRANCH_REQUIRED_FIELD');
}
return true;
}
export async function askEarlyAccessHeaderValue(): Promise<string> {
return await cliux.inquire<string>({
type: 'input',
message: 'CLI_CONFIG_INQUIRE_EARLY_ACCESS_HEADER_VALUE',
name: 'header-value',
validate: inquireRequireFieldValidation,
});
}
export async function askEarlyAccessHeaderAlias(): Promise<string> {
return await cliux.inquire<string>({
type: 'input',
message: 'CLI_CONFIG_INQUIRE_EARLY_ACCESS_HEADER_ALIAS',
name: 'header-alias',
validate: inquireRequireFieldValidation,
});
}
export const askOrgID = async (): Promise<string> => {
return cliux.inquire<string>({
type: 'input',
message: 'Provide the organization UID',
name: 'org',
});
};