You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 30, 2021. It is now read-only.
"This is a mandatory field, please answer. Enter "+
146
+
chalk.cyan("latest")+
147
+
" if you want to import the latest version."
148
+
);// Warn user if no input is entered
112
149
}
113
150
},
114
151
{
@@ -134,15 +171,101 @@ module.exports = class extends Generator {
134
171
returnfalse;// Don't show this prompt if user says that package description is incorrect
135
172
},
136
173
validate: asyncfunction(props){
137
-
varres=awaitexecuteCommand(
138
-
"mkdir dist && cd dist && curl -O "+props,
139
-
"downloadURL"
140
-
);// Import the build file in dist directory from npm
141
-
returnres;
142
-
/**
143
-
* Returns true if command execution is successful and proceeds to commonPrompts
144
-
* returns and logs the error if execution fails
145
-
*/
174
+
if(props){
175
+
if(props==="skip"){
176
+
returntrue;
177
+
}
178
+
179
+
varres=awaitexecuteCommand(
180
+
"mkdir component-dist && cd component-dist && curl -O "+props,
181
+
"downloadURL"
182
+
)
183
+
.then(()=>{
184
+
returntrue;
185
+
})
186
+
.catch(asyncerr=>{
187
+
if(err.code===1){
188
+
returnchalk.red(
189
+
`Sorry, there already seems to be a directory with the same name ${chalk.cyan(
190
+
"(component-dist)"
191
+
)}, please change it's name or move it.\n If you want to just copy this file into that directory, enter ${chalk.cyan(
192
+
"skip"
193
+
)}.\n`
194
+
);
195
+
}
196
+
197
+
if(err.code===3||err.code===23){
198
+
returnchalk.red(
199
+
"The URL is malformed. Please ensure the URL is in correct format."
200
+
);
201
+
}
202
+
203
+
returnchalk.red(
204
+
"Oops! We encountered an error, please see the log below for more details.\n"+
205
+
err
206
+
);
207
+
});// Import the build file in component-dist directory from npm
208
+
returnres;
209
+
/**
210
+
* Returns true if command execution is successful and proceeds to commonPrompts
211
+
* returns and logs the error if execution fails
212
+
*/
213
+
}
214
+
215
+
returnchalk.red("This is a mandatory field, please answer.");
216
+
}
217
+
},
218
+
{
219
+
type: "input",
220
+
name: "downloadBuildFile",
221
+
message: function(answers){
222
+
return(
223
+
"This URL - "+
224
+
chalk.bold.yellow(
225
+
"https://www.jsdelivr.com/package/npm/"+
226
+
answers.packageName+
227
+
"?version="+
228
+
answers.version
229
+
)+
230
+
" contains the directory of the package, please find the build file (generally in the dist or build folder) and paste the link here, we will download it for you in the existing folder."
231
+
);
232
+
},
233
+
when: function(responses){
234
+
if(responses.downloadURL==="skip"){
235
+
returntrue;// Show this prompt if user says that package description is correct
236
+
}
237
+
238
+
returnfalse;// Don't show this prompt if user says that package description is incorrect
239
+
},
240
+
validate: asyncprops=>{
241
+
if(props){
242
+
varres=executeCommand(
243
+
"cd component-dist && curl -O "+props,
244
+
"downloadBuildFile"
245
+
)
246
+
.then(()=>{
247
+
returntrue;
248
+
})
249
+
.catch(asyncerr=>{
250
+
if(err.code===3||err.code===23){
251
+
returnchalk.red(
252
+
"The URL is malformed. Please ensure the URL is in correct format."
253
+
);
254
+
}
255
+
256
+
returnchalk.red(
257
+
"Oops! We encountered an error, please see the log below for more details.\n"+
258
+
err
259
+
);
260
+
});// Import the build file in component-dist directory locally from computer
261
+
returnres;
262
+
/**
263
+
* Returns true if command execution is successful and proceeds to commonPrompts
264
+
* returns and logs the error if execution fails
265
+
*/
266
+
}
267
+
268
+
returnchalk.red("This is a mandatory field, please answer.");
146
269
}
147
270
}
148
271
];
@@ -154,15 +277,79 @@ module.exports = class extends Generator {
154
277
name: "pathOfBuildFile",
155
278
message: "Please enter the path of the build file.",
156
279
validate: asyncprops=>{
157
-
varres=executeCommand(
158
-
"mkdir dist && cp "+props+" dist",
159
-
"local"
160
-
);// Import the build file in dist directory locally from computer
161
-
returnres;
162
-
/**
163
-
* Returns true if command execution is successful and proceeds to commonPrompts
0 commit comments