@helzady/zady 1.0.0 → 1.1.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/README.md CHANGED
@@ -1,78 +1,115 @@
1
- # zady
1
+ # Zady
2
2
 
3
- Biblioteca leve para logs no Node.js com suporte a cores, prefixos, timestamp e controle de erros.
3
+ Logger leve para Node.js com saída colorida no terminal.
4
4
 
5
5
  ---
6
6
 
7
7
  ## 📦 Instalação
8
8
 
9
9
  ```bash
10
- npm install zady
10
+ npm install @helzady/zady
11
11
  ```
12
12
 
13
13
  ---
14
14
 
15
- ## 🚀 Uso básico
15
+ ## 🚀 Uso
16
16
 
17
17
  ```ts
18
- // Importa funções da biblioteca
19
- import { log, warn, error, success, crash } from "@helzady/logger"
18
+ import zady from "@helzady/zady"
20
19
 
21
- // Log padrão
22
- log("Mensagem simples")
20
+ zady.log("Mensagem de debug")
21
+ zady.info("Servidor iniciado na porta 3000")
22
+ zady.warn("Variável de ambiente não definida")
23
+ zady.success("Conexão estabelecida")
24
+ zady.error("Falha crítica", { error: new Error("stack trace aqui") })
25
+ ```
26
+
27
+ Ou com destructuring:
23
28
 
24
- // Aviso
25
- warn("Atenção")
29
+ ```ts
30
+ import { log, info, warn, success, error } from "@helzady/zady"
31
+ ```
26
32
 
27
- // Erro
28
- error("Algo deu errado")
33
+ ---
29
34
 
30
- // Sucesso
31
- success("Operação concluída")
35
+ ## 🧾 Saída
32
36
 
33
- // Erro fatal (encerra o processo)
34
- crash("Erro crítico")
37
+ ```bash
38
+ [18/05/2026 14:00] [LOG] Mensagem de debug # cinza
39
+ [18/05/2026 14:00] [INFO] Servidor na porta 3000 # azul
40
+ [18/05/2026 14:00] [WARN] Variável não definida # amarelo
41
+ [18/05/2026 14:00] [SUCCESS] Conexão estabelecida # verde
42
+ [18/05/2026 14:00] [ERROR] Falha crítica # vermelho
35
43
  ```
36
44
 
37
45
  ---
38
46
 
39
- ## ⚙️ Opções do crash
47
+ ## 📌 Funções disponíveis
48
+
49
+ | Função | Prefix | Cor | Descrição |
50
+ |---|---|---|---|
51
+ | `log(message)` | `LOG` | Cinza | Debug e mensagens de desenvolvimento |
52
+ | `info(message)` | `INFO` | Azul | Informações relevantes do sistema |
53
+ | `warn(message)` | `WARN` | Amarelo | Avisos que não encerram o processo |
54
+ | `success(message)` | `SUCCESS` | Verde | Confirmação de operações bem-sucedidas |
55
+ | `error(message, options?)` | `ERROR` | Vermelho | Erro crítico — **encerra o processo** |
56
+
57
+ ---
58
+
59
+ ## ⚙️ Opções da função `error`
60
+
61
+ A função `error` aceita um segundo argumento com as seguintes opções:
40
62
 
41
63
  ```ts
42
- crash("Erro crítico", {
43
- code: 1, // Código de saída do processo
44
- prefix: "FATAL", // Prefixo da mensagem
45
- showStack: true, // Mostrar stack trace
46
- timestamp: true, // Mostrar data/hora
47
- error: new Error("Detalhes do erro") // Objeto de erro
64
+ error("Mensagem de erro", {
65
+ code?: number // código de saída do processo (padrão: 1)
66
+ prefix?: string // prefixo customizado (padrão: "ERROR")
67
+ showStack?: boolean // exibir stack trace (padrão: true)
68
+ timestamp?: boolean // exibir data/hora (padrão: true)
69
+ error?: unknown // objeto de erro para exibir o stack
48
70
  })
49
71
  ```
50
72
 
73
+ Exemplo:
74
+
75
+ ```ts
76
+ try {
77
+ // ...
78
+ } catch (err) {
79
+ error("Falha ao conectar ao banco", {
80
+ code: 1,
81
+ error: err,
82
+ showStack: true,
83
+ })
84
+ }
85
+ ```
86
+
51
87
  ---
52
88
 
53
- ## 🎨 Recursos
89
+ ## 🎨 Estilos
54
90
 
55
- * Logs coloridos (ANSI)
56
- * Prefixos personalizados
57
- * Timestamp formatado (DD/MM/YYYY HH:mm)
58
- * Stack trace opcional
59
- * Encerramento seguro do processo
91
+ A lib também expõe utilitários de estilo ANSI para uso direto no terminal:
60
92
 
61
- ---
93
+ ```ts
94
+ import zady from "@helzady/zady"
62
95
 
63
- ## 📁 Estrutura
96
+ const { colors, bgColors, terminalStyle } = zady.style
64
97
 
98
+ console.log(`${colors.cyan}Texto ciano${terminalStyle.reset}`)
99
+ console.log(`${bgColors.red}Fundo vermelho${terminalStyle.reset}`)
65
100
  ```
66
- src/
67
- ├── core/ # Núcleo (formatter, colors, types)
68
- ├── functions/ # Funções principais (log, error, etc)
69
- ├── utils/ # Utilitários internos
70
- ├── config/ # Configurações padrão
71
- └── index.ts # Entry point
72
- ```
101
+
102
+ ### `colors`
103
+ `black` · `red` · `green` · `yellow` · `blue` · `magenta` · `cyan` · `white` · `gray`
104
+
105
+ ### `bgColors`
106
+ `black` · `red` · `green` · `yellow` · `blue` · `magenta` · `cyan` · `white`
107
+
108
+ ### `terminalStyle`
109
+ `reset` · `negrito` · `fraco` · `italico` · `sublinhado` · `riscado`
73
110
 
74
111
  ---
75
112
 
76
113
  ## 📄 Licença
77
114
 
78
- MIT License
115
+ MIT — [HelzadyDev](https://github.com/HelzadyDev)
package/package.json CHANGED
@@ -1,6 +1,9 @@
1
1
  {
2
2
  "name": "@helzady/zady",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
4
7
  "description": "um logger simples e poderoso para Node.js, com saídas formatadas no console, tratamento de erros e utilitários focados no desenvolvedor.",
5
8
  "homepage": "https://github.com/HelzadyDev/zady#readme",
6
9
  "bugs": {
@@ -11,7 +14,7 @@
11
14
  "url": "git+https://github.com/HelzadyDev/zady.git"
12
15
  },
13
16
  "license": "MIT",
14
- "author": "Helzady",
17
+ "author": "HelzadyDev",
15
18
  "type": "module",
16
19
  "files": [
17
20
  "build"
@@ -1,6 +0,0 @@
1
- export declare const defaults: {
2
- prefix: string;
3
- code: number;
4
- showStack: boolean;
5
- timeStamp: boolean;
6
- };
@@ -1,6 +0,0 @@
1
- export const defaults = {
2
- prefix: "LOGGER",
3
- code: 1,
4
- showStack: true,
5
- timeStamp: true,
6
- };
@@ -1 +0,0 @@
1
- export * from "./defaults.js";
@@ -1 +0,0 @@
1
- export * from "./defaults.js";
@@ -1,21 +0,0 @@
1
- export declare const colors: {
2
- black: string;
3
- red: string;
4
- green: string;
5
- yellow: string;
6
- blue: string;
7
- magenta: string;
8
- cyan: string;
9
- white: string;
10
- gray: string;
11
- };
12
- export declare const bgColors: {
13
- black: string;
14
- red: string;
15
- green: string;
16
- yellow: string;
17
- blue: string;
18
- magenta: string;
19
- cyan: string;
20
- white: string;
21
- };
@@ -1,22 +0,0 @@
1
- // Define cores ANSI para terminal
2
- export const colors = {
3
- "black": "\x1b[30",
4
- "red": "\x1b[31m",
5
- "green": "\x1b[32m",
6
- "yellow": "\x1b[33m",
7
- "blue": "\x1b[34m",
8
- "magenta": "\x1b[35",
9
- "cyan": "\x1b[36",
10
- "white": "\x1b[37m",
11
- "gray": "\x1b[90m",
12
- };
13
- export const bgColors = {
14
- "black": "\x1b[40m",
15
- "red": "\x1b[41m",
16
- "green": "\x1b[42m",
17
- "yellow": "\x1b[43m",
18
- "blue": "\x1b[44m",
19
- "magenta": "\x1b[45m",
20
- "cyan": "\x1b[46m",
21
- "white": "\x1b[47m",
22
- };
@@ -1 +0,0 @@
1
- export declare function formatMenssage(message: string, prefix: string, color: string, useTimestamp: boolean): string;
@@ -1,9 +0,0 @@
1
- import { colors, terminalStyle } from "#core";
2
- import { getTimestamp } from "#utils";
3
- // Função responsavel por montar a mensagem fatal
4
- export function formatMenssage(message, prefix, color, useTimestamp) {
5
- const time = useTimestamp
6
- ? `${colors.gray}[${getTimestamp()}]${terminalStyle.reset}`
7
- : "";
8
- return `${time}${color}[${prefix}]${terminalStyle.reset} ${message}`;
9
- }
@@ -1,4 +0,0 @@
1
- export * from "./colors.js";
2
- export * from "./types.js";
3
- export * from "./formatter.js";
4
- export * from "./terminalStyle.js";
@@ -1,4 +0,0 @@
1
- export * from "./colors.js";
2
- export * from "./types.js";
3
- export * from "./formatter.js";
4
- export * from "./terminalStyle.js";
@@ -1,8 +0,0 @@
1
- export declare const terminalStyle: {
2
- reset: string;
3
- negrito: string;
4
- fraco: string;
5
- italico: string;
6
- sublinhado: string;
7
- riscado: string;
8
- };
@@ -1,8 +0,0 @@
1
- export const terminalStyle = {
2
- "reset": "\x1b[0m", // Reseta cor
3
- "negrito": "\x1b[1m", // Formata o texto em negrito
4
- "fraco": "\x1b[2m",
5
- "italico": "\x1b[3m",
6
- "sublinhado": "\x1b[4m",
7
- "riscado": "\x1b[9m",
8
- };
@@ -1,7 +0,0 @@
1
- export interface ErrorOptions {
2
- code?: number;
3
- prefix?: string;
4
- showStack?: boolean;
5
- timestamp?: boolean;
6
- error?: unknown;
7
- }
@@ -1,2 +0,0 @@
1
- ;
2
- export {};
@@ -1,2 +0,0 @@
1
- import { ErrorOptions } from "#core";
2
- export declare function error(message: string, options?: ErrorOptions): never;
@@ -1,19 +0,0 @@
1
- // import { colors, formatMenssage } from "#core";
2
- // // log de erro
3
- // export function error(message: string): void {
4
- // console.error(formatMenssage(message, "ERROR", colors.red, true))
5
- // }
6
- import { colors, formatMenssage } from "#core";
7
- import { defaults } from "#config";
8
- // função fatal que encerra o processo
9
- export function error(message, options = {}) {
10
- const { code = defaults.code, prefix = "FATAL", showStack = defaults.showStack, timestamp = defaults.timeStamp, error, } = options;
11
- // Exibe mensagen formatada
12
- console.error(formatMenssage(message, prefix, colors.red, timestamp));
13
- // Exibe stack trace se existir
14
- if (showStack && error instanceof Error) {
15
- console.error(error.stack);
16
- }
17
- // Encerra o processo
18
- process.exit(code);
19
- }
@@ -1,4 +0,0 @@
1
- export * from "./error.js";
2
- export * from "./log.js";
3
- export * from "./success.js";
4
- export * from "./warn.js";
@@ -1,4 +0,0 @@
1
- export * from "./error.js";
2
- export * from "./log.js";
3
- export * from "./success.js";
4
- export * from "./warn.js";
@@ -1 +0,0 @@
1
- export declare function log(message: string): void;
@@ -1,5 +0,0 @@
1
- import { colors, formatMenssage } from "#core";
2
- // Log padrão (info)
3
- export function log(message) {
4
- console.log(formatMenssage(message, "INFO", colors.blue, true));
5
- }
@@ -1 +0,0 @@
1
- export declare function success(message: string): void;
@@ -1,5 +0,0 @@
1
- import { colors, formatMenssage } from "#core";
2
- // Log de sucesso
3
- export function success(message) {
4
- console.log(formatMenssage(message, "SUCCESS", colors.green, true));
5
- }
@@ -1 +0,0 @@
1
- export declare function warn(message: string): void;
@@ -1,5 +0,0 @@
1
- import { colors, formatMenssage } from "#core";
2
- // log de aviso
3
- export function warn(message) {
4
- console.log(formatMenssage(message, "WARN", colors.yellow, true));
5
- }
package/build/index.d.ts DELETED
@@ -1,38 +0,0 @@
1
- declare const logger: {
2
- style: {
3
- bgColors: {
4
- black: string;
5
- red: string;
6
- green: string;
7
- yellow: string;
8
- blue: string;
9
- magenta: string;
10
- cyan: string;
11
- white: string;
12
- };
13
- colors: {
14
- black: string;
15
- red: string;
16
- green: string;
17
- yellow: string;
18
- blue: string;
19
- magenta: string;
20
- cyan: string;
21
- white: string;
22
- gray: string;
23
- };
24
- terminalStyle: {
25
- reset: string;
26
- negrito: string;
27
- fraco: string;
28
- italico: string;
29
- sublinhado: string;
30
- riscado: string;
31
- };
32
- };
33
- error(message: string, options?: import("#core").ErrorOptions): never;
34
- log(message: string): void;
35
- success(message: string): void;
36
- warn(message: string): void;
37
- };
38
- export default logger;
package/build/index.js DELETED
@@ -1,11 +0,0 @@
1
- import * as functions from "#functions";
2
- import { bgColors, colors, terminalStyle } from "#core";
3
- const logger = {
4
- ...functions,
5
- style: {
6
- bgColors,
7
- colors,
8
- terminalStyle
9
- }
10
- };
11
- export default logger;
@@ -1 +0,0 @@
1
- export declare function getTimestamp(): string;
@@ -1,10 +0,0 @@
1
- // Retorna data no formato DD/MM/YYYY HH:mm
2
- export function getTimestamp() {
3
- const now = new Date();
4
- const day = String(now.getDate()).padStart(2, "0");
5
- const month = String(now.getMonth() + 1).padStart(2, "0");
6
- const year = now.getFullYear();
7
- const hours = String(now.getHours()).padStart(2, "0");
8
- const minutes = String(now.getMinutes()).padStart(2, "0");
9
- return `${day}/${month}/${year} ${hours}:${minutes}`;
10
- }
@@ -1,2 +0,0 @@
1
- export * from "./formatDate.js";
2
- export * from "./precess.js";
@@ -1,2 +0,0 @@
1
- export * from "./formatDate.js";
2
- export * from "./precess.js";
@@ -1 +0,0 @@
1
- export declare function exitProcess(code: string): never;
@@ -1,4 +0,0 @@
1
- // wrapper do proces.exit
2
- export function exitProcess(code) {
3
- process.exit(code);
4
- }