@initx-plugin/utils 0.0.12 → 0.0.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/README.md +3 -3
- package/dist/gpg.mjs +2 -2
- package/dist/index.d.mts +14 -1
- package/dist/index.d.ts +14 -1
- package/dist/index.mjs +33 -54
- package/dist/shared/utils.b4326f32.mjs +60 -0
- package/package.json +7 -6
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
<h1 align="center">
|
|
1
|
+
<h1 align="center">initx ⚙️</h1>
|
|
2
2
|
|
|
3
|
-
<p align="center"><code>initx</code>
|
|
3
|
+
<p align="center"><code>initx</code> A more convenient scripting engine</p>
|
|
4
4
|
|
|
5
5
|
<pre align="center">npx <b>initx <something></b></pre>
|
|
6
6
|
|
|
@@ -10,4 +10,4 @@ Utilities for `initx`
|
|
|
10
10
|
|
|
11
11
|
## Documentation
|
|
12
12
|
|
|
13
|
-
[initx](https://github.com/
|
|
13
|
+
[initx](https://github.com/initx-collective/initx)
|
package/dist/gpg.mjs
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -13,4 +13,17 @@ declare const log: {
|
|
|
13
13
|
|
|
14
14
|
declare const where: typeof which.sync;
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
interface SelectBaseOption {
|
|
17
|
+
name: string;
|
|
18
|
+
value: string | number;
|
|
19
|
+
}
|
|
20
|
+
type SelectOptions = string[] | SelectBaseOption[];
|
|
21
|
+
|
|
22
|
+
declare function confirm(message: string): Promise<any>;
|
|
23
|
+
declare function select(message: string, options: SelectOptions): Promise<any>;
|
|
24
|
+
declare const inquirer: {
|
|
25
|
+
confirm: typeof confirm;
|
|
26
|
+
select: typeof select;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export { c, inquirer, log, where };
|
package/dist/index.d.ts
CHANGED
|
@@ -13,4 +13,17 @@ declare const log: {
|
|
|
13
13
|
|
|
14
14
|
declare const where: typeof which.sync;
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
interface SelectBaseOption {
|
|
17
|
+
name: string;
|
|
18
|
+
value: string | number;
|
|
19
|
+
}
|
|
20
|
+
type SelectOptions = string[] | SelectBaseOption[];
|
|
21
|
+
|
|
22
|
+
declare function confirm(message: string): Promise<any>;
|
|
23
|
+
declare function select(message: string, options: SelectOptions): Promise<any>;
|
|
24
|
+
declare const inquirer: {
|
|
25
|
+
confirm: typeof confirm;
|
|
26
|
+
select: typeof select;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export { c, inquirer, log, where };
|
package/dist/index.mjs
CHANGED
|
@@ -1,60 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
1
|
+
export { c, g as gpgList, l as log, w as where } from './shared/utils.b4326f32.mjs';
|
|
2
|
+
import _inquirer from 'inquirer';
|
|
3
|
+
import 'node:os';
|
|
4
|
+
import 'execa';
|
|
5
|
+
import 'picocolors';
|
|
6
|
+
import 'which';
|
|
5
7
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const where = which.sync;
|
|
14
|
-
|
|
15
|
-
async function c(command, options, execaOptions = {}) {
|
|
16
|
-
try {
|
|
17
|
-
where(command);
|
|
18
|
-
return await execa(command, options, execaOptions);
|
|
19
|
-
} catch (e) {
|
|
20
|
-
if (e.message && e.message.startsWith("not found")) {
|
|
21
|
-
log.error(`"${command}" is not installed`);
|
|
8
|
+
async function confirm(message) {
|
|
9
|
+
const { result } = await _inquirer.prompt([
|
|
10
|
+
{
|
|
11
|
+
type: "confirm",
|
|
12
|
+
name: "result",
|
|
13
|
+
message
|
|
22
14
|
}
|
|
23
|
-
|
|
24
|
-
|
|
15
|
+
]);
|
|
16
|
+
return result;
|
|
25
17
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
};
|
|
39
|
-
lines.forEach((line) => {
|
|
40
|
-
const [, key] = /^\s+(\w{40})$/.exec(line) || [];
|
|
41
|
-
if (key) {
|
|
42
|
-
data.key = key;
|
|
43
|
-
return;
|
|
18
|
+
async function select(message, options) {
|
|
19
|
+
const { result } = await _inquirer.prompt([
|
|
20
|
+
{
|
|
21
|
+
type: "list",
|
|
22
|
+
name: "result",
|
|
23
|
+
message,
|
|
24
|
+
choices: options.map((option, index) => {
|
|
25
|
+
return typeof option === "string" ? {
|
|
26
|
+
name: option,
|
|
27
|
+
value: index
|
|
28
|
+
} : option;
|
|
29
|
+
})
|
|
44
30
|
}
|
|
45
|
-
|
|
46
|
-
|
|
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;
|
|
31
|
+
]);
|
|
32
|
+
return result;
|
|
58
33
|
}
|
|
34
|
+
const inquirer = {
|
|
35
|
+
confirm,
|
|
36
|
+
select
|
|
37
|
+
};
|
|
59
38
|
|
|
60
|
-
export {
|
|
39
|
+
export { inquirer };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { EOL } from 'node:os';
|
|
2
|
+
import { execa } from 'execa';
|
|
3
|
+
import c$1 from 'picocolors';
|
|
4
|
+
import which from 'which';
|
|
5
|
+
|
|
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
|
+
const where = which.sync;
|
|
14
|
+
|
|
15
|
+
async function c(command, options, execaOptions = {}) {
|
|
16
|
+
try {
|
|
17
|
+
where(command);
|
|
18
|
+
return await execa(command, options, execaOptions);
|
|
19
|
+
} catch (e) {
|
|
20
|
+
if (e.message && e.message.startsWith("not found")) {
|
|
21
|
+
log.error(`"${command}" is not installed`);
|
|
22
|
+
}
|
|
23
|
+
return e;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
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 as g, log as l, where as w };
|
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@initx-plugin/utils",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
5
|
-
"description": "
|
|
4
|
+
"version": "0.0.14",
|
|
5
|
+
"description": "A more convenient scripting engine",
|
|
6
6
|
"author": "imba97",
|
|
7
7
|
"license": "MIT",
|
|
8
|
-
"homepage": "https://github.com/
|
|
8
|
+
"homepage": "https://github.com/initx-collective/initx#readme",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
|
-
"url": "git
|
|
11
|
+
"url": "git@github.com:initx-collective/initx.git"
|
|
12
12
|
},
|
|
13
13
|
"bugs": {
|
|
14
|
-
"url": "https://github.com/
|
|
14
|
+
"url": "https://github.com/initx-collective/initx/issues"
|
|
15
15
|
},
|
|
16
16
|
"keywords": [
|
|
17
17
|
"initx"
|
|
@@ -33,7 +33,8 @@
|
|
|
33
33
|
"dist"
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"execa": "^9.
|
|
36
|
+
"execa": "^9.5.0",
|
|
37
|
+
"inquirer": "^12.0.1",
|
|
37
38
|
"picocolors": "^1.1.1",
|
|
38
39
|
"which": "^5.0.0"
|
|
39
40
|
},
|