@helzady/zady 1.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 HelzadyDev
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,78 @@
1
+ # zady
2
+
3
+ Biblioteca leve para logs no Node.js com suporte a cores, prefixos, timestamp e controle de erros.
4
+
5
+ ---
6
+
7
+ ## 📦 Instalação
8
+
9
+ ```bash
10
+ npm install zady
11
+ ```
12
+
13
+ ---
14
+
15
+ ## 🚀 Uso básico
16
+
17
+ ```ts
18
+ // Importa funções da biblioteca
19
+ import { log, warn, error, success, crash } from "@helzady/logger"
20
+
21
+ // Log padrão
22
+ log("Mensagem simples")
23
+
24
+ // Aviso
25
+ warn("Atenção")
26
+
27
+ // Erro
28
+ error("Algo deu errado")
29
+
30
+ // Sucesso
31
+ success("Operação concluída")
32
+
33
+ // Erro fatal (encerra o processo)
34
+ crash("Erro crítico")
35
+ ```
36
+
37
+ ---
38
+
39
+ ## ⚙️ Opções do crash
40
+
41
+ ```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
48
+ })
49
+ ```
50
+
51
+ ---
52
+
53
+ ## 🎨 Recursos
54
+
55
+ * Logs coloridos (ANSI)
56
+ * Prefixos personalizados
57
+ * Timestamp formatado (DD/MM/YYYY HH:mm)
58
+ * Stack trace opcional
59
+ * Encerramento seguro do processo
60
+
61
+ ---
62
+
63
+ ## 📁 Estrutura
64
+
65
+ ```
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
+ ```
73
+
74
+ ---
75
+
76
+ ## 📄 Licença
77
+
78
+ MIT License
@@ -0,0 +1,6 @@
1
+ export declare const defaults: {
2
+ prefix: string;
3
+ code: number;
4
+ showStack: boolean;
5
+ timeStamp: boolean;
6
+ };
@@ -0,0 +1,6 @@
1
+ export const defaults = {
2
+ prefix: "LOGGER",
3
+ code: 1,
4
+ showStack: true,
5
+ timeStamp: true,
6
+ };
@@ -0,0 +1 @@
1
+ export * from "./defaults.js";
@@ -0,0 +1 @@
1
+ export * from "./defaults.js";
@@ -0,0 +1,21 @@
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
+ };
@@ -0,0 +1,22 @@
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
+ };
@@ -0,0 +1 @@
1
+ export declare function formatMenssage(message: string, prefix: string, color: string, useTimestamp: boolean): string;
@@ -0,0 +1,9 @@
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
+ }
@@ -0,0 +1,4 @@
1
+ export * from "./colors.js";
2
+ export * from "./types.js";
3
+ export * from "./formatter.js";
4
+ export * from "./terminalStyle.js";
@@ -0,0 +1,4 @@
1
+ export * from "./colors.js";
2
+ export * from "./types.js";
3
+ export * from "./formatter.js";
4
+ export * from "./terminalStyle.js";
@@ -0,0 +1,8 @@
1
+ export declare const terminalStyle: {
2
+ reset: string;
3
+ negrito: string;
4
+ fraco: string;
5
+ italico: string;
6
+ sublinhado: string;
7
+ riscado: string;
8
+ };
@@ -0,0 +1,8 @@
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
+ };
@@ -0,0 +1,7 @@
1
+ export interface ErrorOptions {
2
+ code?: number;
3
+ prefix?: string;
4
+ showStack?: boolean;
5
+ timestamp?: boolean;
6
+ error?: unknown;
7
+ }
@@ -0,0 +1,2 @@
1
+ ;
2
+ export {};
@@ -0,0 +1,2 @@
1
+ import { ErrorOptions } from "#core";
2
+ export declare function error(message: string, options?: ErrorOptions): never;
@@ -0,0 +1,19 @@
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
+ }
@@ -0,0 +1,4 @@
1
+ export * from "./error.js";
2
+ export * from "./log.js";
3
+ export * from "./success.js";
4
+ export * from "./warn.js";
@@ -0,0 +1,4 @@
1
+ export * from "./error.js";
2
+ export * from "./log.js";
3
+ export * from "./success.js";
4
+ export * from "./warn.js";
@@ -0,0 +1 @@
1
+ export declare function log(message: string): void;
@@ -0,0 +1,5 @@
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
+ }
@@ -0,0 +1 @@
1
+ export declare function success(message: string): void;
@@ -0,0 +1,5 @@
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
+ }
@@ -0,0 +1 @@
1
+ export declare function warn(message: string): void;
@@ -0,0 +1,5 @@
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
+ }
@@ -0,0 +1,38 @@
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 ADDED
@@ -0,0 +1,11 @@
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;
@@ -0,0 +1 @@
1
+ export declare function getTimestamp(): string;
@@ -0,0 +1,10 @@
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
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./formatDate.js";
2
+ export * from "./precess.js";
@@ -0,0 +1,2 @@
1
+ export * from "./formatDate.js";
2
+ export * from "./precess.js";
@@ -0,0 +1 @@
1
+ export declare function exitProcess(code: string): never;
@@ -0,0 +1,4 @@
1
+ // wrapper do proces.exit
2
+ export function exitProcess(code) {
3
+ process.exit(code);
4
+ }
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@helzady/zady",
3
+ "version": "1.0.0",
4
+ "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
+ "homepage": "https://github.com/HelzadyDev/zady#readme",
6
+ "bugs": {
7
+ "url": "https://github.com/HelzadyDev/zady/issues"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/HelzadyDev/zady.git"
12
+ },
13
+ "license": "MIT",
14
+ "author": "Helzady",
15
+ "type": "module",
16
+ "files": [
17
+ "build"
18
+ ],
19
+ "main": "build/index.js",
20
+ "types": "build/index.d.ts",
21
+ "scripts": {
22
+ "build": "rimraf ./build && tsc",
23
+ "dev": "tsx ./src/index.ts"
24
+ },
25
+ "keywords": [
26
+ "logger",
27
+ "log",
28
+ "console",
29
+ "nodejs",
30
+ "utils",
31
+ "logging",
32
+ "degub",
33
+ "error",
34
+ "terminal",
35
+ "developer",
36
+ "cli",
37
+ "typescript"
38
+ ],
39
+ "devDependencies": {
40
+ "@types/node": "^25.6.0",
41
+ "tsx": "^4.21.0",
42
+ "typescript": "^6.0.3"
43
+ },
44
+ "imports": {
45
+ "#functions": [
46
+ "./build/functions/index.js"
47
+ ],
48
+ "#utils": [
49
+ "./build/utils/index.js"
50
+ ],
51
+ "#core": [
52
+ "./build/core/index.js"
53
+ ],
54
+ "#config": [
55
+ "./build/config/index.js"
56
+ ]
57
+ }
58
+ }