@initx-plugin/utils 0.0.24 → 0.0.25

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 CHANGED
@@ -1,4 +1,5 @@
1
- export { g as gpgList } from './shared/utils.7b93b229.mjs';
1
+ export { g as gpgList } from './shared/utils.7b284c15.mjs';
2
2
  import 'node:os';
3
+ import 'ora';
3
4
  import 'tinyexec';
4
5
  import 'which';
package/dist/index.d.mts CHANGED
@@ -1,20 +1,12 @@
1
- import which from 'which';
2
1
  export { gpgList } from './gpg.mjs';
2
+ import which from 'which';
3
3
 
4
4
  interface Result {
5
5
  success: boolean;
6
6
  content: string;
7
7
  }
8
8
  declare function c(command: string, options?: string[], execaOptions?: Record<string, any>): Promise<Result>;
9
-
10
- declare const log: {
11
- success: (msg: string) => void;
12
- info: (msg: string) => void;
13
- warn: (msg: string) => void;
14
- error: (msg: string) => void;
15
- };
16
-
17
- declare const where: typeof which.sync;
9
+ declare function loadingFunction<T>(message: string, fn: () => Promise<T>): Promise<T>;
18
10
 
19
11
  interface SelectBaseOption {
20
12
  name: string;
@@ -29,4 +21,13 @@ declare const inquirer: {
29
21
  select: typeof select;
30
22
  };
31
23
 
32
- export { c, inquirer, log, where };
24
+ declare const log: {
25
+ success: (msg: string) => void;
26
+ info: (msg: string) => void;
27
+ warn: (msg: string) => void;
28
+ error: (msg: string) => void;
29
+ };
30
+
31
+ declare const where: typeof which.sync;
32
+
33
+ export { c, inquirer, loadingFunction, log, where };
package/dist/index.d.ts CHANGED
@@ -1,20 +1,12 @@
1
- import which from 'which';
2
1
  export { gpgList } from './gpg.js';
2
+ import which from 'which';
3
3
 
4
4
  interface Result {
5
5
  success: boolean;
6
6
  content: string;
7
7
  }
8
8
  declare function c(command: string, options?: string[], execaOptions?: Record<string, any>): Promise<Result>;
9
-
10
- declare const log: {
11
- success: (msg: string) => void;
12
- info: (msg: string) => void;
13
- warn: (msg: string) => void;
14
- error: (msg: string) => void;
15
- };
16
-
17
- declare const where: typeof which.sync;
9
+ declare function loadingFunction<T>(message: string, fn: () => Promise<T>): Promise<T>;
18
10
 
19
11
  interface SelectBaseOption {
20
12
  name: string;
@@ -29,4 +21,13 @@ declare const inquirer: {
29
21
  select: typeof select;
30
22
  };
31
23
 
32
- export { c, inquirer, log, where };
24
+ declare const log: {
25
+ success: (msg: string) => void;
26
+ info: (msg: string) => void;
27
+ warn: (msg: string) => void;
28
+ error: (msg: string) => void;
29
+ };
30
+
31
+ declare const where: typeof which.sync;
32
+
33
+ export { c, inquirer, loadingFunction, log, where };
package/dist/index.mjs CHANGED
@@ -1,17 +1,11 @@
1
- export { c, g as gpgList, w as where } from './shared/utils.7b93b229.mjs';
2
- import c from 'picocolors';
1
+ export { c, g as gpgList, l as loadingFunction, w as where } from './shared/utils.7b284c15.mjs';
3
2
  import _inquirer from 'inquirer';
3
+ import c from 'picocolors';
4
4
  import 'node:os';
5
+ import 'ora';
5
6
  import 'tinyexec';
6
7
  import 'which';
7
8
 
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
-
15
9
  async function confirm(message) {
16
10
  const { result } = await _inquirer.prompt([
17
11
  {
@@ -43,4 +37,11 @@ const inquirer = {
43
37
  select
44
38
  };
45
39
 
40
+ const log = {
41
+ success: (msg) => console.log(`${c.bgGreen(c.black(" SUCCESS "))} ${msg}`),
42
+ info: (msg) => console.log(`${c.bgBlue(c.white(" INFO "))} ${msg}`),
43
+ warn: (msg) => console.log(`${c.bgYellow(c.black(" WARN "))} ${msg}`),
44
+ error: (msg) => console.log(`${c.bgRed(c.white(" ERROR "))} ${msg}`)
45
+ };
46
+
46
47
  export { inquirer, log };
@@ -1,4 +1,5 @@
1
1
  import { EOL } from 'node:os';
2
+ import ora from 'ora';
2
3
  import { x } from 'tinyexec';
3
4
  import which from 'which';
4
5
 
@@ -23,6 +24,12 @@ async function c(command, options, execaOptions = {}) {
23
24
  }
24
25
  return result;
25
26
  }
27
+ async function loadingFunction(message, fn) {
28
+ const spinner = ora(message).start();
29
+ return fn().finally(() => {
30
+ spinner.stop();
31
+ });
32
+ }
26
33
 
27
34
  async function gpgList() {
28
35
  const result = await c("gpg", ["-k"]);
@@ -57,4 +64,4 @@ async function gpgList() {
57
64
  return keys;
58
65
  }
59
66
 
60
- export { c, gpgList as g, where as w };
67
+ export { c, gpgList as g, loadingFunction as l, where as w };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@initx-plugin/utils",
3
3
  "type": "module",
4
- "version": "0.0.24",
4
+ "version": "0.0.25",
5
5
  "description": "A more convenient scripting engine",
6
6
  "license": "MIT",
7
7
  "homepage": "https://github.com/initx-collective/initx#readme",
@@ -33,6 +33,7 @@
33
33
  ],
34
34
  "dependencies": {
35
35
  "inquirer": "^12.1.0",
36
+ "ora": "^8.1.1",
36
37
  "picocolors": "^1.1.1",
37
38
  "tinyexec": "^0.3.1",
38
39
  "which": "^5.0.0"