@initx-plugin/utils 0.0.10 → 0.0.12

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  <h1 align="center">init 🛠</h1>
2
2
 
3
- <p align="center"><code>initx</code> More convenient initialization tool</p>
3
+ <p align="center"><code>initx</code> More convenient initialization engine</p>
4
4
 
5
5
  <pre align="center">npx <b>initx &lt;something&gt;</b></pre>
6
6
 
package/dist/gpg.mjs CHANGED
@@ -1,40 +1,5 @@
1
- import { EOL } from 'node:os';
2
- import { c } from './index.mjs';
1
+ export { gpgList } from './index.mjs';
3
2
  import 'execa';
4
3
  import 'picocolors';
5
4
  import 'which';
6
-
7
- async function gpgList() {
8
- const result = await c("gpg", ["-k"]);
9
- const keys = [];
10
- const lines = result.stdout.split(EOL).filter((str) => str.trim() !== "");
11
- if (!lines || lines.length < 4) {
12
- return [];
13
- }
14
- const data = {
15
- key: "",
16
- name: "",
17
- email: ""
18
- };
19
- lines.forEach((line) => {
20
- const [, key] = /^\s+(\w{40})$/.exec(line) || [];
21
- if (key) {
22
- data.key = key;
23
- return;
24
- }
25
- if (line.startsWith("uid")) {
26
- const [, name, email] = /\s(\w+)\s<([\w-]+@[\w-]+(?:\.[\w-]+)+)>/.exec(line) || [];
27
- data.name = name;
28
- data.email = email;
29
- return;
30
- }
31
- if (line.startsWith("sub")) {
32
- keys.push({
33
- ...data
34
- });
35
- }
36
- });
37
- return keys;
38
- }
39
-
40
- export { gpgList };
5
+ import 'node:os';
package/dist/index.d.mts CHANGED
@@ -1,7 +1,8 @@
1
1
  import { Result } from 'execa';
2
2
  import which from 'which';
3
+ export { gpgList } from './gpg.mjs';
3
4
 
4
- declare function c(command: string, options?: string[]): Promise<Result>;
5
+ declare function c(command: string, options?: string[], execaOptions?: Record<string, any>): Promise<Result | Result<Record<string, any>>>;
5
6
 
6
7
  declare const log: {
7
8
  success: (msg: string) => void;
package/dist/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  import { Result } from 'execa';
2
2
  import which from 'which';
3
+ export { gpgList } from './gpg.js';
3
4
 
4
- declare function c(command: string, options?: string[]): Promise<Result>;
5
+ declare function c(command: string, options?: string[], execaOptions?: Record<string, any>): Promise<Result | Result<Record<string, any>>>;
5
6
 
6
7
  declare const log: {
7
8
  success: (msg: string) => void;
package/dist/index.mjs CHANGED
@@ -1,6 +1,7 @@
1
1
  import { execa } from 'execa';
2
2
  import c$1 from 'picocolors';
3
3
  import which from 'which';
4
+ import { EOL } from 'node:os';
4
5
 
5
6
  const log = {
6
7
  success: (msg) => console.log(`${c$1.bgGreen(c$1.black(" SUCCESS "))} ${msg}`),
@@ -11,10 +12,10 @@ const log = {
11
12
 
12
13
  const where = which.sync;
13
14
 
14
- async function c(command, options) {
15
+ async function c(command, options, execaOptions = {}) {
15
16
  try {
16
17
  where(command);
17
- return await execa(command, options);
18
+ return await execa(command, options, execaOptions);
18
19
  } catch (e) {
19
20
  if (e.message && e.message.startsWith("not found")) {
20
21
  log.error(`"${command}" is not installed`);
@@ -23,4 +24,37 @@ async function c(command, options) {
23
24
  }
24
25
  }
25
26
 
26
- export { c, log, where };
27
+ async function gpgList() {
28
+ const result = await c("gpg", ["-k"]);
29
+ const keys = [];
30
+ const lines = result.stdout.split(EOL).filter((str) => str.trim() !== "");
31
+ if (!lines || lines.length < 4) {
32
+ return [];
33
+ }
34
+ const data = {
35
+ key: "",
36
+ name: "",
37
+ email: ""
38
+ };
39
+ lines.forEach((line) => {
40
+ const [, key] = /^\s+(\w{40})$/.exec(line) || [];
41
+ if (key) {
42
+ data.key = key;
43
+ return;
44
+ }
45
+ if (line.startsWith("uid")) {
46
+ const [, name, email] = /\s(\w+)\s<([\w-]+@[\w-]+(?:\.[\w-]+)+)>/.exec(line) || [];
47
+ data.name = name;
48
+ data.email = email;
49
+ return;
50
+ }
51
+ if (line.startsWith("sub")) {
52
+ keys.push({
53
+ ...data
54
+ });
55
+ }
56
+ });
57
+ return keys;
58
+ }
59
+
60
+ export { c, gpgList, log, where };
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@initx-plugin/utils",
3
3
  "type": "module",
4
- "version": "0.0.10",
5
- "description": "More convenient initialization tool",
4
+ "version": "0.0.12",
5
+ "description": "More convenient initialization engine",
6
6
  "author": "imba97",
7
7
  "license": "MIT",
8
8
  "homepage": "https://github.com/imba97/initx#readme",