-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathinteractive.ts
More file actions
42 lines (39 loc) · 1.21 KB
/
interactive.ts
File metadata and controls
42 lines (39 loc) · 1.21 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
import { cliux, validatePath } from '@contentstack/cli-utilities';
import * as path from 'path';
import first from 'lodash/first';
import split from 'lodash/split';
export const askContentDir = async (): Promise<string> => {
let result = await cliux.inquire<string>({
type: 'input',
message: 'Enter the path for the content',
name: 'dir',
validate: validatePath,
});
result = result.replace(/["']/g, '');
return path.resolve(result);
};
export const askSelectedModules = async (): Promise<string> => {
return cliux.inquire<string>({
type: 'list',
name: 'selectedModule',
message: 'Please select a module to generate the mapper files.',
choices: [
{ name: 'Global Fields', value: 'global-fields' },
{ name: 'Content types', value: 'content-types' },
{ name: 'Entries', value: 'entries' },
],
});
};
export const askAPIKey = async (): Promise<string> => {
return cliux.inquire<string>({
type: 'input',
message: 'Enter the stack api key',
name: 'apiKey',
validate: (input: string) => {
if (!input || !input.trim()) {
return 'Stack API key cannot be empty. Please enter a valid stack API key.';
}
return true;
},
});
};