@initx-plugin/utils 0.0.15 → 0.0.16
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 -3
- package/dist/index.d.mts +5 -2
- package/dist/index.d.ts +5 -2
- package/dist/index.mjs +11 -4
- package/dist/shared/{utils.b4326f32.mjs → utils.7b93b229.mjs} +14 -14
- package/package.json +2 -3
package/dist/gpg.mjs
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import { Result } from 'execa';
|
|
2
1
|
import which from 'which';
|
|
3
2
|
export { gpgList } from './gpg.mjs';
|
|
4
3
|
|
|
5
|
-
|
|
4
|
+
interface Result {
|
|
5
|
+
success: boolean;
|
|
6
|
+
content: string;
|
|
7
|
+
}
|
|
8
|
+
declare function c(command: string, options?: string[], execaOptions?: Record<string, any>): Promise<Result>;
|
|
6
9
|
|
|
7
10
|
declare const log: {
|
|
8
11
|
success: (msg: string) => void;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import { Result } from 'execa';
|
|
2
1
|
import which from 'which';
|
|
3
2
|
export { gpgList } from './gpg.js';
|
|
4
3
|
|
|
5
|
-
|
|
4
|
+
interface Result {
|
|
5
|
+
success: boolean;
|
|
6
|
+
content: string;
|
|
7
|
+
}
|
|
8
|
+
declare function c(command: string, options?: string[], execaOptions?: Record<string, any>): Promise<Result>;
|
|
6
9
|
|
|
7
10
|
declare const log: {
|
|
8
11
|
success: (msg: string) => void;
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
|
-
export { c, g as gpgList,
|
|
1
|
+
export { c, g as gpgList, w as where } from './shared/utils.7b93b229.mjs';
|
|
2
|
+
import c from 'picocolors';
|
|
2
3
|
import _inquirer from 'inquirer';
|
|
3
4
|
import 'node:os';
|
|
4
|
-
import '
|
|
5
|
-
import 'picocolors';
|
|
5
|
+
import 'tinyexec';
|
|
6
6
|
import 'which';
|
|
7
7
|
|
|
8
|
+
const log = {
|
|
9
|
+
success: (msg) => console.log(`${c.bgGreen(c.black(" SUCCESS "))} ${msg}`),
|
|
10
|
+
info: (msg) => console.log(`${c.bgBlue(c.white(" INFO "))} ${msg}`),
|
|
11
|
+
warn: (msg) => console.log(`${c.bgYellow(c.black(" WARN "))} ${msg}`),
|
|
12
|
+
error: (msg) => console.log(`${c.bgRed(c.white(" ERROR "))} ${msg}`)
|
|
13
|
+
};
|
|
14
|
+
|
|
8
15
|
async function confirm(message) {
|
|
9
16
|
const { result } = await _inquirer.prompt([
|
|
10
17
|
{
|
|
@@ -36,4 +43,4 @@ const inquirer = {
|
|
|
36
43
|
select
|
|
37
44
|
};
|
|
38
45
|
|
|
39
|
-
export { inquirer };
|
|
46
|
+
export { inquirer, log };
|
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
import { EOL } from 'node:os';
|
|
2
|
-
import {
|
|
3
|
-
import c$1 from 'picocolors';
|
|
2
|
+
import { x } from 'tinyexec';
|
|
4
3
|
import which from 'which';
|
|
5
4
|
|
|
6
|
-
const log = {
|
|
7
|
-
success: (msg) => console.log(`${c$1.bgGreen(c$1.black(" SUCCESS "))} ${msg}`),
|
|
8
|
-
info: (msg) => console.log(`${c$1.bgBlue(c$1.white(" INFO "))} ${msg}`),
|
|
9
|
-
warn: (msg) => console.log(`${c$1.bgYellow(c$1.black(" WARN "))} ${msg}`),
|
|
10
|
-
error: (msg) => console.log(`${c$1.bgRed(c$1.white(" ERROR "))} ${msg}`)
|
|
11
|
-
};
|
|
12
|
-
|
|
13
5
|
const where = which.sync;
|
|
14
6
|
|
|
15
7
|
async function c(command, options, execaOptions = {}) {
|
|
8
|
+
const result = {
|
|
9
|
+
success: false,
|
|
10
|
+
content: "Unknown error"
|
|
11
|
+
};
|
|
16
12
|
try {
|
|
17
13
|
where(command);
|
|
18
|
-
|
|
14
|
+
const xResult = await x(command, options, execaOptions);
|
|
15
|
+
result.success = xResult.exitCode === 0;
|
|
16
|
+
result.content = (result.success ? xResult.stdout : xResult.stderr).trim();
|
|
19
17
|
} catch (e) {
|
|
20
18
|
if (e.message && e.message.startsWith("not found")) {
|
|
21
|
-
|
|
19
|
+
result.content = `can not find command: ${command}`;
|
|
20
|
+
} else {
|
|
21
|
+
result.content = e.message;
|
|
22
22
|
}
|
|
23
|
-
return e;
|
|
24
23
|
}
|
|
24
|
+
return result;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
async function gpgList() {
|
|
28
28
|
const result = await c("gpg", ["-k"]);
|
|
29
29
|
const keys = [];
|
|
30
|
-
const lines = result.
|
|
30
|
+
const lines = result.content.split(EOL).filter((str) => str.trim() !== "");
|
|
31
31
|
if (!lines || lines.length < 4) {
|
|
32
32
|
return [];
|
|
33
33
|
}
|
|
@@ -57,4 +57,4 @@ async function gpgList() {
|
|
|
57
57
|
return keys;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
export { c, gpgList as g,
|
|
60
|
+
export { c, gpgList as g, where as w };
|
package/package.json
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@initx-plugin/utils",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.16",
|
|
5
5
|
"description": "A more convenient scripting engine",
|
|
6
|
-
"author": "imba97",
|
|
7
6
|
"license": "MIT",
|
|
8
7
|
"homepage": "https://github.com/initx-collective/initx#readme",
|
|
9
8
|
"repository": {
|
|
@@ -33,9 +32,9 @@
|
|
|
33
32
|
"dist"
|
|
34
33
|
],
|
|
35
34
|
"dependencies": {
|
|
36
|
-
"execa": "^9.5.0",
|
|
37
35
|
"inquirer": "^12.0.1",
|
|
38
36
|
"picocolors": "^1.1.1",
|
|
37
|
+
"tinyexec": "^0.3.1",
|
|
39
38
|
"which": "^5.0.0"
|
|
40
39
|
},
|
|
41
40
|
"devDependencies": {
|