Skip to content

Commit 8074d97

Browse files
authored
Merge pull request #1 from mathauscm/staging
Staging
2 parents 83976a3 + f3d33ca commit 8074d97

17 files changed

Lines changed: 565 additions & 4969 deletions

.github/workflows/deploy.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Publish to npm
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
jobs:
8+
test:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
- uses: actions/setup-node@v4
13+
with:
14+
node-version: 20
15+
- run: npm ci
16+
- run: npm test
17+
18+
publish:
19+
needs: test
20+
runs-on: ubuntu-latest
21+
permissions:
22+
contents: read
23+
id-token: write
24+
steps:
25+
- uses: actions/checkout@v4
26+
- uses: actions/setup-node@v4
27+
with:
28+
node-version: 20
29+
registry-url: https://registry.npmjs.org
30+
- run: npm ci
31+
- run: npm run build
32+
- run: npm publish --provenance --access public
33+
env:
34+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

README.md

Lines changed: 11 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
# @aldeia/faker-br
22

3-
Gerador de textos aleatórios em **PT-BR** para Node.js e NestJS.
3+
[![npm version](https://img.shields.io/npm/v/@aldeia/faker-br.svg)](https://www.npmjs.com/package/@aldeia/faker-br)
4+
[![CI](https://github.com/mathauscm/faker/actions/workflows/deploy.yml/badge.svg)](https://github.com/mathauscm/faker/actions/workflows/deploy.yml)
5+
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
46

5-
Ideal para popular interfaces, prototipar telas, gerar seeds de banco de dados e testar aplicações com textos realistas em português.
7+
Gerador de textos aleatórios em **PT-BR** para Node.js e TypeScript.
8+
9+
Zero dependências de produção. Ideal para popular interfaces, prototipar telas, gerar seeds de banco de dados e testar aplicações com textos realistas em português.
610

711
## Instalação
812

913
```bash
1014
npm install @aldeia/faker-br
1115
```
1216

13-
## Uso Standalone
14-
15-
Funciona em qualquer projeto Node.js/TypeScript, sem dependência do NestJS.
17+
## Uso
1618

1719
```typescript
1820
import { fakerBr } from '@aldeia/faker-br';
@@ -51,57 +53,6 @@ const faker = createFakerBr(() => 0.5);
5153
faker.lorem.sentence(); // Sempre retorna o mesmo resultado
5254
```
5355

54-
## Uso com NestJS
55-
56-
### Configuração do módulo
57-
58-
```typescript
59-
import { Module } from '@nestjs/common';
60-
import { FakerModule } from '@aldeia/faker-br';
61-
62-
@Module({
63-
imports: [FakerModule.forRoot()],
64-
})
65-
export class AppModule {}
66-
```
67-
68-
O `FakerModule.forRoot()` registra o módulo como **global**, então o `FakerService` fica disponível em toda a aplicação.
69-
70-
### Injetando o FakerService
71-
72-
```typescript
73-
import { Injectable } from '@nestjs/common';
74-
import { FakerService } from '@aldeia/faker-br';
75-
76-
@Injectable()
77-
export class SeedService {
78-
constructor(private readonly faker: FakerService) {}
79-
80-
generateProduct() {
81-
return {
82-
name: this.faker.marketing.headline(),
83-
description: this.faker.marketing.description(),
84-
cta: this.faker.marketing.callToAction(),
85-
};
86-
}
87-
88-
generateNotification() {
89-
return {
90-
success: this.faker.support.successMessage(),
91-
error: this.faker.support.errorMessage(),
92-
};
93-
}
94-
}
95-
```
96-
97-
### Opções do módulo
98-
99-
```typescript
100-
FakerModule.forRoot({
101-
randomSource: () => Math.random(), // Fonte de randomização customizada
102-
})
103-
```
104-
10556
## Módulos disponíveis
10657

10758
| Módulo | Métodos | Descrição |
@@ -120,67 +71,20 @@ Todos os textos ficam em arquivos JSON em `src/data/pt-br/`, facilitando ediçã
12071
- `support.json` — 20 mensagens de cada tipo (success, error, warning, info)
12172
- `whatsapp.json` — 25 casuais, 20 followup, 20 confirmação
12273

123-
## Desenvolvimento
74+
## Contribuindo
12475

12576
```bash
12677
# Instalar dependências
12778
npm install
12879

129-
# Rodar em modo dev
130-
npm run start:dev
131-
132-
# Rodar testes unitários
133-
npm run test
134-
135-
# Rodar testes e2e
136-
npm run test:e2e
80+
# Rodar testes
81+
npm test
13782

13883
# Build
13984
npm run build
14085
```
14186

142-
### Demo API
143-
144-
A aplicação demo expõe os seguintes endpoints:
145-
146-
| Endpoint | Descrição |
147-
|---|---|
148-
| `GET /lorem/sentence` | Frase aleatória |
149-
| `GET /lorem/paragraph` | Parágrafo aleatório |
150-
| `GET /marketing/headline` | Headline de marketing |
151-
| `GET /marketing/description` | Descrição de marketing |
152-
| `GET /marketing/cta` | Call-to-action |
153-
| `GET /support/:type` | Mensagem de suporte (success, error, warning, info) |
154-
| `GET /whatsapp/:type` | Mensagem WhatsApp (casual, followup, confirmation) |
155-
156-
## Estrutura do projeto
157-
158-
```
159-
src/
160-
index.ts # Exports públicos da lib
161-
faker.ts # Factory standalone + singleton
162-
faker.module.ts # NestJS dynamic module
163-
core/
164-
random.ts # Classe Random (int, pickOne, pickMany)
165-
data/
166-
text-data.interface.ts # Interfaces TypeScript
167-
data-loader.ts # Importa e agrupa os JSONs
168-
pt-br/
169-
lorem.json
170-
marketing.json
171-
support.json
172-
whatsapp.json
173-
text/
174-
text.service.ts # FakerService (NestJS injectable)
175-
lorem/
176-
lorem.generator.ts
177-
marketing/
178-
marketing.generator.ts
179-
support/
180-
support.generator.ts
181-
whatsapp/
182-
whatsapp.generator.ts
183-
```
87+
O deploy para o npm é automático via GitHub Actions ao fazer merge na branch `main`.
18488

18589
## Licença
18690

nest-cli.json

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)