|
1 |
| -import { LocationsSettings } from "./types"; |
| 1 | +import { LocationsSettings } from './types'; |
2 | 2 |
|
3 | 3 | export const selectLocationsPrompt = {
|
4 |
| - name: 'locations', |
5 |
| - message: `Select where your app can be rendered:`, |
6 |
| - type: 'checkbox', |
7 |
| - choices: [ |
8 |
| - { name: 'App configuration screen ', value: 'app-config' }, |
9 |
| - { name: 'Entry field', value: 'entry-field' }, |
10 |
| - { name: 'Entry sidebar', value: 'entry-sidebar' }, |
11 |
| - { name: 'Entry editor', value: 'entry-editor' }, |
12 |
| - { name: 'Page', value: 'page' }, |
13 |
| - { name: 'Home', value: 'home' }, |
14 |
| - ], |
15 |
| - } |
| 4 | + name: 'locations', |
| 5 | + message: `Select where your app can be rendered:`, |
| 6 | + type: 'checkbox', |
| 7 | + choices: [ |
| 8 | + { name: 'App configuration screen ', value: 'app-config' }, |
| 9 | + { name: 'Entry field', value: 'entry-field' }, |
| 10 | + { name: 'Entry sidebar', value: 'entry-sidebar' }, |
| 11 | + { name: 'Entry editor', value: 'entry-editor' }, |
| 12 | + { name: 'Page', value: 'page' }, |
| 13 | + { name: 'Home', value: 'home' }, |
| 14 | + ], |
| 15 | +}; |
16 | 16 |
|
17 | 17 | export const selectFieldsPrompt = {
|
18 |
| - name: 'fields', |
19 |
| - message: 'Select the field types the app can be rendered:', |
20 |
| - type: 'checkbox', |
21 |
| - choices: [ |
22 |
| - { name: 'Short text', value: { type: 'Symbol' } }, |
23 |
| - { name: 'Short text, list', value: { type: 'Array', items: { type: 'Symbol' } } }, |
24 |
| - { name: 'Long text', value: { type: 'Text' } }, |
25 |
| - { name: 'Rich text', value: { type: 'RichText' } }, |
26 |
| - { name: 'Number, integer', value: { type: 'Integer' } }, |
27 |
| - { name: 'Number, decimal', value: { type: 'Number' } }, |
28 |
| - { name: 'Date and time', value: { type: 'Date' } }, |
29 |
| - { name: 'Location', value: { type: 'Location' } }, |
30 |
| - { name: 'Boolean', value: { type: 'Boolean' } }, |
31 |
| - { name: 'JSON object', value: { type: 'Object' } }, |
32 |
| - { name: 'Entry reference', value: { type: 'Link', linkType: 'Entry' } }, |
33 |
| - { |
34 |
| - name: 'Entry reference, list', |
35 |
| - value: { |
36 |
| - type: 'Array', |
37 |
| - items: { |
38 |
| - type: 'Link', |
39 |
| - linkType: 'Entry', |
40 |
| - }, |
| 18 | + name: 'fields', |
| 19 | + message: 'Select the field types the app can be rendered:', |
| 20 | + type: 'checkbox', |
| 21 | + choices: [ |
| 22 | + { name: 'Short text', value: { type: 'Symbol' } }, |
| 23 | + { name: 'Short text, list', value: { type: 'Array', items: { type: 'Symbol' } } }, |
| 24 | + { name: 'Long text', value: { type: 'Text' } }, |
| 25 | + { name: 'Rich text', value: { type: 'RichText' } }, |
| 26 | + { name: 'Number, integer', value: { type: 'Integer' } }, |
| 27 | + { name: 'Number, decimal', value: { type: 'Number' } }, |
| 28 | + { name: 'Date and time', value: { type: 'Date' } }, |
| 29 | + { name: 'Location', value: { type: 'Location' } }, |
| 30 | + { name: 'Boolean', value: { type: 'Boolean' } }, |
| 31 | + { name: 'JSON object', value: { type: 'Object' } }, |
| 32 | + { name: 'Entry reference', value: { type: 'Link', linkType: 'Entry' } }, |
| 33 | + { |
| 34 | + name: 'Entry reference, list', |
| 35 | + value: { |
| 36 | + type: 'Array', |
| 37 | + items: { |
| 38 | + type: 'Link', |
| 39 | + linkType: 'Entry', |
41 | 40 | },
|
42 |
| - }, |
43 |
| - { name: 'Media reference', value: { type: 'Link', linkType: 'Asset' } }, |
44 |
| - { |
45 |
| - name: 'Media reference, list', |
46 |
| - value: { type: 'Array', items: { type: 'Link', linkType: 'Asset' } }, |
47 |
| - }, |
48 |
| - ], |
49 |
| - when(answers: LocationsSettings) { |
50 |
| - return answers.locations.includes('entry-field'); |
| 41 | + }, |
51 | 42 | },
|
52 |
| - // eslint-disable-next-line @typescript-eslint/no-explicit-any |
53 |
| - validate(input: any) { |
54 |
| - if (input.length < 1) { |
55 |
| - return 'You must choose at least one field type.'; |
56 |
| - } |
57 |
| - return true; |
| 43 | + { name: 'Media reference', value: { type: 'Link', linkType: 'Asset' } }, |
| 44 | + { |
| 45 | + name: 'Media reference, list', |
| 46 | + value: { type: 'Array', items: { type: 'Link', linkType: 'Asset' } }, |
58 | 47 | },
|
59 |
| -} |
| 48 | + ], |
| 49 | + when(answers: LocationsSettings) { |
| 50 | + return answers.locations.includes('entry-field'); |
| 51 | + }, |
| 52 | + // eslint-disable-next-line @typescript-eslint/no-explicit-any |
| 53 | + validate(input: any) { |
| 54 | + if (input.length < 1) { |
| 55 | + return 'You must choose at least one field type.'; |
| 56 | + } |
| 57 | + return true; |
| 58 | + }, |
| 59 | +}; |
60 | 60 |
|
61 | 61 | export const pageNavPrompt = {
|
62 |
| - name: 'pageNav', |
63 |
| - message: 'Page location: Would you like your page location to render in the main navigation?', |
64 |
| - type: 'confirm', |
65 |
| - default: false, |
66 |
| - when(answers: LocationsSettings) { |
67 |
| - return answers.locations.includes('page'); |
68 |
| - }, |
69 |
| - } |
| 62 | + name: 'pageNav', |
| 63 | + message: 'Page location: Would you like your page location to render in the main navigation?', |
| 64 | + type: 'confirm', |
| 65 | + default: false, |
| 66 | + when(answers: LocationsSettings) { |
| 67 | + return answers.locations.includes('page'); |
| 68 | + }, |
| 69 | +}; |
70 | 70 |
|
71 |
| - export const pageNavLinkNamePrompt = { |
72 |
| - name: 'pageNavLinkName', |
73 |
| - message: 'Page location: Provide a name for the link in the main navigation:', |
74 |
| - when(answers: LocationsSettings) { |
75 |
| - return answers.locations.includes('page') && answers.pageNav; |
76 |
| - }, |
77 |
| - // eslint-disable-next-line @typescript-eslint/no-explicit-any |
78 |
| - validate(input: any) { |
79 |
| - if (input.length < 1 || input.length > 40) { |
80 |
| - return 'Size must be at least 1 and at most 40'; |
81 |
| - } |
82 |
| - return true; |
83 |
| - }, |
84 |
| -} |
| 71 | +export const pageNavLinkNamePrompt = { |
| 72 | + name: 'pageNavLinkName', |
| 73 | + message: 'Page location: Provide a name for the link in the main navigation:', |
| 74 | + when(answers: LocationsSettings) { |
| 75 | + return answers.locations.includes('page') && answers.pageNav; |
| 76 | + }, |
| 77 | + // eslint-disable-next-line @typescript-eslint/no-explicit-any |
| 78 | + validate(input: any) { |
| 79 | + if (input.length < 1 || input.length > 40) { |
| 80 | + return 'Size must be at least 1 and at most 40'; |
| 81 | + } |
| 82 | + return true; |
| 83 | + }, |
| 84 | +}; |
85 | 85 |
|
86 | 86 | export const pageNavLinkPathPrompt = {
|
87 |
| - name: 'pageNavLinkPath', |
88 |
| - message: |
89 |
| - 'Page location: Provide a path which starts with / and does not contain empty space:', |
90 |
| - default: '/', |
91 |
| - when(answers: LocationsSettings) { |
92 |
| - return answers.locations.includes('page') && answers.pageNav; |
93 |
| - }, |
94 |
| - // eslint-disable-next-line @typescript-eslint/no-explicit-any |
95 |
| - validate(input: any) { |
96 |
| - if (input.length > 512) { |
97 |
| - return 'Maximum 512 characters'; |
98 |
| - } |
99 |
| - if (input.includes(' ')) { |
100 |
| - return 'Path cannot contain empty space'; |
101 |
| - } |
102 |
| - if (!input.startsWith('/')) { |
103 |
| - return 'Path must start with /'; |
104 |
| - } |
105 |
| - return true; |
106 |
| - }, |
107 |
| -} |
| 87 | + name: 'pageNavLinkPath', |
| 88 | + message: 'Page location: Provide a path which starts with / and does not contain empty space:', |
| 89 | + default: '/', |
| 90 | + when(answers: LocationsSettings) { |
| 91 | + return answers.locations.includes('page') && answers.pageNav; |
| 92 | + }, |
| 93 | + // eslint-disable-next-line @typescript-eslint/no-explicit-any |
| 94 | + validate(input: any) { |
| 95 | + if (input.length > 512) { |
| 96 | + return 'Maximum 512 characters'; |
| 97 | + } |
| 98 | + if (input.includes(' ')) { |
| 99 | + return 'Path cannot contain empty space'; |
| 100 | + } |
| 101 | + if (!input.startsWith('/')) { |
| 102 | + return 'Path must start with /'; |
| 103 | + } |
| 104 | + return true; |
| 105 | + }, |
| 106 | +}; |
0 commit comments