@@ -24,11 +24,11 @@ if (!isWindows) {
24
24
* Unlike `getKeys`, this method returns preset names formatted
25
25
* for display and includes modes like '(Deliver)' or '(Compute)'.
26
26
* Each type corresponds to a folder in the 'presets' directory.
27
- * @returns {string[] } The list of presets with modes like '(Deliver)' or '(Compute)' if applicable .
27
+ * @returns {string[] } The list of presets.
28
28
* @example
29
29
* const presetsList = getBeautify();
30
30
* console.log(presetsList);
31
- * // Output might be: ['Angular (Deliver) ', 'React (Compute) ', 'Vue (Deliver) ']
31
+ * // Output might be: ['Angular', 'React', 'Vue']
32
32
*/
33
33
function getBeautify ( ) {
34
34
const presets = [ ] ;
@@ -37,25 +37,9 @@ function getBeautify() {
37
37
const folders = fs
38
38
. readdirSync ( presetsDir , { withFileTypes : true } )
39
39
. filter ( ( dirent ) => dirent . isDirectory ( ) )
40
- . flatMap ( ( dirent ) => {
40
+ . map ( ( dirent ) => {
41
41
const presetName = dirent . name ;
42
- const subDirs = fs
43
- . readdirSync ( path . join ( presetsDir , presetName ) , {
44
- withFileTypes : true ,
45
- } )
46
- . filter ( ( subDirent ) => subDirent . isDirectory ( ) ) ;
47
-
48
- if ( subDirs . length === 0 ) {
49
- return [ presetName . charAt ( 0 ) . toUpperCase ( ) + presetName . slice ( 1 ) ] ;
50
- }
51
-
52
- return subDirs . map ( ( subDir ) => {
53
- const subDirName =
54
- subDir . name . charAt ( 0 ) . toUpperCase ( ) + subDir . name . slice ( 1 ) ;
55
- return `${
56
- presetName . charAt ( 0 ) . toUpperCase ( ) + presetName . slice ( 1 )
57
- } (${ subDirName } )`;
58
- } ) ;
42
+ return presetName . charAt ( 0 ) . toUpperCase ( ) + presetName . slice ( 1 ) ;
59
43
} ) ;
60
44
61
45
presets . push ( ...folders ) ;
@@ -111,37 +95,6 @@ function set(name) {
111
95
fs . writeFileSync ( path . join ( presetPath , 'prebuild.js' ) , '' ) ;
112
96
fs . writeFileSync ( path . join ( presetPath , 'config.js' ) , '' ) ;
113
97
}
114
-
115
- /**
116
- * @function
117
- * @memberof Utils
118
- * @description Retrieves an array of available modes for a given preset.
119
- * Each sub-folder name in these directories is considered as a valid mode for the preset.
120
- * @param {string } presetName - The name of the preset for which modes are to be retrieved.
121
- * @returns {string[] } An array of available modes for the given preset.
122
- * @example
123
- * const availableModes = getModes('angular');
124
- * console.log(availableModes);
125
- * // Output might be: ['Deliver']
126
- * @throws {Error } Throws an error if unable to read the directory.
127
- */
128
- function getModes ( presetName ) {
129
- const modes = [ ] ;
130
-
131
- const presetPath = path . join ( baselibPath , 'presets' , presetName ) ;
132
-
133
- if ( fs . existsSync ( presetPath ) ) {
134
- const directories = fs
135
- . readdirSync ( presetPath , { withFileTypes : true } )
136
- . filter ( ( dir ) => dir . isDirectory ( ) )
137
- . map ( ( dir ) => dir . name . charAt ( 0 ) . toUpperCase ( ) + dir . name . slice ( 1 ) ) ;
138
-
139
- modes . push ( ...directories ) ;
140
- }
141
-
142
- return modes ;
143
- }
144
-
145
98
/**
146
99
* @function
147
100
* @memberof Utils
@@ -150,8 +103,6 @@ function getModes(presetName) {
150
103
* These keys are raw and do not include any modes or formatting.
151
104
* @property {Function } getBeautify - Function to retrieve a list of presets in a beautified format.
152
105
* Unlike `getKeys`, the names are formatted and include modes like '(Compute)' or '(Deliver)'.
153
- * @property {Function } getModes - Function to retrieve an array of a
154
- * vailable modes for a given preset.
155
106
* @property {Function } set - Function to create a new preset along with its required files.
156
107
* @example
157
108
* import { presets } from '#utils';
@@ -162,16 +113,13 @@ function getModes(presetName) {
162
113
* // Get beautified preset names
163
114
* const beautifiedNames = presets.getBeautify();
164
115
*
165
- * // Get available modes for a preset
166
- * const availableModes = presets.getModes('angular');
167
116
*
168
117
* // Create a new preset
169
118
* presets.set('MyNewPreset');
170
119
*/
171
120
const presets = {
172
121
getKeys,
173
122
getBeautify,
174
- getModes,
175
123
set,
176
124
} ;
177
125
0 commit comments