@initx-plugin/utils 0.2.0 → 0.3.0
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/index.d.mts +47 -1
- package/dist/index.d.ts +47 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,52 @@
|
|
|
1
1
|
export { gpgList } from './gpg.mjs';
|
|
2
2
|
import which from 'which';
|
|
3
3
|
|
|
4
|
+
declare class ColorBuilder {
|
|
5
|
+
private text;
|
|
6
|
+
private fgColor;
|
|
7
|
+
private bgColor;
|
|
8
|
+
private styles;
|
|
9
|
+
constructor(text: string);
|
|
10
|
+
black(): this;
|
|
11
|
+
red(): this;
|
|
12
|
+
green(): this;
|
|
13
|
+
yellow(): this;
|
|
14
|
+
blue(): this;
|
|
15
|
+
white(): this;
|
|
16
|
+
gray(): this;
|
|
17
|
+
bgBlack(): this;
|
|
18
|
+
bgRed(): this;
|
|
19
|
+
bgGreen(): this;
|
|
20
|
+
bgYellow(): this;
|
|
21
|
+
bgBlue(): this;
|
|
22
|
+
bgGray(): this;
|
|
23
|
+
dim(): this;
|
|
24
|
+
bold(): this;
|
|
25
|
+
reset(): this;
|
|
26
|
+
toString(): string;
|
|
27
|
+
valueOf(): string;
|
|
28
|
+
private setColor;
|
|
29
|
+
private setBgColor;
|
|
30
|
+
private addStyle;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Create a color builder for the given text
|
|
34
|
+
* @example
|
|
35
|
+
* useColors('Hello').red().bgBlue()
|
|
36
|
+
* useColors('World').green().bold()
|
|
37
|
+
*/
|
|
38
|
+
declare function useColors(text: string): ColorBuilder;
|
|
39
|
+
declare const red: (text: string) => ColorBuilder;
|
|
40
|
+
declare const green: (text: string) => ColorBuilder;
|
|
41
|
+
declare const yellow: (text: string) => ColorBuilder;
|
|
42
|
+
declare const blue: (text: string) => ColorBuilder;
|
|
43
|
+
declare const white: (text: string) => ColorBuilder;
|
|
44
|
+
declare const black: (text: string) => ColorBuilder;
|
|
45
|
+
declare const gray: (text: string) => ColorBuilder;
|
|
46
|
+
declare const dim: (text: string) => ColorBuilder;
|
|
47
|
+
declare const bold: (text: string) => ColorBuilder;
|
|
48
|
+
declare const reset: (text: string) => ColorBuilder;
|
|
49
|
+
|
|
4
50
|
interface Result {
|
|
5
51
|
success: boolean;
|
|
6
52
|
content: string;
|
|
@@ -40,4 +86,4 @@ declare const log: Logger;
|
|
|
40
86
|
|
|
41
87
|
declare const where: typeof which.sync;
|
|
42
88
|
|
|
43
|
-
export { c, inquirer, loadingFunction, log, logger, where };
|
|
89
|
+
export { ColorBuilder, black, blue, bold, c, dim, gray, green, inquirer, loadingFunction, log, logger, red, reset, useColors, where, white, yellow };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,52 @@
|
|
|
1
1
|
export { gpgList } from './gpg.js';
|
|
2
2
|
import which from 'which';
|
|
3
3
|
|
|
4
|
+
declare class ColorBuilder {
|
|
5
|
+
private text;
|
|
6
|
+
private fgColor;
|
|
7
|
+
private bgColor;
|
|
8
|
+
private styles;
|
|
9
|
+
constructor(text: string);
|
|
10
|
+
black(): this;
|
|
11
|
+
red(): this;
|
|
12
|
+
green(): this;
|
|
13
|
+
yellow(): this;
|
|
14
|
+
blue(): this;
|
|
15
|
+
white(): this;
|
|
16
|
+
gray(): this;
|
|
17
|
+
bgBlack(): this;
|
|
18
|
+
bgRed(): this;
|
|
19
|
+
bgGreen(): this;
|
|
20
|
+
bgYellow(): this;
|
|
21
|
+
bgBlue(): this;
|
|
22
|
+
bgGray(): this;
|
|
23
|
+
dim(): this;
|
|
24
|
+
bold(): this;
|
|
25
|
+
reset(): this;
|
|
26
|
+
toString(): string;
|
|
27
|
+
valueOf(): string;
|
|
28
|
+
private setColor;
|
|
29
|
+
private setBgColor;
|
|
30
|
+
private addStyle;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Create a color builder for the given text
|
|
34
|
+
* @example
|
|
35
|
+
* useColors('Hello').red().bgBlue()
|
|
36
|
+
* useColors('World').green().bold()
|
|
37
|
+
*/
|
|
38
|
+
declare function useColors(text: string): ColorBuilder;
|
|
39
|
+
declare const red: (text: string) => ColorBuilder;
|
|
40
|
+
declare const green: (text: string) => ColorBuilder;
|
|
41
|
+
declare const yellow: (text: string) => ColorBuilder;
|
|
42
|
+
declare const blue: (text: string) => ColorBuilder;
|
|
43
|
+
declare const white: (text: string) => ColorBuilder;
|
|
44
|
+
declare const black: (text: string) => ColorBuilder;
|
|
45
|
+
declare const gray: (text: string) => ColorBuilder;
|
|
46
|
+
declare const dim: (text: string) => ColorBuilder;
|
|
47
|
+
declare const bold: (text: string) => ColorBuilder;
|
|
48
|
+
declare const reset: (text: string) => ColorBuilder;
|
|
49
|
+
|
|
4
50
|
interface Result {
|
|
5
51
|
success: boolean;
|
|
6
52
|
content: string;
|
|
@@ -40,4 +86,4 @@ declare const log: Logger;
|
|
|
40
86
|
|
|
41
87
|
declare const where: typeof which.sync;
|
|
42
88
|
|
|
43
|
-
export { c, inquirer, loadingFunction, log, logger, where };
|
|
89
|
+
export { ColorBuilder, black, blue, bold, c, dim, gray, green, inquirer, loadingFunction, log, logger, red, reset, useColors, where, white, yellow };
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{c,g as gpgList,l as loadingFunction,w as where}from"./shared/utils.Dmh89-WN.mjs";import
|
|
1
|
+
export{c,g as gpgList,l as loadingFunction,w as where}from"./shared/utils.Dmh89-WN.mjs";import g from"inquirer";import"ora";import"tinyexec";import"which";const s={reset:"\x1B[0m",black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",white:"\x1B[37m",gray:"\x1B[90m",bgBlack:"\x1B[40m",bgRed:"\x1B[41m",bgGreen:"\x1B[42m",bgYellow:"\x1B[43m",bgBlue:"\x1B[44m",bgGray:"\x1B[100m",dim:"\x1B[2m",bold:"\x1B[1m"};class u{constructor(e){this.text=e}fgColor="";bgColor="";styles=[];black(){return this.setColor("black")}red(){return this.setColor("red")}green(){return this.setColor("green")}yellow(){return this.setColor("yellow")}blue(){return this.setColor("blue")}white(){return this.setColor("white")}gray(){return this.setColor("gray")}bgBlack(){return this.setBgColor("bgBlack")}bgRed(){return this.setBgColor("bgRed")}bgGreen(){return this.setBgColor("bgGreen")}bgYellow(){return this.setBgColor("bgYellow")}bgBlue(){return this.setBgColor("bgBlue")}bgGray(){return this.setBgColor("bgGray")}dim(){return this.addStyle("dim")}bold(){return this.addStyle("bold")}reset(){return this.fgColor="",this.bgColor="",this.styles=[],this}toString(){const e=[...this.styles,this.fgColor,this.bgColor].filter(Boolean).join("");return e?`${e}${this.text}${s.reset}`:this.text}valueOf(){return this.toString()}setColor(e){return this.fgColor=s[e],this}setBgColor(e){return this.bgColor=s[e],this}addStyle(e){return this.styles.push(s[e]),this}}function r(t){return new u(t)}const a=t=>r(t).red(),B=t=>r(t).green(),m=t=>r(t).yellow(),d=t=>r(t).blue(),x=t=>r(t).white(),w=t=>r(t).black(),C=t=>r(t).gray(),y=t=>r(t).dim(),f=t=>r(t).bold(),$=t=>r(t).reset();async function p(t){const{result:e}=await g.prompt([{type:"confirm",name:"result",message:t}]);return e}async function k(t,e){const{result:l}=await g.prompt([{type:"list",name:"result",message:t,choices:e.map((n,c)=>typeof n=="string"?{name:n,value:c}:n)}]);return l}const G={confirm:p,select:k},i={reset:"\x1B[0m",black:"\x1B[30m",white:"\x1B[37m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",bgBrightBlack:"\x1B[100m",bgGreen:"\x1B[42m",bgBlue:"\x1B[44m",bgYellow:"\x1B[43m",bgRed:"\x1B[41m"},h={debug:0,info:1,success:2,warn:3,error:4};function o(t,e,l){return`${i[l]}${i[e]}${t}${i.reset}`}class R{level="info";setLevel(e){this.level=e}shouldLog(e){return h[e]>=h[this.level]}debug(e){this.shouldLog("debug")&&console.log(`${o(" DEBUG ","black","bgBrightBlack")} ${e}`)}info(e){this.shouldLog("info")&&console.log(`${o(" INFO ","white","bgBlue")} ${e}`)}success(e){this.shouldLog("success")&&console.log(`${o(" SUCCESS ","black","bgGreen")} ${e}`)}warn(e){this.shouldLog("warn")&&console.log(`${o(" WARN ","black","bgYellow")} ${e}`)}error(e){this.shouldLog("error")&&console.log(`${o(" ERROR ","white","bgRed")} ${e}`)}}const b=new R,L=b;export{u as ColorBuilder,w as black,d as blue,f as bold,y as dim,C as gray,B as green,G as inquirer,L as log,b as logger,a as red,$ as reset,r as useColors,x as white,m as yellow};
|
package/package.json
CHANGED