create-blocklet 0.9.13 → 0.9.14

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
@@ -1,29 +1,30 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import ejs from 'ejs';
3
+ import { isValid, toTypeInfo, types } from '@arcblock/did';
4
4
  import boxen from 'boxen';
5
- import { fileURLToPath } from 'url';
6
5
  import { execSync } from 'child_process';
7
- import { cd, argv, fs, YAML, chalk, path } from 'zx';
6
+ import ejs from 'ejs';
7
+ import * as envfile from 'envfile';
8
8
  import ora from 'ora';
9
9
  import prompts from 'prompts';
10
- import { isValid, toTypeInfo, types } from '@arcblock/did';
11
- import * as envfile from 'envfile';
10
+ import { fileURLToPath } from 'url';
11
+ import { argv, cd, chalk, fs, path, YAML } from 'zx';
12
12
 
13
13
  import { echoBrand, echoDocument } from './lib/arcblock.js';
14
- import { getUser } from './lib/index.js';
15
- import { checkServerInstalled, checkServerRunning, checkSatisfiedVersion, getServerDirectory } from './lib/server.js';
16
14
  import { getBlockletDidList } from './lib/did.js';
17
15
  import { initGitRepo } from './lib/git.js';
16
+ import { getUser } from './lib/index.js';
17
+ import { checkSatisfiedVersion, checkServerInstalled, checkServerRunning, getServerDirectory } from './lib/server.js';
18
18
  import {
19
+ checkLerna,
20
+ checkYarn,
19
21
  copy,
20
22
  emptyDir,
23
+ fuzzyQuery,
21
24
  isEmpty,
25
+ isValidName,
22
26
  isValidPackageName,
23
27
  toValidPackageName,
24
- fuzzyQuery,
25
- checkLerna,
26
- checkYarn,
27
28
  } from './lib/utils.js';
28
29
 
29
30
  const { yellow, red, green, cyan, blue, bold } = chalk;
@@ -247,18 +248,21 @@ async function init() {
247
248
 
248
249
  let result = {};
249
250
  const authorInfo = await getUser();
251
+ const transferName = toValidPackageName(defaultProjectName);
250
252
 
251
253
  try {
252
254
  result = await prompts(
253
255
  [
254
256
  {
255
- type: targetDir && !['.', './'].includes(targetDir) ? null : 'text',
257
+ type: isValidName(defaultProjectName) && targetDir && !['.', './'].includes(targetDir) ? null : 'text',
256
258
  name: 'projectName',
257
259
  message: 'Project name:',
258
- initial: defaultProjectName,
260
+ initial: transferName,
259
261
  onState: (state) => {
260
- projectName = state.value.trim() || defaultProjectName;
262
+ projectName = state.value.trim() || transferName;
261
263
  },
264
+ validate: (value) =>
265
+ isValidName(value) ? true : 'Please enter a valid project name, only a~z, A~Z, 0~9, - and _ are allowed.',
262
266
  },
263
267
  {
264
268
  type: () => (!fs.existsSync(targetDir) || isEmpty(targetDir) ? null : 'confirm'),
package/lib/utils.js CHANGED
@@ -11,6 +11,10 @@ export function copy(src, dest) {
11
11
  }
12
12
  }
13
13
 
14
+ export function isValidName(name) {
15
+ return /^[a-zA-Z0-9][-a-zA-Z0-9_]{2,128}$/.test(name);
16
+ }
17
+
14
18
  export function isValidPackageName(projectName) {
15
19
  return /^(?:@[a-z0-9-*~][a-z0-9-*._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/.test(projectName);
16
20
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-blocklet",
3
- "version": "0.9.13",
3
+ "version": "0.9.14",
4
4
  "exports": "./index.js",
5
5
  "type": "module",
6
6
  "repository": "git@github.com:blocklet/create-blocklet.git",
@@ -77,7 +77,7 @@
77
77
  "rimraf": "^5.0.10",
78
78
  "simple-git-hooks": "^2.11.1",
79
79
  "vite": "^5.4.8",
80
- "vite-plugin-blocklet": "^0.9.13",
80
+ "vite-plugin-blocklet": "^0.9.14",
81
81
  "vite-plugin-svgr": "^4.2.0",
82
82
  "zx": "^8.1.8"
83
83
  },
@@ -52,7 +52,7 @@
52
52
  "simple-git-hooks": "^2.11.1",
53
53
  "vite": "^5.4.8",
54
54
  "vite-node": "^2.1.1",
55
- "vite-plugin-blocklet": "^0.9.13",
55
+ "vite-plugin-blocklet": "^0.9.14",
56
56
  "vite-plugin-require": "^1.2.14",
57
57
  "vite-plugin-svgr": "^4.2.0",
58
58
  "zx": "^8.1.8"
@@ -71,7 +71,7 @@
71
71
  "rimraf": "^5.0.10",
72
72
  "simple-git-hooks": "^2.11.1",
73
73
  "vite": "^5.4.8",
74
- "vite-plugin-blocklet": "^0.9.13",
74
+ "vite-plugin-blocklet": "^0.9.14",
75
75
  "vite-plugin-svgr": "^4.2.0",
76
76
  "zx": "^8.1.8"
77
77
  },
@@ -81,7 +81,7 @@
81
81
  "ts-node": "^10.9.2",
82
82
  "typescript": "^5.6.2",
83
83
  "vite": "^5.4.8",
84
- "vite-plugin-blocklet": "^0.9.13",
84
+ "vite-plugin-blocklet": "^0.9.14",
85
85
  "vite-plugin-svgr": "^4.2.0",
86
86
  "zx": "^8.1.8"
87
87
  },
@@ -71,7 +71,7 @@
71
71
  "rimraf": "^5.0.10",
72
72
  "simple-git-hooks": "^2.11.1",
73
73
  "vite": "^5.4.8",
74
- "vite-plugin-blocklet": "^0.9.13",
74
+ "vite-plugin-blocklet": "^0.9.14",
75
75
  "vite-plugin-svgr": "^4.2.0",
76
76
  "zx": "^8.1.8"
77
77
  },
@@ -52,7 +52,7 @@
52
52
  "rimraf": "^5.0.10",
53
53
  "simple-git-hooks": "^2.11.1",
54
54
  "vite": "^5.4.8",
55
- "vite-plugin-blocklet": "^0.9.13",
55
+ "vite-plugin-blocklet": "^0.9.14",
56
56
  "vite-plugin-svgr": "^4.2.0",
57
57
  "zx": "^8.1.8"
58
58
  },
@@ -36,7 +36,7 @@
36
36
  "rimraf": "^5.0.10",
37
37
  "simple-git-hooks": "^2.11.1",
38
38
  "vite": "^5.4.8",
39
- "vite-plugin-blocklet": "^0.9.13",
39
+ "vite-plugin-blocklet": "^0.9.14",
40
40
  "vite-plugin-solid": "^2.10.2",
41
41
  "zx": "^8.1.8"
42
42
  },
@@ -32,7 +32,7 @@
32
32
  "simple-git-hooks": "^2.11.1",
33
33
  "solid-js": "^1.9.1",
34
34
  "vite": "^5.4.8",
35
- "vite-plugin-blocklet": "^0.9.13",
35
+ "vite-plugin-blocklet": "^0.9.14",
36
36
  "vite-plugin-solid": "^2.10.2",
37
37
  "zx": "^8.1.8"
38
38
  },
@@ -44,7 +44,7 @@
44
44
  "simple-git-hooks": "^2.11.1",
45
45
  "svelte": "^4.2.19",
46
46
  "vite": "^5.4.8",
47
- "vite-plugin-blocklet": "^0.9.13",
47
+ "vite-plugin-blocklet": "^0.9.14",
48
48
  "zx": "^8.1.8"
49
49
  },
50
50
  "lint-staged": {
@@ -25,7 +25,7 @@
25
25
  "simple-git-hooks": "^2.11.1",
26
26
  "svelte": "^4.2.19",
27
27
  "vite": "^5.4.8",
28
- "vite-plugin-blocklet": "^0.9.13",
28
+ "vite-plugin-blocklet": "^0.9.14",
29
29
  "zx": "^8.1.8"
30
30
  },
31
31
  "lint-staged": {
@@ -96,7 +96,7 @@
96
96
  "ts-node": "^10.9.2",
97
97
  "typescript": "^5.6.2",
98
98
  "vite": "^5.4.8",
99
- "vite-plugin-blocklet": "^0.9.13",
99
+ "vite-plugin-blocklet": "^0.9.14",
100
100
  "vite-plugin-svgr": "^4.2.0",
101
101
  "zx": "^8.1.8"
102
102
  },
@@ -49,7 +49,7 @@
49
49
  "rimraf": "^5.0.10",
50
50
  "simple-git-hooks": "^2.11.1",
51
51
  "vite": "^5.4.8",
52
- "vite-plugin-blocklet": "^0.9.13",
52
+ "vite-plugin-blocklet": "^0.9.14",
53
53
  "vue": "^3.5.10",
54
54
  "zx": "^8.1.8"
55
55
  },
@@ -30,7 +30,7 @@
30
30
  "rimraf": "^5.0.10",
31
31
  "simple-git-hooks": "^2.11.1",
32
32
  "vite": "^5.4.8",
33
- "vite-plugin-blocklet": "^0.9.13",
33
+ "vite-plugin-blocklet": "^0.9.14",
34
34
  "vue": "^3.5.10",
35
35
  "zx": "^8.1.8"
36
36
  },
@@ -39,7 +39,7 @@
39
39
  "taze": "^0.16.9",
40
40
  "typescript": "^5.6.2",
41
41
  "vite": "^5.4.8",
42
- "vite-plugin-blocklet": "^0.9.13",
42
+ "vite-plugin-blocklet": "^0.9.14",
43
43
  "vue-tsc": "^2.1.6",
44
44
  "zx": "^8.1.8"
45
45
  },
@@ -48,7 +48,7 @@
48
48
  "rimraf": "^5.0.10",
49
49
  "simple-git-hooks": "^2.11.1",
50
50
  "vite": "^5.4.8",
51
- "vite-plugin-blocklet": "^0.9.13",
51
+ "vite-plugin-blocklet": "^0.9.14",
52
52
  "vue": "^2.7.16",
53
53
  "zx": "^8.1.8"
54
54
  },
@@ -30,7 +30,7 @@
30
30
  "rimraf": "^5.0.10",
31
31
  "simple-git-hooks": "^2.11.1",
32
32
  "vite": "^5.4.8",
33
- "vite-plugin-blocklet": "^0.9.13",
33
+ "vite-plugin-blocklet": "^0.9.14",
34
34
  "vue": "^2.7.16",
35
35
  "zx": "^8.1.8"
36
36
  },