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 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
- type: 'autocompleteMultiselect',
174
- name: 'templateNames',
175
- message: 'Choose one or more blocklet templates:',
176
- choices: templates.map((template) => {
177
- const templateColor = template.color;
178
- return {
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
- initial: 1,
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-blocklet",
3
- "version": "0.4.56",
3
+ "version": "0.4.58",
4
4
  "exports": "./index.js",
5
5
  "type": "module",
6
6
  "repository": "git@github.com:blocklet/create-blocklet.git",
@@ -32,7 +32,7 @@
32
32
  "npm-run-all": "^4.1.5",
33
33
  "prettier": "^2.7.1",
34
34
  "vite": "^3.1.3",
35
- "vite-plugin-blocklet": "^0.4.56",
35
+ "vite-plugin-blocklet": "^0.4.58",
36
36
  "vite-plugin-html": "^3.2.0",
37
37
  "vite-plugin-solid": "^2.3.8"
38
38
  },
@@ -26,7 +26,7 @@
26
26
  "lint-staged": "^12.5.0",
27
27
  "prettier": "^2.7.1",
28
28
  "vite": "^3.1.3",
29
- "vite-plugin-blocklet": "^0.4.56",
29
+ "vite-plugin-blocklet": "^0.4.58",
30
30
  "vite-plugin-html": "^3.2.0",
31
31
  "vite-plugin-solid": "^2.3.8"
32
32
  },
@@ -46,7 +46,7 @@
46
46
  "prettier": "^2.7.1",
47
47
  "svelte": "^3.50.1",
48
48
  "vite": "^3.1.3",
49
- "vite-plugin-blocklet": "^0.4.56",
49
+ "vite-plugin-blocklet": "^0.4.58",
50
50
  "vite-plugin-html": "^3.2.0"
51
51
  },
52
52
  "lint-staged": {
@@ -27,7 +27,7 @@
27
27
  "prettier": "^2.7.1",
28
28
  "svelte": "^3.50.1",
29
29
  "vite": "^3.1.3",
30
- "vite-plugin-blocklet": "^0.4.56",
30
+ "vite-plugin-blocklet": "^0.4.58",
31
31
  "vite-plugin-html": "^3.2.0"
32
32
  },
33
33
  "lint-staged": {
@@ -49,7 +49,7 @@
49
49
  "npm-run-all": "^4.1.5",
50
50
  "prettier": "^2.7.1",
51
51
  "vite": "^3.1.3",
52
- "vite-plugin-blocklet": "^0.4.56"
52
+ "vite-plugin-blocklet": "^0.4.58"
53
53
  },
54
54
  "lint-staged": {
55
55
  "*.{mjs,js,vue}": [
@@ -28,7 +28,7 @@
28
28
  "lint-staged": "^12.5.0",
29
29
  "prettier": "^2.7.1",
30
30
  "vite": "^3.1.3",
31
- "vite-plugin-blocklet": "^0.4.56",
31
+ "vite-plugin-blocklet": "^0.4.58",
32
32
  "vite-plugin-html": "^3.2.0"
33
33
  },
34
34
  "lint-staged": {