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.
Copy file name to clipboardExpand all lines: generators/app/index.js
+39-24Lines changed: 39 additions & 24 deletions
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,19 @@ const yosay = require("yosay");
5
5
constvalidators=require("./validator");
6
6
7
7
module.exports=classextendsGenerator{
8
+
// Note: arguments and options should be defined in the constructor.
9
+
constructor(args,opts){
10
+
super(args,opts);
11
+
this.argument("projectDirectory",{
12
+
type: String,
13
+
required: false,
14
+
default: "web-component",
15
+
desc: `${chalk.blue(
16
+
"path of the project directory, if you enter the path of a directory which does not exist, the generator will make one for you, otherwise it will use the existing one."
@@ -43,7 +62,7 @@ module.exports = class extends Generator {
43
62
message:
44
63
"I need the build file (generally index.js, main.js or componentName.js) for this, import it using one of the options -",
45
64
choices: [
46
-
"Install component from npm package (Recommended - fastest way)",
65
+
"Install component from npm package. (Recommended - fastest way)",
47
66
"Tell us the path of the build file on your local machine and I will import it in the project.",
48
67
"Tell us the npm package name, version, build file URL and I will download the build file."
49
68
],
@@ -68,7 +87,7 @@ module.exports = class extends Generator {
68
87
name: "changeImportSourceFromNpmPackage",
69
88
message: "What do you want to do?",
70
89
choices: [
71
-
"Enter package name again to install component from npm package.",
90
+
"Enter package name again to install component from npm package. (Recommended - fastest way)",
72
91
"Import the file locally from your computer.",
73
92
"Enter package name, version, build file URL to download the build file."
74
93
],
@@ -115,7 +134,7 @@ module.exports = class extends Generator {
115
134
name: "changeImportSourceFromNpmBuildFile",
116
135
message: "What do you want to do?",
117
136
choices: [
118
-
"Enter package name again to install component from npm package.",
137
+
"Enter package name again to install component from npm package. (Recommended - fastest way)",
119
138
"Import the file locally from your computer.",
120
139
"Enter package name, version, build file URL to download the build file."
121
140
],
@@ -148,6 +167,13 @@ module.exports = class extends Generator {
148
167
message:
149
168
"The build file will be imported in a separate directory in the project's root. Enter the name of this directory or press Enter if you like to go with default.",
150
169
validate: validators.directoryName,
170
+
when: function(responses){
171
+
if(responses.confirmPackageName){
172
+
returntrue;// Show this prompt if user says that package description is correct
173
+
}
174
+
175
+
returnfalse;// Don't show this prompt if user says that package description is incorrect
176
+
},
151
177
default: "component-dist"
152
178
},
153
179
{
@@ -181,9 +207,8 @@ module.exports = class extends Generator {
181
207
{
182
208
type: "input",
183
209
name: "directoryName",
184
-
message: `The build file will be imported in a separate directory in the project's root. Enter the name of this directory or press Enter if you like to go with default ${chalk.cyan(
185
-
"component-dist"
186
-
)}.`,
210
+
message:
211
+
"The build file will be imported in a separate directory in the project's root. Enter the name of this directory or press Enter if you like to go with default.",
187
212
validate: validators.directoryName,
188
213
default: "component-dist"
189
214
},
@@ -236,7 +261,6 @@ module.exports = class extends Generator {
236
261
);// Call the function recursively
237
262
}
238
263
239
-
// If user chooses to install component from npm after starting over
0 commit comments