create-blocklet 0.4.56 → 0.4.58
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +36 -29
- package/package.json +1 -1
- package/templates/solidjs-dapp/package.json +1 -1
- package/templates/solidjs-static/package.json +1 -1
- package/templates/svelte-dapp/package.json +1 -1
- package/templates/svelte-static/package.json +1 -1
- package/templates/vue-dapp/package.json +1 -1
- package/templates/vue-static/package.json +1 -1
package/index.js
CHANGED
|
@@ -127,6 +127,11 @@ async function init() {
|
|
|
127
127
|
await echoBrand({ version });
|
|
128
128
|
|
|
129
129
|
let targetDir = argv._[0] ? String(argv._[0]) : undefined;
|
|
130
|
+
let inputTemplateName = argv._[1] ? String(argv._[1]) : undefined;
|
|
131
|
+
if (inputTemplateName && !templates.find(item => item.name === inputTemplateName)) {
|
|
132
|
+
console.error(`${red('✖')} The template ${inputTemplateName} is invalid.`);
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
130
135
|
|
|
131
136
|
const defaultProjectName = !targetDir ? 'blocklet-project' : targetDir;
|
|
132
137
|
|
|
@@ -169,38 +174,40 @@ async function init() {
|
|
|
169
174
|
initial: () => toValidPackageName(targetDir),
|
|
170
175
|
validate: (dir) => isValidPackageName(dir) || 'Invalid package.json name',
|
|
171
176
|
},
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
title: templateColor(template.display),
|
|
180
|
-
value: template.name,
|
|
181
|
-
};
|
|
182
|
-
}),
|
|
183
|
-
min: 1,
|
|
184
|
-
suggest: (input, choices) => Promise.resolve(choices.filter((i) => i.title.includes(input))),
|
|
185
|
-
},
|
|
186
|
-
// 这里需要添加一步 如果选择了 多项 就要提示用户设置主应用
|
|
187
|
-
{
|
|
188
|
-
type: (templateNames = []) => {
|
|
189
|
-
return templateNames.length > 1 ? 'select' : null;
|
|
190
|
-
},
|
|
191
|
-
name: 'mainBlocklet',
|
|
192
|
-
message: 'Please choose the main blocklet',
|
|
193
|
-
//
|
|
194
|
-
choices: (templateNames = []) =>
|
|
195
|
-
templateNames.map((templateName) => {
|
|
196
|
-
const template = templates.find((x) => x.name === templateName);
|
|
177
|
+
...(inputTemplateName ? [] : [
|
|
178
|
+
{
|
|
179
|
+
type: 'autocompleteMultiselect',
|
|
180
|
+
name: 'templateNames',
|
|
181
|
+
message: 'Choose one or more blocklet templates:',
|
|
182
|
+
choices: templates.map((template) => {
|
|
183
|
+
const templateColor = template.color;
|
|
197
184
|
return {
|
|
198
|
-
title: template.display,
|
|
185
|
+
title: templateColor(template.display),
|
|
199
186
|
value: template.name,
|
|
200
187
|
};
|
|
201
188
|
}),
|
|
202
|
-
|
|
203
|
-
|
|
189
|
+
min: 1,
|
|
190
|
+
suggest: (input, choices) => Promise.resolve(choices.filter((i) => i.title.includes(input))),
|
|
191
|
+
},
|
|
192
|
+
// 这里需要添加一步 如果选择了 多项 就要提示用户设置主应用
|
|
193
|
+
{
|
|
194
|
+
type: (templateNames = []) => {
|
|
195
|
+
return templateNames.length > 1 ? 'select' : null;
|
|
196
|
+
},
|
|
197
|
+
name: 'mainBlocklet',
|
|
198
|
+
message: 'Please choose the main blocklet',
|
|
199
|
+
//
|
|
200
|
+
choices: (templateNames = []) =>
|
|
201
|
+
templateNames.map((templateName) => {
|
|
202
|
+
const template = templates.find((x) => x.name === templateName);
|
|
203
|
+
return {
|
|
204
|
+
title: template.display,
|
|
205
|
+
value: template.name,
|
|
206
|
+
};
|
|
207
|
+
}),
|
|
208
|
+
initial: 1,
|
|
209
|
+
},
|
|
210
|
+
]),
|
|
204
211
|
{
|
|
205
212
|
type: 'text',
|
|
206
213
|
name: 'authorName',
|
|
@@ -228,7 +235,7 @@ async function init() {
|
|
|
228
235
|
}
|
|
229
236
|
|
|
230
237
|
// user choice associated with prompts
|
|
231
|
-
const { mainBlocklet = null, templateNames = [], overwrite, packageName, authorName, authorEmail } = result;
|
|
238
|
+
const { mainBlocklet = null, templateNames = inputTemplateName ? [inputTemplateName] : [], overwrite, packageName, authorName, authorEmail } = result;
|
|
232
239
|
|
|
233
240
|
await echoDocument();
|
|
234
241
|
|
package/package.json
CHANGED