@initx-plugin/utils 0.0.10 → 0.0.11
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/dist/gpg.mjs +2 -37
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.mjs +37 -3
- package/package.json +1 -1
package/dist/gpg.mjs
CHANGED
|
@@ -1,40 +1,5 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
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 };
|