create-carlos 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/index.js +45 -0
- package/package.json +18 -0
- package/templates/api-template/.env.example +11 -0
- package/templates/api-template/.gitattributes +6 -0
- package/templates/api-template/docker-compose.yml +27 -0
- package/templates/api-template/package-lock.json +4491 -0
- package/templates/api-template/package.json +44 -0
- package/templates/api-template/prisma/migrations/migration_lock.toml +3 -0
- package/templates/api-template/prisma/schema.prisma +8 -0
- package/templates/api-template/prisma/seed.ts +41 -0
- package/templates/api-template/prisma7.config.ts +9 -0
- package/templates/api-template/src/@types/express/index.d.ts +9 -0
- package/templates/api-template/src/lib/R2Bucket.ts +10 -0
- package/templates/api-template/src/lib/redis.ts +19 -0
- package/templates/api-template/src/prisma/prisma.ts +11 -0
- package/templates/api-template/src/server.ts +9 -0
- package/templates/api-template/tsconfig.json +48 -0
package/index.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
import { intro, outro, text, cancel, isCancel } from "@clack/prompts";
|
|
7
|
+
|
|
8
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
9
|
+
const __dirname = path.dirname(__filename);
|
|
10
|
+
|
|
11
|
+
intro("🚀 Carlos CLI");
|
|
12
|
+
|
|
13
|
+
const projectName = await text({
|
|
14
|
+
message: "Qual o nome do projeto?",
|
|
15
|
+
placeholder: "minha-api",
|
|
16
|
+
validate(value) {
|
|
17
|
+
if (!value) {
|
|
18
|
+
return "Digite um nome para o projeto.";
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (!/^[a-z0-9-_]+$/.test(value)) {
|
|
22
|
+
return "Use apenas letras minúsculas, números, - ou _.";
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
if (isCancel(projectName)) {
|
|
28
|
+
cancel("Operação cancelada.");
|
|
29
|
+
process.exit(0);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const templatePath = path.join(__dirname, "templates", "api-template");
|
|
33
|
+
|
|
34
|
+
const destinationPath = path.join(process.cwd(), projectName);
|
|
35
|
+
|
|
36
|
+
if (fs.existsSync(destinationPath)) {
|
|
37
|
+
cancel(`A pasta "${projectName}" já existe.`);
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
fs.cpSync(templatePath, destinationPath, {
|
|
42
|
+
recursive: true,
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
outro(`🎉 Projeto "${projectName}" criado com sucesso!`);
|
package/package.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "create-carlos",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "CLI para criar projetos Node.js",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"create-carlos": "./index.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"index.js",
|
|
11
|
+
"templates"
|
|
12
|
+
],
|
|
13
|
+
"author": "Carlos Dutra",
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@clack/prompts": "^1.7.0"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Environment variables for the application
|
|
2
|
+
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/postgres"
|
|
3
|
+
JWT_SECRET=
|
|
4
|
+
REDIS_URL="redis://localhost:6379"
|
|
5
|
+
|
|
6
|
+
# R2 Configuration
|
|
7
|
+
R2_ACCOUNT_ID=
|
|
8
|
+
R2_BUCKET_NAME=
|
|
9
|
+
R2_ACCESS_KEY_ID=
|
|
10
|
+
R2_SECRET_ACCESS_KEY=
|
|
11
|
+
R2_ENDPOINT=
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
src/prisma/contract.json linguist-generated
|
|
2
|
+
src/prisma/contract.d.ts linguist-generated
|
|
3
|
+
src/prisma/ops.json linguist-generated
|
|
4
|
+
src/prisma/migration.json linguist-generated
|
|
5
|
+
migrations/snapshots/**/contract.json linguist-generated
|
|
6
|
+
migrations/snapshots/**/contract.d.ts linguist-generated
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
services:
|
|
2
|
+
db:
|
|
3
|
+
image: postgres:18-alpine
|
|
4
|
+
container_name: real-estate-db
|
|
5
|
+
restart: always
|
|
6
|
+
environment:
|
|
7
|
+
POSTGRES_USER: postgres
|
|
8
|
+
POSTGRES_PASSWORD: postgres
|
|
9
|
+
POSTGRES_DB: postgres
|
|
10
|
+
ports:
|
|
11
|
+
- "5432:5432"
|
|
12
|
+
volumes:
|
|
13
|
+
- postgres_data:/var/lib/postgresql
|
|
14
|
+
|
|
15
|
+
redis:
|
|
16
|
+
image: redis:7-alpine
|
|
17
|
+
container_name: real-estate-redis
|
|
18
|
+
restart: always
|
|
19
|
+
ports:
|
|
20
|
+
- "6379:6379"
|
|
21
|
+
volumes:
|
|
22
|
+
- redis_data:/data
|
|
23
|
+
command: redis-server --appendonly yes
|
|
24
|
+
|
|
25
|
+
volumes:
|
|
26
|
+
postgres_data:
|
|
27
|
+
redis_data:
|