create-blocklet 0.3.2 → 0.3.3

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
@@ -182,12 +182,14 @@ async function init() {
182
182
  name: 'authorName',
183
183
  message: 'Author name:',
184
184
  initial: authorInfo?.name || '',
185
+ validate: (name) => (name ? true : 'Author name is required'),
185
186
  },
186
187
  {
187
188
  type: 'text',
188
189
  name: 'authorEmail',
189
190
  message: 'Author email:',
190
191
  initial: authorInfo?.email || '',
192
+ validate: (email) => (email ? true : 'Author email is required'),
191
193
  },
192
194
  ],
193
195
  {
package/lib/git.js CHANGED
@@ -19,7 +19,14 @@ export async function initGitRepo(root) {
19
19
  }
20
20
 
21
21
  export async function getUserInfo() {
22
- const { stdout: name } = await $`git config user.name`;
23
- const { stdout: email } = await $`git config user.email`;
24
- return { name: name.trim(), email: email.trim() };
22
+ try {
23
+ const { stdout: name } = await $`git config user.name`;
24
+ const { stdout: email } = await $`git config user.email`;
25
+ return { name: name.trim(), email: email.trim() };
26
+ } catch {
27
+ return {
28
+ name: '',
29
+ email: '',
30
+ };
31
+ }
25
32
  }
package/lib/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { $ } from 'zx';
2
2
  import { getAuthor } from './npm.js';
3
3
  import { getUserInfo } from './git.js';
4
+ import { getUserInfo as getServerUserInfo } from './server.js';
4
5
 
5
6
  $.verbose = false;
6
7
 
@@ -10,10 +11,9 @@ export async function getOutput(cmd) {
10
11
  }
11
12
 
12
13
  export async function getUser() {
13
- const npmAuthor = await getAuthor();
14
- const gitUser = await getUserInfo();
14
+ const [npmAuthor, gitUser, serverUser] = await Promise.all([getAuthor(), getUserInfo(), getServerUserInfo()]);
15
15
  return {
16
- name: npmAuthor.name || gitUser.name,
17
- email: npmAuthor.email || gitUser.email,
16
+ name: serverUser.name || npmAuthor.name || gitUser.name || '',
17
+ email: serverUser.email || npmAuthor.email || gitUser.email || '',
18
18
  };
19
19
  }
package/lib/npm.js CHANGED
@@ -4,8 +4,15 @@ import { $ } from 'zx';
4
4
  $.verbose = false;
5
5
 
6
6
  export async function getAuthor() {
7
- const { stdout: name } = await $`npm config get init.author.name`;
8
- const { stdout: email } = await $`npm config get init.author.email`;
7
+ try {
8
+ const { stdout: name } = await $`npm config get init.author.name`;
9
+ const { stdout: email } = await $`npm config get init.author.email`;
9
10
 
10
- return { name: name.trim(), email: email.trim() };
11
+ return { name: name.trim(), email: email.trim() };
12
+ } catch {
13
+ return {
14
+ name: '',
15
+ email: '',
16
+ };
17
+ }
11
18
  }
package/lib/server.js CHANGED
@@ -45,3 +45,19 @@ export async function getServerDirectory() {
45
45
  const directory = matchStr.replace(/Blocklet Server Data Directory:[\s]*([\S]+)\/\.abtnode\n/gm, '$1');
46
46
  return directory;
47
47
  }
48
+
49
+ export async function getUserInfo() {
50
+ try {
51
+ const { stdout: user } = await $`blocklet config get user`;
52
+ const { stdout: email } = await $`blocklet config get email`;
53
+ return {
54
+ user: user?.trim(),
55
+ email: email?.trim(),
56
+ };
57
+ } catch {
58
+ return {
59
+ user: '',
60
+ email: '',
61
+ };
62
+ }
63
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-blocklet",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
4
4
  "exports": "./index.js",
5
5
  "type": "module",
6
6
  "repository": "git@github.com:blocklet/create-blocklet.git",