@sundaysf/cli-v2 1.0.1 → 1.0.5
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 +178 -178
- package/dist/README.md +178 -178
- package/dist/bin/generators/class.js.map +1 -1
- package/dist/bin/generators/postman.js.map +1 -1
- package/dist/bin/index.js +1 -1
- package/dist/bin/index.js.map +1 -1
- package/dist/templates/backend/.claude/agents/knex-table-implementer.md +113 -113
- package/dist/templates/backend/.claude/agents/sundays-backend-builder.md +70 -70
- package/dist/templates/backend/.claude/settings.local.json +13 -13
- package/dist/templates/backend/.env.example +13 -13
- package/dist/templates/backend/.prettierignore +2 -2
- package/dist/templates/backend/.prettierrc +9 -9
- package/dist/templates/backend/.sundaysrc +7 -0
- package/dist/templates/backend/CLAUDE.md +348 -348
- package/dist/templates/backend/Dockerfile +14 -14
- package/dist/templates/backend/README.md +18 -18
- package/dist/templates/backend/eslint.config.js +20 -20
- package/dist/templates/backend/src/app.ts +34 -34
- package/dist/templates/backend/src/common/config/origins/origins.config.ts +11 -11
- package/dist/templates/backend/src/common/utils/environment.resolver.ts +3 -3
- package/dist/templates/backend/src/common/utils/version.resolver.ts +4 -4
- package/dist/templates/backend/src/controllers/health/health.controller.ts +23 -23
- package/dist/templates/backend/src/middlewares/error/error.middleware.ts +21 -21
- package/dist/templates/backend/src/routes/health/health.router.ts +16 -16
- package/dist/templates/backend/src/routes/index.ts +57 -57
- package/dist/templates/backend/src/server.ts +16 -16
- package/dist/templates/backend/src/types.d.ts +10 -10
- package/dist/templates/backend/tsconfig.json +16 -16
- package/dist/templates/backend-db-sql/.claude/agents/knex-table-implementer.md +114 -114
- package/dist/templates/backend-db-sql/.claude/agents/sundays-backend-builder.md +70 -70
- package/dist/templates/backend-db-sql/.claude/settings.local.json +19 -19
- package/dist/templates/backend-db-sql/.env.example +13 -13
- package/dist/templates/backend-db-sql/.prettierignore +2 -2
- package/dist/templates/backend-db-sql/.prettierrc +9 -9
- package/dist/templates/backend-db-sql/.sundaysrc +7 -0
- package/dist/templates/backend-db-sql/CLAUDE.md +374 -374
- package/dist/templates/backend-db-sql/Dockerfile +17 -17
- package/dist/templates/backend-db-sql/README.md +34 -34
- package/dist/templates/backend-db-sql/db/knexfile.ts +33 -33
- package/dist/templates/backend-db-sql/db/migrations/001_create_sundays_package_version.ts +12 -12
- package/dist/templates/backend-db-sql/db/seeds/001_sundays_package_version_seed.ts +10 -10
- package/dist/templates/backend-db-sql/db/src/KnexConnection.ts +74 -74
- package/dist/templates/backend-db-sql/db/src/d.types.ts +18 -18
- package/dist/templates/backend-db-sql/db/src/dao/sundays-package-version/sundays-package-version.dao.ts +71 -71
- package/dist/templates/backend-db-sql/db/src/index.ts +9 -9
- package/dist/templates/backend-db-sql/db/src/interfaces/sundays-package-version/sundays-package-version.interfaces.ts +6 -6
- package/dist/templates/backend-db-sql/db/tsconfig.json +16 -16
- package/dist/templates/backend-db-sql/eslint.config.js +20 -20
- package/dist/templates/backend-db-sql/src/app.ts +34 -34
- package/dist/templates/backend-db-sql/src/common/config/origins/origins.config.ts +11 -11
- package/dist/templates/backend-db-sql/src/common/utils/environment.resolver.ts +3 -3
- package/dist/templates/backend-db-sql/src/common/utils/version.resolver.ts +4 -4
- package/dist/templates/backend-db-sql/src/controllers/health/health.controller.ts +23 -23
- package/dist/templates/backend-db-sql/src/middlewares/error/error.middleware.ts +21 -21
- package/dist/templates/backend-db-sql/src/routes/health/health.router.ts +16 -16
- package/dist/templates/backend-db-sql/src/routes/index.ts +57 -57
- package/dist/templates/backend-db-sql/src/server.ts +18 -18
- package/dist/templates/backend-db-sql/src/types.d.ts +10 -10
- package/dist/templates/backend-db-sql/tsconfig.json +16 -16
- package/dist/templates/backend-embedded-db-sql/.claude/agents/knex-table-implementer.md +116 -0
- package/dist/templates/backend-embedded-db-sql/.claude/agents/sundays-backend-builder.md +70 -0
- package/dist/templates/backend-embedded-db-sql/.claude/settings.local.json +18 -0
- package/dist/templates/backend-embedded-db-sql/.env.example +14 -0
- package/dist/templates/backend-embedded-db-sql/.prettierignore +3 -0
- package/dist/templates/backend-embedded-db-sql/.prettierrc +9 -0
- package/dist/templates/backend-embedded-db-sql/.sundaysrc +7 -0
- package/dist/templates/backend-embedded-db-sql/CLAUDE.md +371 -0
- package/dist/templates/backend-embedded-db-sql/Dockerfile +14 -0
- package/dist/templates/backend-embedded-db-sql/README.md +32 -0
- package/dist/templates/backend-embedded-db-sql/eslint.config.js +20 -0
- package/dist/templates/backend-embedded-db-sql/knexfile.ts +37 -0
- package/dist/templates/backend-embedded-db-sql/migrations/.gitkeep +0 -0
- package/dist/templates/backend-embedded-db-sql/migrations/001_create_sundays_package_version.ts +13 -0
- package/dist/templates/backend-embedded-db-sql/seeds/001_sundays_package_version_seed.ts +11 -0
- package/dist/templates/backend-embedded-db-sql/src/app.ts +35 -0
- package/dist/templates/backend-embedded-db-sql/src/common/config/origins/origins.config.ts +11 -0
- package/dist/templates/backend-embedded-db-sql/src/common/utils/environment.resolver.ts +4 -0
- package/dist/templates/backend-embedded-db-sql/src/common/utils/version.resolver.ts +5 -0
- package/dist/templates/backend-embedded-db-sql/src/controllers/health/health.controller.ts +24 -0
- package/dist/templates/backend-embedded-db-sql/src/db/KnexConnection.ts +74 -0
- package/dist/templates/backend-embedded-db-sql/src/db/d.types.ts +18 -0
- package/dist/templates/backend-embedded-db-sql/src/db/dao/sundays-package-version/sundays-package-version.dao.ts +71 -0
- package/dist/templates/backend-embedded-db-sql/src/db/index.ts +9 -0
- package/dist/templates/backend-embedded-db-sql/src/db/interfaces/sundays-package-version/sundays-package-version.interfaces.ts +6 -0
- package/dist/templates/backend-embedded-db-sql/src/middlewares/error/error.middleware.ts +21 -0
- package/dist/templates/backend-embedded-db-sql/src/routes/health/health.router.ts +17 -0
- package/dist/templates/backend-embedded-db-sql/src/routes/index.ts +57 -0
- package/dist/templates/backend-embedded-db-sql/src/server.ts +18 -0
- package/dist/templates/backend-embedded-db-sql/src/types.d.ts +10 -0
- package/dist/templates/backend-embedded-db-sql/tsconfig.json +16 -0
- package/dist/templates/db-sql/.claude/agents/knex-table-implementer.md +113 -113
- package/dist/templates/db-sql/.claude/agents/sundays-backend-builder.md +70 -70
- package/dist/templates/db-sql/.claude/settings.local.json +10 -10
- package/dist/templates/db-sql/.env.example +8 -8
- package/dist/templates/db-sql/CLAUDE.md +105 -105
- package/dist/templates/db-sql/knexfile.ts +33 -33
- package/dist/templates/db-sql/migrations/001_create_sundays_package_version.ts +12 -12
- package/dist/templates/db-sql/seeds/001_sundays_package_version_seed.ts +10 -10
- package/dist/templates/db-sql/src/KnexConnection.ts +74 -74
- package/dist/templates/db-sql/src/d.types.ts +18 -18
- package/dist/templates/db-sql/src/dao/sundays-package-version/sundays-package-version.dao.ts +71 -71
- package/dist/templates/db-sql/src/index.ts +9 -9
- package/dist/templates/db-sql/src/interfaces/sundays-package-version/sundays-package-version.interfaces.ts +6 -6
- package/dist/templates/db-sql/tsconfig.json +16 -16
- package/dist/templates/frontend-nextjs/.sundaysrc +7 -0
- package/dist/templates/frontend-nextjs/app/globals.css +125 -0
- package/dist/templates/frontend-nextjs/app/layout.tsx +45 -0
- package/dist/templates/frontend-nextjs/app/page.tsx +5 -0
- package/dist/templates/frontend-nextjs/components/project-generator.tsx +558 -0
- package/dist/templates/frontend-nextjs/components/theme-provider.tsx +11 -0
- package/dist/templates/frontend-nextjs/components/ui/accordion.tsx +66 -0
- package/dist/templates/frontend-nextjs/components/ui/alert-dialog.tsx +157 -0
- package/dist/templates/frontend-nextjs/components/ui/alert.tsx +66 -0
- package/dist/templates/frontend-nextjs/components/ui/aspect-ratio.tsx +11 -0
- package/dist/templates/frontend-nextjs/components/ui/avatar.tsx +53 -0
- package/dist/templates/frontend-nextjs/components/ui/badge.tsx +46 -0
- package/dist/templates/frontend-nextjs/components/ui/breadcrumb.tsx +109 -0
- package/dist/templates/frontend-nextjs/components/ui/button-group.tsx +83 -0
- package/dist/templates/frontend-nextjs/components/ui/button.tsx +60 -0
- package/dist/templates/frontend-nextjs/components/ui/calendar.tsx +213 -0
- package/dist/templates/frontend-nextjs/components/ui/card.tsx +92 -0
- package/dist/templates/frontend-nextjs/components/ui/carousel.tsx +241 -0
- package/dist/templates/frontend-nextjs/components/ui/chart.tsx +353 -0
- package/dist/templates/frontend-nextjs/components/ui/checkbox.tsx +32 -0
- package/dist/templates/frontend-nextjs/components/ui/collapsible.tsx +33 -0
- package/dist/templates/frontend-nextjs/components/ui/command.tsx +184 -0
- package/dist/templates/frontend-nextjs/components/ui/context-menu.tsx +252 -0
- package/dist/templates/frontend-nextjs/components/ui/dialog.tsx +143 -0
- package/dist/templates/frontend-nextjs/components/ui/drawer.tsx +135 -0
- package/dist/templates/frontend-nextjs/components/ui/dropdown-menu.tsx +257 -0
- package/dist/templates/frontend-nextjs/components/ui/empty.tsx +104 -0
- package/dist/templates/frontend-nextjs/components/ui/field.tsx +244 -0
- package/dist/templates/frontend-nextjs/components/ui/form.tsx +167 -0
- package/dist/templates/frontend-nextjs/components/ui/hover-card.tsx +44 -0
- package/dist/templates/frontend-nextjs/components/ui/input-group.tsx +169 -0
- package/dist/templates/frontend-nextjs/components/ui/input-otp.tsx +77 -0
- package/dist/templates/frontend-nextjs/components/ui/input.tsx +21 -0
- package/dist/templates/frontend-nextjs/components/ui/item.tsx +193 -0
- package/dist/templates/frontend-nextjs/components/ui/kbd.tsx +28 -0
- package/dist/templates/frontend-nextjs/components/ui/label.tsx +24 -0
- package/dist/templates/frontend-nextjs/components/ui/menubar.tsx +276 -0
- package/dist/templates/frontend-nextjs/components/ui/navigation-menu.tsx +166 -0
- package/dist/templates/frontend-nextjs/components/ui/pagination.tsx +127 -0
- package/dist/templates/frontend-nextjs/components/ui/popover.tsx +48 -0
- package/dist/templates/frontend-nextjs/components/ui/progress.tsx +31 -0
- package/dist/templates/frontend-nextjs/components/ui/radio-group.tsx +45 -0
- package/dist/templates/frontend-nextjs/components/ui/resizable.tsx +56 -0
- package/dist/templates/frontend-nextjs/components/ui/scroll-area.tsx +58 -0
- package/dist/templates/frontend-nextjs/components/ui/select.tsx +185 -0
- package/dist/templates/frontend-nextjs/components/ui/separator.tsx +28 -0
- package/dist/templates/frontend-nextjs/components/ui/sheet.tsx +139 -0
- package/dist/templates/frontend-nextjs/components/ui/sidebar.tsx +726 -0
- package/dist/templates/frontend-nextjs/components/ui/skeleton.tsx +13 -0
- package/dist/templates/frontend-nextjs/components/ui/slider.tsx +63 -0
- package/dist/templates/frontend-nextjs/components/ui/sonner.tsx +25 -0
- package/dist/templates/frontend-nextjs/components/ui/spinner.tsx +16 -0
- package/dist/templates/frontend-nextjs/components/ui/switch.tsx +31 -0
- package/dist/templates/frontend-nextjs/components/ui/table.tsx +116 -0
- package/dist/templates/frontend-nextjs/components/ui/tabs.tsx +66 -0
- package/dist/templates/frontend-nextjs/components/ui/textarea.tsx +18 -0
- package/dist/templates/frontend-nextjs/components/ui/toast.tsx +129 -0
- package/dist/templates/frontend-nextjs/components/ui/toaster.tsx +35 -0
- package/dist/templates/frontend-nextjs/components/ui/toggle-group.tsx +73 -0
- package/dist/templates/frontend-nextjs/components/ui/toggle.tsx +47 -0
- package/dist/templates/frontend-nextjs/components/ui/tooltip.tsx +61 -0
- package/dist/templates/frontend-nextjs/components/ui/use-mobile.tsx +19 -0
- package/dist/templates/frontend-nextjs/components/ui/use-toast.ts +191 -0
- package/dist/templates/frontend-nextjs/components.json +21 -0
- package/dist/templates/frontend-nextjs/hooks/use-mobile.ts +19 -0
- package/dist/templates/frontend-nextjs/hooks/use-toast.ts +191 -0
- package/dist/templates/frontend-nextjs/lib/utils.ts +6 -0
- package/dist/templates/frontend-nextjs/next.config.mjs +11 -0
- package/dist/templates/frontend-nextjs/postcss.config.mjs +8 -0
- package/dist/templates/frontend-nextjs/public/apple-icon.png +0 -0
- package/dist/templates/frontend-nextjs/public/icon-dark-32x32.png +0 -0
- package/dist/templates/frontend-nextjs/public/icon-light-32x32.png +0 -0
- package/dist/templates/frontend-nextjs/public/icon.svg +26 -0
- package/dist/templates/frontend-nextjs/public/placeholder-logo.png +0 -0
- package/dist/templates/frontend-nextjs/public/placeholder-logo.svg +1 -0
- package/dist/templates/frontend-nextjs/public/placeholder-user.jpg +0 -0
- package/dist/templates/frontend-nextjs/public/placeholder.jpg +0 -0
- package/dist/templates/frontend-nextjs/public/placeholder.svg +1 -0
- package/dist/templates/frontend-nextjs/styles/globals.css +125 -0
- package/dist/templates/frontend-nextjs/tsconfig.json +27 -0
- package/dist/templates/module/.claude/agents/knex-table-implementer.md +113 -113
- package/dist/templates/module/.claude/agents/sundays-backend-builder.md +70 -70
- package/dist/templates/module/.claude/settings.local.json +10 -10
- package/dist/templates/module/CLAUDE.md +158 -158
- package/dist/templates/module/src/index.ts +9 -9
- package/dist/templates/module/tsconfig.json +19 -19
- package/package.json +40 -40
package/dist/README.md
CHANGED
|
@@ -1,178 +1,178 @@
|
|
|
1
|
-
# 🚀 Sundays Framework - The Backend Architect's Dream
|
|
2
|
-
|
|
3
|
-
> *"Why waste weekdays struggling with boilerplate when you can build like it's Sunday?"* - Paul Sundays
|
|
4
|
-
|
|
5
|
-
Welcome to **Sundays Framework**, where backend development meets architectural elegance. Created by Paul Sundays, your personal backend architect, this framework transforms the way you build scalable, production-ready applications.
|
|
6
|
-
|
|
7
|
-
## 🌟 Why Sundays Framework?
|
|
8
|
-
|
|
9
|
-
In a world of complex setups and endless configurations, Sundays Framework stands as your beacon of simplicity and power. We believe that great architecture shouldn't require a PhD to implement. That's why we've crafted every line of code with love, ensuring you spend less time configuring and more time creating.
|
|
10
|
-
|
|
11
|
-
### ✨ Features That Make Every Day Feel Like Sunday
|
|
12
|
-
|
|
13
|
-
- **🏗️ Zero-Config Architecture**: Start building in seconds, not hours
|
|
14
|
-
- **🎯 Type-Safe Everything**: TypeScript-first approach for bulletproof code
|
|
15
|
-
- **⚡ Lightning Fast Setup**: From zero to API in under 60 seconds
|
|
16
|
-
- **🔧 Smart Code Generation**: Controllers, routes, and DAOs created automagically
|
|
17
|
-
- **📦 Production-Ready**: Docker, migrations, and best practices out of the box
|
|
18
|
-
- **🎨 Clean Code Philosophy**: Because beautiful code is maintainable code
|
|
19
|
-
|
|
20
|
-
## 🎯 Quick Start - Your Sunday Begins Now
|
|
21
|
-
|
|
22
|
-
Paul Sundays here! Let me guide you through the smoothest setup experience you've ever had. Choose your adventure:
|
|
23
|
-
|
|
24
|
-
### 🏃♂️ Backend API Template
|
|
25
|
-
```bash
|
|
26
|
-
npx @sundaysf/cli --init --backend
|
|
27
|
-
```
|
|
28
|
-
*Perfect for REST APIs, microservices, and full-stack backends*
|
|
29
|
-
|
|
30
|
-
### 🗄️ Database SQL Module
|
|
31
|
-
```bash
|
|
32
|
-
npx @sundaysf/cli --init --db-sql
|
|
33
|
-
```
|
|
34
|
-
*Ideal for database layers with Knex.js, migrations, and seeds*
|
|
35
|
-
|
|
36
|
-
### 📦 Basic Module Template
|
|
37
|
-
```bash
|
|
38
|
-
npx @sundaysf/cli --init --module
|
|
39
|
-
```
|
|
40
|
-
*Great for npm packages and shared libraries*
|
|
41
|
-
|
|
42
|
-
> **Pro tip from Paul**: Each template comes pre-configured with everything you need. No more "how do I structure this?" moments!
|
|
43
|
-
## ⚙️ Configuration - Set It and Forget It
|
|
44
|
-
|
|
45
|
-
After initialization, you'll find a `.env.example` file. Simply:
|
|
46
|
-
|
|
47
|
-
```bash
|
|
48
|
-
cp .env.example .env
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
Customize your environment variables, and you're ready to rock! The framework handles the rest with sensible defaults.
|
|
52
|
-
|
|
53
|
-
## 🎨 Magic Controller Generation
|
|
54
|
-
|
|
55
|
-
Watch as Paul Sundays works his magic! Need a new feature? Let's create a controller with all CRUD operations in seconds:
|
|
56
|
-
|
|
57
|
-
```bash
|
|
58
|
-
npm run create:controller
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
### What You Get:
|
|
62
|
-
- ✅ **Full CRUD Operations**: GET, GET by UUID, CREATE, UPDATE, DELETE
|
|
63
|
-
- ✅ **Type-Safe Routes**: Automatically generated with proper TypeScript types
|
|
64
|
-
- ✅ **Postman Collection**: API documentation generated on the fly
|
|
65
|
-
- ✅ **Best Practices**: Error handling, validation, and clean architecture
|
|
66
|
-
|
|
67
|
-
> **Paul's Secret**: Each controller follows the same battle-tested patterns I've refined over years of Sunday coding sessions!
|
|
68
|
-
|
|
69
|
-
## 🛠️ Development Commands - Your Sunday Toolkit
|
|
70
|
-
|
|
71
|
-
### 🔥 Development Mode
|
|
72
|
-
```bash
|
|
73
|
-
npm run start:dev
|
|
74
|
-
```
|
|
75
|
-
*Hot-reloading enabled! Code like the wind, see changes instantly.*
|
|
76
|
-
|
|
77
|
-
### 🏗️ Build for Production
|
|
78
|
-
```bash
|
|
79
|
-
npm run build
|
|
80
|
-
```
|
|
81
|
-
*TypeScript → JavaScript transformation with optimization magic.*
|
|
82
|
-
|
|
83
|
-
### 🚀 Production Server
|
|
84
|
-
```bash
|
|
85
|
-
npm run start
|
|
86
|
-
```
|
|
87
|
-
*Battle-tested, production-ready, and blazing fast.*
|
|
88
|
-
|
|
89
|
-
### 🗄️ Database Commands (db-sql template)
|
|
90
|
-
```bash
|
|
91
|
-
npm run migrate:create # Create a new migration
|
|
92
|
-
npm run migrate:deploy # Run pending migrations
|
|
93
|
-
npm run seed:create # Create a new seed file
|
|
94
|
-
npm run seed:run # Populate your database
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
### 🎯 Code Quality
|
|
98
|
-
```bash
|
|
99
|
-
npm run format # Prettier auto-formatting
|
|
100
|
-
npm run lint # ESLint code analysis
|
|
101
|
-
npm test # Run your test suite
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
## 🐳 Docker Support - Ship It Like a Pro
|
|
105
|
-
|
|
106
|
-
Paul Sundays believes in shipping with confidence. That's why every backend template includes a production-ready Dockerfile!
|
|
107
|
-
|
|
108
|
-
### 📦 Build Your Container
|
|
109
|
-
```bash
|
|
110
|
-
docker build -t my-sunday-api .
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
### 🚢 Launch to the Cloud
|
|
114
|
-
```bash
|
|
115
|
-
docker run -p 3098:3098 my-sunday-api
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
### 🎯 Docker Compose Ready
|
|
119
|
-
```yaml
|
|
120
|
-
version: '3.8'
|
|
121
|
-
services:
|
|
122
|
-
api:
|
|
123
|
-
build: .
|
|
124
|
-
ports:
|
|
125
|
-
- "3098:3098"
|
|
126
|
-
environment:
|
|
127
|
-
- NODE_ENV=production
|
|
128
|
-
volumes:
|
|
129
|
-
- ./logs:/app/logs
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
## 🏗️ Project Structure - Organized Like Sunday Brunch
|
|
133
|
-
|
|
134
|
-
```
|
|
135
|
-
your-project/
|
|
136
|
-
├── src/
|
|
137
|
-
│ ├── controllers/ # Your business logic lives here
|
|
138
|
-
│ ├── routes/ # RESTful route definitions
|
|
139
|
-
│ ├── services/ # Reusable service layer
|
|
140
|
-
│ ├── middlewares/ # Express middleware magic
|
|
141
|
-
│ ├── dao/ # Data Access Objects (db-sql)
|
|
142
|
-
│ └── interfaces/ # TypeScript interfaces
|
|
143
|
-
├── migrations/ # Database evolution scripts
|
|
144
|
-
├── seeds/ # Sample data for development
|
|
145
|
-
├── dist/ # Compiled production code
|
|
146
|
-
└── postman.json # Auto-generated API docs
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
## 🎓 Philosophy - The Sunday Way
|
|
150
|
-
|
|
151
|
-
**"Code on Sundays, Deploy on Mondays"**
|
|
152
|
-
|
|
153
|
-
We believe that:
|
|
154
|
-
- 🌟 **Simplicity is the ultimate sophistication**
|
|
155
|
-
- 🎯 **Convention over configuration saves lives**
|
|
156
|
-
- 🚀 **Developer experience is user experience**
|
|
157
|
-
- 💪 **Great frameworks empower, not constrain**
|
|
158
|
-
|
|
159
|
-
## 🤝 Join the Sunday Revolution
|
|
160
|
-
|
|
161
|
-
Created with ❤️ by Paul Sundays, your backend architect who believes every developer deserves tools that spark joy.
|
|
162
|
-
|
|
163
|
-
### 🌐 Connect with Paul
|
|
164
|
-
- 📧 Feedback: Create an issue and let's make Sundays even better!
|
|
165
|
-
- 🐛 Found a bug? You've discovered a weekday trying to sneak in!
|
|
166
|
-
- 💡 Have an idea? Sunday brainstorming sessions are the best!
|
|
167
|
-
|
|
168
|
-
## 📜 License
|
|
169
|
-
|
|
170
|
-
MIT License - Because Sundays are meant to be free!
|
|
171
|
-
|
|
172
|
-
---
|
|
173
|
-
|
|
174
|
-
*Remember: When you code with Sundays Framework, every day feels like the weekend. Now go build something amazing!*
|
|
175
|
-
|
|
176
|
-
**Happy Sunday Coding! 🎉**
|
|
177
|
-
|
|
178
|
-
*- Paul Sundays, Your Backend Architect*
|
|
1
|
+
# 🚀 Sundays Framework - The Backend Architect's Dream
|
|
2
|
+
|
|
3
|
+
> *"Why waste weekdays struggling with boilerplate when you can build like it's Sunday?"* - Paul Sundays
|
|
4
|
+
|
|
5
|
+
Welcome to **Sundays Framework**, where backend development meets architectural elegance. Created by Paul Sundays, your personal backend architect, this framework transforms the way you build scalable, production-ready applications.
|
|
6
|
+
|
|
7
|
+
## 🌟 Why Sundays Framework?
|
|
8
|
+
|
|
9
|
+
In a world of complex setups and endless configurations, Sundays Framework stands as your beacon of simplicity and power. We believe that great architecture shouldn't require a PhD to implement. That's why we've crafted every line of code with love, ensuring you spend less time configuring and more time creating.
|
|
10
|
+
|
|
11
|
+
### ✨ Features That Make Every Day Feel Like Sunday
|
|
12
|
+
|
|
13
|
+
- **🏗️ Zero-Config Architecture**: Start building in seconds, not hours
|
|
14
|
+
- **🎯 Type-Safe Everything**: TypeScript-first approach for bulletproof code
|
|
15
|
+
- **⚡ Lightning Fast Setup**: From zero to API in under 60 seconds
|
|
16
|
+
- **🔧 Smart Code Generation**: Controllers, routes, and DAOs created automagically
|
|
17
|
+
- **📦 Production-Ready**: Docker, migrations, and best practices out of the box
|
|
18
|
+
- **🎨 Clean Code Philosophy**: Because beautiful code is maintainable code
|
|
19
|
+
|
|
20
|
+
## 🎯 Quick Start - Your Sunday Begins Now
|
|
21
|
+
|
|
22
|
+
Paul Sundays here! Let me guide you through the smoothest setup experience you've ever had. Choose your adventure:
|
|
23
|
+
|
|
24
|
+
### 🏃♂️ Backend API Template
|
|
25
|
+
```bash
|
|
26
|
+
npx @sundaysf/cli --init --backend
|
|
27
|
+
```
|
|
28
|
+
*Perfect for REST APIs, microservices, and full-stack backends*
|
|
29
|
+
|
|
30
|
+
### 🗄️ Database SQL Module
|
|
31
|
+
```bash
|
|
32
|
+
npx @sundaysf/cli --init --db-sql
|
|
33
|
+
```
|
|
34
|
+
*Ideal for database layers with Knex.js, migrations, and seeds*
|
|
35
|
+
|
|
36
|
+
### 📦 Basic Module Template
|
|
37
|
+
```bash
|
|
38
|
+
npx @sundaysf/cli --init --module
|
|
39
|
+
```
|
|
40
|
+
*Great for npm packages and shared libraries*
|
|
41
|
+
|
|
42
|
+
> **Pro tip from Paul**: Each template comes pre-configured with everything you need. No more "how do I structure this?" moments!
|
|
43
|
+
## ⚙️ Configuration - Set It and Forget It
|
|
44
|
+
|
|
45
|
+
After initialization, you'll find a `.env.example` file. Simply:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
cp .env.example .env
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Customize your environment variables, and you're ready to rock! The framework handles the rest with sensible defaults.
|
|
52
|
+
|
|
53
|
+
## 🎨 Magic Controller Generation
|
|
54
|
+
|
|
55
|
+
Watch as Paul Sundays works his magic! Need a new feature? Let's create a controller with all CRUD operations in seconds:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
npm run create:controller
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### What You Get:
|
|
62
|
+
- ✅ **Full CRUD Operations**: GET, GET by UUID, CREATE, UPDATE, DELETE
|
|
63
|
+
- ✅ **Type-Safe Routes**: Automatically generated with proper TypeScript types
|
|
64
|
+
- ✅ **Postman Collection**: API documentation generated on the fly
|
|
65
|
+
- ✅ **Best Practices**: Error handling, validation, and clean architecture
|
|
66
|
+
|
|
67
|
+
> **Paul's Secret**: Each controller follows the same battle-tested patterns I've refined over years of Sunday coding sessions!
|
|
68
|
+
|
|
69
|
+
## 🛠️ Development Commands - Your Sunday Toolkit
|
|
70
|
+
|
|
71
|
+
### 🔥 Development Mode
|
|
72
|
+
```bash
|
|
73
|
+
npm run start:dev
|
|
74
|
+
```
|
|
75
|
+
*Hot-reloading enabled! Code like the wind, see changes instantly.*
|
|
76
|
+
|
|
77
|
+
### 🏗️ Build for Production
|
|
78
|
+
```bash
|
|
79
|
+
npm run build
|
|
80
|
+
```
|
|
81
|
+
*TypeScript → JavaScript transformation with optimization magic.*
|
|
82
|
+
|
|
83
|
+
### 🚀 Production Server
|
|
84
|
+
```bash
|
|
85
|
+
npm run start
|
|
86
|
+
```
|
|
87
|
+
*Battle-tested, production-ready, and blazing fast.*
|
|
88
|
+
|
|
89
|
+
### 🗄️ Database Commands (db-sql template)
|
|
90
|
+
```bash
|
|
91
|
+
npm run migrate:create # Create a new migration
|
|
92
|
+
npm run migrate:deploy # Run pending migrations
|
|
93
|
+
npm run seed:create # Create a new seed file
|
|
94
|
+
npm run seed:run # Populate your database
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### 🎯 Code Quality
|
|
98
|
+
```bash
|
|
99
|
+
npm run format # Prettier auto-formatting
|
|
100
|
+
npm run lint # ESLint code analysis
|
|
101
|
+
npm test # Run your test suite
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## 🐳 Docker Support - Ship It Like a Pro
|
|
105
|
+
|
|
106
|
+
Paul Sundays believes in shipping with confidence. That's why every backend template includes a production-ready Dockerfile!
|
|
107
|
+
|
|
108
|
+
### 📦 Build Your Container
|
|
109
|
+
```bash
|
|
110
|
+
docker build -t my-sunday-api .
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### 🚢 Launch to the Cloud
|
|
114
|
+
```bash
|
|
115
|
+
docker run -p 3098:3098 my-sunday-api
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### 🎯 Docker Compose Ready
|
|
119
|
+
```yaml
|
|
120
|
+
version: '3.8'
|
|
121
|
+
services:
|
|
122
|
+
api:
|
|
123
|
+
build: .
|
|
124
|
+
ports:
|
|
125
|
+
- "3098:3098"
|
|
126
|
+
environment:
|
|
127
|
+
- NODE_ENV=production
|
|
128
|
+
volumes:
|
|
129
|
+
- ./logs:/app/logs
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## 🏗️ Project Structure - Organized Like Sunday Brunch
|
|
133
|
+
|
|
134
|
+
```
|
|
135
|
+
your-project/
|
|
136
|
+
├── src/
|
|
137
|
+
│ ├── controllers/ # Your business logic lives here
|
|
138
|
+
│ ├── routes/ # RESTful route definitions
|
|
139
|
+
│ ├── services/ # Reusable service layer
|
|
140
|
+
│ ├── middlewares/ # Express middleware magic
|
|
141
|
+
│ ├── dao/ # Data Access Objects (db-sql)
|
|
142
|
+
│ └── interfaces/ # TypeScript interfaces
|
|
143
|
+
├── migrations/ # Database evolution scripts
|
|
144
|
+
├── seeds/ # Sample data for development
|
|
145
|
+
├── dist/ # Compiled production code
|
|
146
|
+
└── postman.json # Auto-generated API docs
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## 🎓 Philosophy - The Sunday Way
|
|
150
|
+
|
|
151
|
+
**"Code on Sundays, Deploy on Mondays"**
|
|
152
|
+
|
|
153
|
+
We believe that:
|
|
154
|
+
- 🌟 **Simplicity is the ultimate sophistication**
|
|
155
|
+
- 🎯 **Convention over configuration saves lives**
|
|
156
|
+
- 🚀 **Developer experience is user experience**
|
|
157
|
+
- 💪 **Great frameworks empower, not constrain**
|
|
158
|
+
|
|
159
|
+
## 🤝 Join the Sunday Revolution
|
|
160
|
+
|
|
161
|
+
Created with ❤️ by Paul Sundays, your backend architect who believes every developer deserves tools that spark joy.
|
|
162
|
+
|
|
163
|
+
### 🌐 Connect with Paul
|
|
164
|
+
- 📧 Feedback: Create an issue and let's make Sundays even better!
|
|
165
|
+
- 🐛 Found a bug? You've discovered a weekday trying to sneak in!
|
|
166
|
+
- 💡 Have an idea? Sunday brainstorming sessions are the best!
|
|
167
|
+
|
|
168
|
+
## 📜 License
|
|
169
|
+
|
|
170
|
+
MIT License - Because Sundays are meant to be free!
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
*Remember: When you code with Sundays Framework, every day feels like the weekend. Now go build something amazing!*
|
|
175
|
+
|
|
176
|
+
**Happy Sunday Coding! 🎉**
|
|
177
|
+
|
|
178
|
+
*- Paul Sundays, Your Backend Architect*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"class.js","names":["generateController","className","generateRouter","controllerClassName","controllerDirectoryName"],"sources":["bin/generators/class.js"],"mappings":"OAAO,MAAMA,mBAAsBC,GACV,wJAIFA,gwEAwEhB,MAAMC,eAAiB,CAACD,EAAWE,EAAqBC,IACtC,iEAEND,+BAAiDC,KAA2BA,0CAExEH,kEAEAG,qBAA2CD,wNAMpBC,iCAAuDA,oEAClDA,oCAA0DA,oEAC1DA,iCAAuDA,sEACrDA,gCAAsDA,gEAC5DA,iCAAuDA,uEAChDA,iCAAuDA","ignoreList":[],"sourcesContent":["export const generateController = (className) => {\n const classContent = `\n import { Request, Response, NextFunction } from 'express';\n import { IBaseController } from '../../types';\n\n export class ${className} implements IBaseController{\n\n public async getAll(req: Request, res: Response, next: NextFunction): Promise<void>{\n try{\n // TODO: implement\n res.status(200).json({ success: true, data: [] });\n }catch(err: unknown){\n next(err);\n }\n }\n\n public async getByUuid(req: Request, res: Response, next: NextFunction): Promise<void>{\n try{\n const { uuid } = req.params;\n // TODO: implement\n res.status(200).json({ success: true, data: null });\n }catch(err: unknown){\n next(err);\n }\n }\n\n public async update(req: Request, res: Response, next: NextFunction): Promise<void>{\n try{\n const { uuid } = req.params;\n // TODO: implement\n res.status(200).json({ success: true, data: null });\n }catch(err: unknown){\n next(err);\n }\n }\n\n public async patch(req: Request, res: Response, next: NextFunction): Promise<void>{\n try{\n const { uuid } = req.params;\n // TODO: implement\n res.status(200).json({ success: true, data: null });\n }catch(err: unknown){\n next(err);\n }\n }\n\n public async create(req: Request, res: Response, next: NextFunction): Promise<void>{\n try{\n // TODO: implement\n res.status(201).json({ success: true, data: null });\n }catch(err: unknown){\n next(err);\n }\n }\n\n public async delete(req: Request, res: Response, next: NextFunction): Promise<void>{\n try{\n const { uuid } = req.params;\n // TODO: implement\n res.status(200).json({ success: true, data: null });\n }catch(err: unknown){\n next(err);\n }\n }\n }\n\n `\n return classContent;\n}\n\n/**\n *\n * @param {String} className\n * @param {String} controllerClassName\n * @param {String} controllerDirectoryName\n * @returns {String}\n */\nexport const generateRouter = (className, controllerClassName, controllerDirectoryName) => {\n const classContent = `\n import { Router } from 'express';\n import { ${controllerClassName} } from '../../controllers/${controllerDirectoryName}/${controllerDirectoryName}.controller';\n\n export class ${className}{\n private _router: Router;\n private _${controllerDirectoryName}Controller = new ${controllerClassName}();\n constructor(){\n this._router = Router();\n this.initRoutes();\n }\n private initRoutes(): void {\n this._router.get(\"/\", this._${controllerDirectoryName}Controller.getAll.bind(this._${controllerDirectoryName}Controller));\n this._router.get(\"/:uuid\", this._${controllerDirectoryName}Controller.getByUuid.bind(this._${controllerDirectoryName}Controller));\n this._router.put(\"/:uuid\", this._${controllerDirectoryName}Controller.update.bind(this._${controllerDirectoryName}Controller));\n this._router.patch(\"/:uuid\", this._${controllerDirectoryName}Controller.patch.bind(this._${controllerDirectoryName}Controller));\n this._router.post(\"/\", this._${controllerDirectoryName}Controller.create.bind(this._${controllerDirectoryName}Controller));\n this._router.delete(\"/:uuid\", this._${controllerDirectoryName}Controller.delete.bind(this._${controllerDirectoryName}Controller));\n }\n public get router(): Router {\n return this._router;\n }\n }\n\n `\n return classContent;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"class.js","names":["generateController","className","generateRouter","controllerClassName","controllerDirectoryName"],"sources":["bin/generators/class.js"],"mappings":"OAAO,MAAMA,mBAAsBC,GACV,wJAIFA,gwEAwEhB,MAAMC,eAAiB,CAACD,EAAWE,EAAqBC,IACtC,iEAEND,+BAAiDC,KAA2BA,0CAExEH,kEAEAG,qBAA2CD,wNAMpBC,iCAAuDA,oEAClDA,oCAA0DA,oEAC1DA,iCAAuDA,sEACrDA,gCAAsDA,gEAC5DA,iCAAuDA,uEAChDA,iCAAuDA","ignoreList":[],"sourcesContent":["export const generateController = (className) => {\r\n const classContent = `\r\n import { Request, Response, NextFunction } from 'express';\r\n import { IBaseController } from '../../types';\r\n\r\n export class ${className} implements IBaseController{\r\n\r\n public async getAll(req: Request, res: Response, next: NextFunction): Promise<void>{\r\n try{\r\n // TODO: implement\r\n res.status(200).json({ success: true, data: [] });\r\n }catch(err: unknown){\r\n next(err);\r\n }\r\n }\r\n\r\n public async getByUuid(req: Request, res: Response, next: NextFunction): Promise<void>{\r\n try{\r\n const { uuid } = req.params;\r\n // TODO: implement\r\n res.status(200).json({ success: true, data: null });\r\n }catch(err: unknown){\r\n next(err);\r\n }\r\n }\r\n\r\n public async update(req: Request, res: Response, next: NextFunction): Promise<void>{\r\n try{\r\n const { uuid } = req.params;\r\n // TODO: implement\r\n res.status(200).json({ success: true, data: null });\r\n }catch(err: unknown){\r\n next(err);\r\n }\r\n }\r\n\r\n public async patch(req: Request, res: Response, next: NextFunction): Promise<void>{\r\n try{\r\n const { uuid } = req.params;\r\n // TODO: implement\r\n res.status(200).json({ success: true, data: null });\r\n }catch(err: unknown){\r\n next(err);\r\n }\r\n }\r\n\r\n public async create(req: Request, res: Response, next: NextFunction): Promise<void>{\r\n try{\r\n // TODO: implement\r\n res.status(201).json({ success: true, data: null });\r\n }catch(err: unknown){\r\n next(err);\r\n }\r\n }\r\n\r\n public async delete(req: Request, res: Response, next: NextFunction): Promise<void>{\r\n try{\r\n const { uuid } = req.params;\r\n // TODO: implement\r\n res.status(200).json({ success: true, data: null });\r\n }catch(err: unknown){\r\n next(err);\r\n }\r\n }\r\n }\r\n\r\n `\r\n return classContent;\r\n}\r\n\r\n/**\r\n *\r\n * @param {String} className\r\n * @param {String} controllerClassName\r\n * @param {String} controllerDirectoryName\r\n * @returns {String}\r\n */\r\nexport const generateRouter = (className, controllerClassName, controllerDirectoryName) => {\r\n const classContent = `\r\n import { Router } from 'express';\r\n import { ${controllerClassName} } from '../../controllers/${controllerDirectoryName}/${controllerDirectoryName}.controller';\r\n\r\n export class ${className}{\r\n private _router: Router;\r\n private _${controllerDirectoryName}Controller = new ${controllerClassName}();\r\n constructor(){\r\n this._router = Router();\r\n this.initRoutes();\r\n }\r\n private initRoutes(): void {\r\n this._router.get(\"/\", this._${controllerDirectoryName}Controller.getAll.bind(this._${controllerDirectoryName}Controller));\r\n this._router.get(\"/:uuid\", this._${controllerDirectoryName}Controller.getByUuid.bind(this._${controllerDirectoryName}Controller));\r\n this._router.put(\"/:uuid\", this._${controllerDirectoryName}Controller.update.bind(this._${controllerDirectoryName}Controller));\r\n this._router.patch(\"/:uuid\", this._${controllerDirectoryName}Controller.patch.bind(this._${controllerDirectoryName}Controller));\r\n this._router.post(\"/\", this._${controllerDirectoryName}Controller.create.bind(this._${controllerDirectoryName}Controller));\r\n this._router.delete(\"/:uuid\", this._${controllerDirectoryName}Controller.delete.bind(this._${controllerDirectoryName}Controller));\r\n }\r\n public get router(): Router {\r\n return this._router;\r\n }\r\n }\r\n\r\n `\r\n return classContent;\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postman.js","names":["toCamel","uuidv4","generateBasePostman","projectName","baseData","info","_postman_id","name","schema","item","event","listen","script","type","packages","exec","variable","key","value","getItemFormatted","controllerDirectoryName","authBearer","bearer","makeUrl","pathSuffix","variables","raw","pathParts","push","replace","url","host","path","length","uuidVariable","jsonBody","mode","options","language","request","auth","method","header","response","body"],"sources":["bin/generators/postman.js"],"mappings":"OAASA,YAAe,+BACTC,WAAc,cAEtB,MAAMC,oBAAuBC,IAChC,MAAMC,EAAW,CAAC,EAyClB,OAxCAA,EAASC,KAAO,CACZC,YAAaL,SACbM,KAAMJ,EACNK,OAAQ,wEAEZJ,EAASK,KAAO,GAChBL,EAASM,MAAQ,CACb,CACIC,OAAU,aACVC,OAAU,CACNC,KAAQ,kBACRC,SAAY,CAAC,EACbC,KAAQ,CACJ,MAIZ,CACIJ,OAAU,OACVC,OAAU,CACNC,KAAQ,kBACRC,SAAY,CAAC,EACbC,KAAQ,CACJ,OAKhBX,EAASY,SAAW,CAChB,CACIC,IAAO,GAAGjB,QAAQG,gBAClBe,MAAS,0BACTL,KAAQ,UAEZ,CACII,IAAO,GAAGjB,QAAQG,gBAClBe,MAAS,UACTL,KAAQ,WAGTT,CAAQ,SASZ,MAAMe,iBAAmB,CAACC,EAAyBjB,KACtD,MAAMkB,EAAa,CACfR,KAAQ,SACRS,OAAU,CACN,CACIL,IAAO,QACPC,MAAS,KAAKlB,QAAQG,kBACtBU,KAAQ,YAKdU,EAAU,CAACC,EAAa,GAAIC,EAAY,MAC1C,MAAMC,EAAM,KAAK1B,QAAQG,uBAAiCiB,IAA0BI,IAC9EG,EAAY,CAAC,MAAOP,GACtBI,GAAYG,EAAUC,KAAKJ,EAAWK,QAAQ,IAAK,KAEvD,MAAMC,EAAM,CACRJ,MACAK,KAAQ,CAAC,KAAK/B,QAAQG,mBACtB6B,KAAQL,GAGZ,OADIF,EAAUQ,OAAS,IAAGH,EAAId,SAAWS,GAClCK,CAAG,EAGRI,EAAe,CAAC,CAAEjB,IAAO,OAAQC,MAAS,WAC1CiB,EAAW,CACbC,KAAQ,MACRV,IAAO,KACPW,QAAW,CAAEX,IAAO,CAAEY,SAAY,UAGtC,MAAO,CACH/B,KAAQa,EACRX,KAAQ,CACJ,CACIF,KAAQ,UACRgC,QAAW,CACPC,KAAQnB,EACRoB,OAAU,MACVC,OAAU,GACVZ,IAAOP,KAEXoB,SAAY,IAEhB,CACIpC,KAAQ,cACRgC,QAAW,CACPC,KAAQnB,EACRoB,OAAU,MACVC,OAAU,GACVZ,IAAOP,EAAQ,SAAUW,IAE7BS,SAAY,IAEhB,CACIpC,KAAQ,SACRgC,QAAW,CACPC,KAAQnB,EACRoB,OAAU,OACVC,OAAU,GACVE,KAAQT,EACRL,IAAOP,KAEXoB,SAAY,IAEhB,CACIpC,KAAQ,SACRgC,QAAW,CACPC,KAAQnB,EACRoB,OAAU,MACVC,OAAU,GACVE,KAAQT,EACRL,IAAOP,EAAQ,SAAUW,IAE7BS,SAAY,IAEhB,CACIpC,KAAQ,QACRgC,QAAW,CACPC,KAAQnB,EACRoB,OAAU,QACVC,OAAU,GACVE,KAAQT,EACRL,IAAOP,EAAQ,SAAUW,IAE7BS,SAAY,IAEhB,CACIpC,KAAQ,SACRgC,QAAW,CACPC,KAAQnB,EACRoB,OAAU,SACVC,OAAU,GACVZ,IAAOP,EAAQ,SAAUW,IAE7BS,SAAY,KAGxB","ignoreList":[],"sourcesContent":["import { toCamel } from 'ts-case-convert';\nimport { v4 as uuidv4 } from 'uuid';\n\nexport const generateBasePostman = (projectName) => {\n const baseData = {}\n baseData.info = {\n _postman_id: uuidv4(),\n name: projectName,\n schema: \"https://schema.getpostman.com/json/collection/v2.1.0/collection.json\"\n };\n baseData.item = [];\n baseData.event = [\n {\n \"listen\": \"prerequest\",\n \"script\": {\n \"type\": \"text/javascript\",\n \"packages\": {},\n \"exec\": [\n \"\"\n ]\n }\n },\n {\n \"listen\": \"test\",\n \"script\": {\n \"type\": \"text/javascript\",\n \"packages\": {},\n \"exec\": [\n \"\"\n ]\n }\n }\n ];\n baseData.variable = [\n {\n \"key\": `${toCamel(projectName)}BackendHost`,\n \"value\": \"http://localhost:<PORT>\",\n \"type\": \"string\"\n },\n {\n \"key\": `${toCamel(projectName)}BearerToken`,\n \"value\": \"<token>\",\n \"type\": \"string\"\n }\n ];\n return baseData;\n}\n\n/**\n *\n * @param {String} controllerDirectoryName\n * @param {String} projectName\n * @returns {Object}\n */\nexport const getItemFormatted = (controllerDirectoryName, projectName) => {\n const authBearer = {\n \"type\": \"bearer\",\n \"bearer\": [\n {\n \"key\": \"token\",\n \"value\": `{{${toCamel(projectName)}BearerToken}}`,\n \"type\": \"string\"\n }\n ]\n };\n\n const makeUrl = (pathSuffix = '', variables = []) => {\n const raw = `{{${toCamel(projectName)}BackendHost}}/api/${controllerDirectoryName}${pathSuffix}`;\n const pathParts = [\"api\", controllerDirectoryName];\n if (pathSuffix) pathParts.push(pathSuffix.replace('/', ''));\n\n const url = {\n raw,\n \"host\": [`{{${toCamel(projectName)}BackendHost}}`],\n \"path\": pathParts\n };\n if (variables.length > 0) url.variable = variables;\n return url;\n };\n\n const uuidVariable = [{ \"key\": \"uuid\", \"value\": \"<uuid>\" }];\n const jsonBody = {\n \"mode\": \"raw\",\n \"raw\": \"{}\",\n \"options\": { \"raw\": { \"language\": \"json\" } }\n };\n\n return {\n \"name\": controllerDirectoryName,\n \"item\": [\n {\n \"name\": \"GET ALL\",\n \"request\": {\n \"auth\": authBearer,\n \"method\": \"GET\",\n \"header\": [],\n \"url\": makeUrl()\n },\n \"response\": []\n },\n {\n \"name\": \"GET BY UUID\",\n \"request\": {\n \"auth\": authBearer,\n \"method\": \"GET\",\n \"header\": [],\n \"url\": makeUrl(\"/:uuid\", uuidVariable)\n },\n \"response\": []\n },\n {\n \"name\": \"CREATE\",\n \"request\": {\n \"auth\": authBearer,\n \"method\": \"POST\",\n \"header\": [],\n \"body\": jsonBody,\n \"url\": makeUrl()\n },\n \"response\": []\n },\n {\n \"name\": \"UPDATE\",\n \"request\": {\n \"auth\": authBearer,\n \"method\": \"PUT\",\n \"header\": [],\n \"body\": jsonBody,\n \"url\": makeUrl(\"/:uuid\", uuidVariable)\n },\n \"response\": []\n },\n {\n \"name\": \"PATCH\",\n \"request\": {\n \"auth\": authBearer,\n \"method\": \"PATCH\",\n \"header\": [],\n \"body\": jsonBody,\n \"url\": makeUrl(\"/:uuid\", uuidVariable)\n },\n \"response\": []\n },\n {\n \"name\": \"DELETE\",\n \"request\": {\n \"auth\": authBearer,\n \"method\": \"DELETE\",\n \"header\": [],\n \"url\": makeUrl(\"/:uuid\", uuidVariable)\n },\n \"response\": []\n }\n ]\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"postman.js","names":["toCamel","uuidv4","generateBasePostman","projectName","baseData","info","_postman_id","name","schema","item","event","listen","script","type","packages","exec","variable","key","value","getItemFormatted","controllerDirectoryName","authBearer","bearer","makeUrl","pathSuffix","variables","raw","pathParts","push","replace","url","host","path","length","uuidVariable","jsonBody","mode","options","language","request","auth","method","header","response","body"],"sources":["bin/generators/postman.js"],"mappings":"OAASA,YAAe,+BACTC,WAAc,cAEtB,MAAMC,oBAAuBC,IAChC,MAAMC,EAAW,CAAC,EAyClB,OAxCAA,EAASC,KAAO,CACZC,YAAaL,SACbM,KAAMJ,EACNK,OAAQ,wEAEZJ,EAASK,KAAO,GAChBL,EAASM,MAAQ,CACb,CACIC,OAAU,aACVC,OAAU,CACNC,KAAQ,kBACRC,SAAY,CAAC,EACbC,KAAQ,CACJ,MAIZ,CACIJ,OAAU,OACVC,OAAU,CACNC,KAAQ,kBACRC,SAAY,CAAC,EACbC,KAAQ,CACJ,OAKhBX,EAASY,SAAW,CAChB,CACIC,IAAO,GAAGjB,QAAQG,gBAClBe,MAAS,0BACTL,KAAQ,UAEZ,CACII,IAAO,GAAGjB,QAAQG,gBAClBe,MAAS,UACTL,KAAQ,WAGTT,CAAQ,SASZ,MAAMe,iBAAmB,CAACC,EAAyBjB,KACtD,MAAMkB,EAAa,CACfR,KAAQ,SACRS,OAAU,CACN,CACIL,IAAO,QACPC,MAAS,KAAKlB,QAAQG,kBACtBU,KAAQ,YAKdU,EAAU,CAACC,EAAa,GAAIC,EAAY,MAC1C,MAAMC,EAAM,KAAK1B,QAAQG,uBAAiCiB,IAA0BI,IAC9EG,EAAY,CAAC,MAAOP,GACtBI,GAAYG,EAAUC,KAAKJ,EAAWK,QAAQ,IAAK,KAEvD,MAAMC,EAAM,CACRJ,MACAK,KAAQ,CAAC,KAAK/B,QAAQG,mBACtB6B,KAAQL,GAGZ,OADIF,EAAUQ,OAAS,IAAGH,EAAId,SAAWS,GAClCK,CAAG,EAGRI,EAAe,CAAC,CAAEjB,IAAO,OAAQC,MAAS,WAC1CiB,EAAW,CACbC,KAAQ,MACRV,IAAO,KACPW,QAAW,CAAEX,IAAO,CAAEY,SAAY,UAGtC,MAAO,CACH/B,KAAQa,EACRX,KAAQ,CACJ,CACIF,KAAQ,UACRgC,QAAW,CACPC,KAAQnB,EACRoB,OAAU,MACVC,OAAU,GACVZ,IAAOP,KAEXoB,SAAY,IAEhB,CACIpC,KAAQ,cACRgC,QAAW,CACPC,KAAQnB,EACRoB,OAAU,MACVC,OAAU,GACVZ,IAAOP,EAAQ,SAAUW,IAE7BS,SAAY,IAEhB,CACIpC,KAAQ,SACRgC,QAAW,CACPC,KAAQnB,EACRoB,OAAU,OACVC,OAAU,GACVE,KAAQT,EACRL,IAAOP,KAEXoB,SAAY,IAEhB,CACIpC,KAAQ,SACRgC,QAAW,CACPC,KAAQnB,EACRoB,OAAU,MACVC,OAAU,GACVE,KAAQT,EACRL,IAAOP,EAAQ,SAAUW,IAE7BS,SAAY,IAEhB,CACIpC,KAAQ,QACRgC,QAAW,CACPC,KAAQnB,EACRoB,OAAU,QACVC,OAAU,GACVE,KAAQT,EACRL,IAAOP,EAAQ,SAAUW,IAE7BS,SAAY,IAEhB,CACIpC,KAAQ,SACRgC,QAAW,CACPC,KAAQnB,EACRoB,OAAU,SACVC,OAAU,GACVZ,IAAOP,EAAQ,SAAUW,IAE7BS,SAAY,KAGxB","ignoreList":[],"sourcesContent":["import { toCamel } from 'ts-case-convert';\r\nimport { v4 as uuidv4 } from 'uuid';\r\n\r\nexport const generateBasePostman = (projectName) => {\r\n const baseData = {}\r\n baseData.info = {\r\n _postman_id: uuidv4(),\r\n name: projectName,\r\n schema: \"https://schema.getpostman.com/json/collection/v2.1.0/collection.json\"\r\n };\r\n baseData.item = [];\r\n baseData.event = [\r\n {\r\n \"listen\": \"prerequest\",\r\n \"script\": {\r\n \"type\": \"text/javascript\",\r\n \"packages\": {},\r\n \"exec\": [\r\n \"\"\r\n ]\r\n }\r\n },\r\n {\r\n \"listen\": \"test\",\r\n \"script\": {\r\n \"type\": \"text/javascript\",\r\n \"packages\": {},\r\n \"exec\": [\r\n \"\"\r\n ]\r\n }\r\n }\r\n ];\r\n baseData.variable = [\r\n {\r\n \"key\": `${toCamel(projectName)}BackendHost`,\r\n \"value\": \"http://localhost:<PORT>\",\r\n \"type\": \"string\"\r\n },\r\n {\r\n \"key\": `${toCamel(projectName)}BearerToken`,\r\n \"value\": \"<token>\",\r\n \"type\": \"string\"\r\n }\r\n ];\r\n return baseData;\r\n}\r\n\r\n/**\r\n *\r\n * @param {String} controllerDirectoryName\r\n * @param {String} projectName\r\n * @returns {Object}\r\n */\r\nexport const getItemFormatted = (controllerDirectoryName, projectName) => {\r\n const authBearer = {\r\n \"type\": \"bearer\",\r\n \"bearer\": [\r\n {\r\n \"key\": \"token\",\r\n \"value\": `{{${toCamel(projectName)}BearerToken}}`,\r\n \"type\": \"string\"\r\n }\r\n ]\r\n };\r\n\r\n const makeUrl = (pathSuffix = '', variables = []) => {\r\n const raw = `{{${toCamel(projectName)}BackendHost}}/api/${controllerDirectoryName}${pathSuffix}`;\r\n const pathParts = [\"api\", controllerDirectoryName];\r\n if (pathSuffix) pathParts.push(pathSuffix.replace('/', ''));\r\n\r\n const url = {\r\n raw,\r\n \"host\": [`{{${toCamel(projectName)}BackendHost}}`],\r\n \"path\": pathParts\r\n };\r\n if (variables.length > 0) url.variable = variables;\r\n return url;\r\n };\r\n\r\n const uuidVariable = [{ \"key\": \"uuid\", \"value\": \"<uuid>\" }];\r\n const jsonBody = {\r\n \"mode\": \"raw\",\r\n \"raw\": \"{}\",\r\n \"options\": { \"raw\": { \"language\": \"json\" } }\r\n };\r\n\r\n return {\r\n \"name\": controllerDirectoryName,\r\n \"item\": [\r\n {\r\n \"name\": \"GET ALL\",\r\n \"request\": {\r\n \"auth\": authBearer,\r\n \"method\": \"GET\",\r\n \"header\": [],\r\n \"url\": makeUrl()\r\n },\r\n \"response\": []\r\n },\r\n {\r\n \"name\": \"GET BY UUID\",\r\n \"request\": {\r\n \"auth\": authBearer,\r\n \"method\": \"GET\",\r\n \"header\": [],\r\n \"url\": makeUrl(\"/:uuid\", uuidVariable)\r\n },\r\n \"response\": []\r\n },\r\n {\r\n \"name\": \"CREATE\",\r\n \"request\": {\r\n \"auth\": authBearer,\r\n \"method\": \"POST\",\r\n \"header\": [],\r\n \"body\": jsonBody,\r\n \"url\": makeUrl()\r\n },\r\n \"response\": []\r\n },\r\n {\r\n \"name\": \"UPDATE\",\r\n \"request\": {\r\n \"auth\": authBearer,\r\n \"method\": \"PUT\",\r\n \"header\": [],\r\n \"body\": jsonBody,\r\n \"url\": makeUrl(\"/:uuid\", uuidVariable)\r\n },\r\n \"response\": []\r\n },\r\n {\r\n \"name\": \"PATCH\",\r\n \"request\": {\r\n \"auth\": authBearer,\r\n \"method\": \"PATCH\",\r\n \"header\": [],\r\n \"body\": jsonBody,\r\n \"url\": makeUrl(\"/:uuid\", uuidVariable)\r\n },\r\n \"response\": []\r\n },\r\n {\r\n \"name\": \"DELETE\",\r\n \"request\": {\r\n \"auth\": authBearer,\r\n \"method\": \"DELETE\",\r\n \"header\": [],\r\n \"url\": makeUrl(\"/:uuid\", uuidVariable)\r\n },\r\n \"response\": []\r\n }\r\n ]\r\n }\r\n}\r\n"]}
|
package/dist/bin/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{Command}from"commander";import inquirer from"inquirer";import{generateController,generateRouter}from"./generators/class.js";import fs from"fs-extra";import path from"path";import{fileURLToPath}from"url";import{exec}from"child_process";import ora from"ora";import{generateBasePostman,getItemFormatted}from"./generators/postman.js";const __dirname=path.dirname(fileURLToPath(import.meta.url)),pkg=fs.readJsonSync(path.join(__dirname,"../../package.json")),program=new Command;program.version(pkg.version,"-v, --version").option("--init","Initialize a new project").option("--backend","Initialize with backend template").option("--module","Initialize with module template").option("--db-sql","Initialize with db-sql template").option("--backend-db-sql","Initialize with backend + database template").option("--create-controller","Create a controller and its associated route"),program.parse(process.argv);const options=program.opts();function runFormatter(e="."){return new Promise(((t,r)=>{const s=exec("npm run format",{cwd:e});s.stdout.on("data",(e=>process.stdout.write(e))),s.stderr.on("data",(e=>process.stderr.write(e))),s.on("close",(e=>{0===e?t():r(new Error(`npm format exited with code ${e}`))}))}))}function runNpmInstall(e){return new Promise(((t,r)=>{const s=exec("npm install",{cwd:e});s.stdout.on("data",(e=>process.stdout.write(e))),s.stderr.on("data",(e=>process.stderr.write(e))),s.on("close",(e=>{0===e?t():r(new Error(`npm install exited with code ${e}`))}))}))}function initGitRepo(e){return new Promise(((t,r)=>{const s=exec("git init",{cwd:e});s.stdout.on("data",(e=>process.stdout.write(e))),s.stderr.on("data",(e=>process.stderr.write(e))),s.on("close",(e=>{0===e?t():r(new Error(`Git init exited with code ${e}`))}))}))}options.init&&(options.backend||options.module||options.dbSql||options.backendDbSql)?(console.log("Hello! I'm Paul Sundays, your backend architect. Let's craft an awesome backend together!"),inquirer.prompt([{type:"input",name:"projectName",message:"Name of the project:",validate:e=>!!e||"The name of the project can not be empty"}]).then((async({projectName:e})=>{const t=options.backend?"backend":options.backendDbSql?"backend-db-sql":options.module?"module":"db-sql",r=path.join(__dirname,`../templates/${t}`);let s,n,o;"."===e?(s=path.resolve("."),n=path.basename(s),fs.existsSync(path.join(s,"package.json"))&&(console.error("A package.json already exists in the current directory."),process.exit(1))):(n=e.toLowerCase().replace(/\s+/g,"-"),s=path.resolve(n),fs.existsSync(s)&&(console.error(`Directory "${n}" already exists.`),process.exit(1)),await fs.mkdir(s,{recursive:!0}));try{await fs.copy(r,s,{overwrite:!1,errorOnExist:!0,filter:(e,t)=>!0}),console.log("Template files copied successfully")}catch(e){console.error("Error copying the files:",e),process.exit(1)}if(o="db-sql"===t?{name:n,version:"0.0.1",description:"Knex Module",main:"dist/index.js",scripts:{test:"jest",format:"prettier --write .",build:"tsc",clean:"rimraf dist && npm run format && npm run build","npm:publish":"npm run clean && npm publish","migrate:create":"knex migrate:make migration -x ts","migrate:deploy":"knex migrate:latest","seed:create":"knex seed:make seed -x ts","seed:run":"knex seed:run"},repository:{type:"git",url:""},author:"",license:"MIT",bugs:{url:""},homepage:"",devDependencies:{"@eslint/js":"^9.23.0","@types/node":"^22.13.13",eslint:"^9.23.0",globals:"^16.0.0",prettier:"^3.5.3",rimraf:"^6.0.1","ts-node":"^10.9.2",typescript:"^5.8.2","typescript-eslint":"^8.28.0"},dependencies:{dotenv:"^16.4.7",knex:"^3.1.0",lodash:"^4.17.21",pg:"^8.14.1",uuid:"^11.1.0"}}:"backend"===t?{name:n,version:"1.0.0",description:"Backend project generated with Sundays Framework",main:"dist/server.js",scripts:{test:"jest",start:"node dist/server.js",build:"tsc","start:dev":"nodemon src/server.ts",format:"prettier --write .","create:controller":"sundaysf --create-controller"},dependencies:{morgan:"^1.10.0",cors:"^2.8.5",dotenv:"^16.4.7",express:"^4.18.2"},devDependencies:{"@types/morgan":"^1.9.9","@types/cors":"^2.8.17","@types/express":"^4.17.21",nodemon:"^3.0.2",prettier:"^3.5.3","ts-node":"^10.9.2",typescript:"^5.8.2","@eslint/js":"^9.23.0",eslint:"^9.23.0","typescript-eslint":"^8.28.0"},author:"",license:"MIT"}:"backend-db-sql"===t?{name:n,version:"1.0.0",description:"Backend project with database module generated with Sundays Framework",main:"dist/server.js",scripts:{test:"jest",start:"node dist/server.js",build:"tsc","start:dev":"nodemon src/server.ts",format:"prettier --write .","create:controller":"sundaysf --create-controller","migrate:create":"knex migrate:make migration -x ts --knexfile db/knexfile.ts","migrate:deploy":"knex migrate:latest --knexfile db/knexfile.ts","seed:create":"knex seed:make seed -x ts --knexfile db/knexfile.ts","seed:run":"knex seed:run --knexfile db/knexfile.ts","db:build":"tsc -p db/tsconfig.json","db:publish":"cd db && npm publish"},dependencies:{morgan:"^1.10.0",cors:"^2.8.5",dotenv:"^16.4.7",express:"^4.18.2",knex:"^3.1.0",lodash:"^4.17.21",pg:"^8.14.1",uuid:"^11.1.0"},devDependencies:{"@types/morgan":"^1.9.9","@types/cors":"^2.8.17","@types/express":"^4.17.21","@types/lodash":"^4.17.16","@types/node":"^22.13.13",nodemon:"^3.0.2",prettier:"^3.5.3",rimraf:"^6.0.1","ts-node":"^10.9.2",typescript:"^5.8.2","@eslint/js":"^9.23.0",eslint:"^9.23.0",globals:"^16.0.0","typescript-eslint":"^8.28.0"},author:"",license:"MIT"}:{name:n,version:"1.0.0",description:"Module generated with Sundays Framework",main:"dist/index.js",types:"dist/index.d.ts",scripts:{test:"jest",build:"tsc",format:"prettier --write .",clean:"rimraf dist && npm run build"},dependencies:{},devDependencies:{prettier:"^3.5.3",rimraf:"^6.0.1",typescript:"^5.8.2"},author:"",license:"MIT"},await fs.writeJson(path.join(s,"package.json"),o,{spaces:2}),"backend"===t||"backend-db-sql"===t){const t=generateBasePostman(e);await fs.writeJson(path.join(s,"postman.json"),t,{spaces:2})}if("backend-db-sql"===t){const e={name:`${n}-db`,version:"0.0.1",description:"Database module",main:"dist/index.js",types:"dist/index.d.ts",scripts:{build:"tsc",clean:"rimraf dist && npm run build",format:"prettier --write .","npm:publish":"npm run clean && npm publish","migrate:create":"knex migrate:make migration -x ts","migrate:deploy":"knex migrate:latest","seed:create":"knex seed:make seed -x ts","seed:run":"knex seed:run"},dependencies:{dotenv:"^16.4.7",knex:"^3.1.0",lodash:"^4.17.21",pg:"^8.14.1",uuid:"^11.1.0"},devDependencies:{typescript:"^5.8.2","ts-node":"^10.9.2",rimraf:"^6.0.1",prettier:"^3.5.3","@types/node":"^22.13.13"}};await fs.writeJson(path.join(s,"db/package.json"),e,{spaces:2})}const i=ora("Git init...").start();await initGitRepo(s),i.succeed("Git initialized");const a=ora("Installing dependencies...").start();await runNpmInstall(s),a.succeed("Dependencies installed"),await runFormatter(s);const c="."===e?"Project created successfully in current directory":`Project '${e}' created successfully in ./${n}`;console.log(c)}))):options.createController?(fs.existsSync("./src/controllers")&&fs.existsSync("./postman.json")||(console.error("This command must be run inside a Sundays backend project."),console.error("Expected ./src/controllers/ and ./postman.json to exist."),process.exit(1)),inquirer.prompt([{type:"input",name:"controllerName",message:"Controller name:",validate:e=>e?!!/^[a-zA-Z][a-zA-Z0-9]*$/.test(e)||"Name must start with a letter and contain only letters and numbers":"The controller name is empty"}]).then((async({controllerName:e})=>{try{const t=e.charAt(0).toLowerCase()+e.slice(1),r=e.charAt(0).toUpperCase()+e.slice(1),s=`${r}Controller`,n=`${t}.controller.ts`,o=`${t}`,i=`${r}Router`,a=`${t}.router.ts`,c=`${t}`,d=`./src/controllers/${o}`,p=`./src/routes/${c}`;fs.existsSync(d)&&(console.error(`Controller directory "${d}" already exists.`),process.exit(1));const l=generateController(s),m=generateRouter(i,s,o),u=`${d}/${n}`,f=`${p}/${a}`;await fs.mkdir(d,{recursive:!0}),await fs.mkdir(p,{recursive:!0}),await fs.writeFile(u,l),await fs.writeFile(f,m);const g=await fs.readFile("./postman.json","utf-8"),b=JSON.parse(g),x=getItemFormatted(c,b.info.name);b.item.push(x),await fs.writeJson(path.join(".","postman.json"),b,{spaces:2}),await runFormatter("."),console.log(`Created ${s} in ${o}/${n} and ${i} in ${c}/${a}`)}catch(e){console.error("Error generating controller:",e.message),process.exit(1)}}))):program.help();
|
|
2
|
+
import{Command}from"commander";import inquirer from"inquirer";import{generateController,generateRouter}from"./generators/class.js";import fs from"fs-extra";import path from"path";import{fileURLToPath}from"url";import{exec}from"child_process";import ora from"ora";import{generateBasePostman,getItemFormatted}from"./generators/postman.js";const __dirname=path.dirname(fileURLToPath(import.meta.url)),pkg=fs.readJsonSync(path.join(__dirname,"../../package.json")),program=new Command;program.version(pkg.version,"-v, --version").option("--init","Initialize a new project").option("--backend","Initialize with backend template").option("--module","Initialize with module template").option("--db-sql","Initialize with db-sql template").option("--backend-db-sql","Initialize with backend + database template (separate db module)").option("--backend-embedded-db-sql","Initialize with backend + embedded database template (single project)").option("--frontend-nextjs","Initialize with Next.js frontend template (shadcn/ui + Tailwind)").option("--create-controller","Create a controller and its associated route"),program.parse(process.argv);const options=program.opts();function runFormatter(e="."){return new Promise(((t,r)=>{const s=exec("npm run format",{cwd:e});s.stdout.on("data",(e=>process.stdout.write(e))),s.stderr.on("data",(e=>process.stderr.write(e))),s.on("close",(e=>{0===e?t():r(new Error(`npm format exited with code ${e}`))}))}))}function runNpmInstall(e){return new Promise(((t,r)=>{const s=exec("npm install",{cwd:e});s.stdout.on("data",(e=>process.stdout.write(e))),s.stderr.on("data",(e=>process.stderr.write(e))),s.on("close",(e=>{0===e?t():r(new Error(`npm install exited with code ${e}`))}))}))}function initGitRepo(e){return new Promise(((t,r)=>{const s=exec("git init",{cwd:e});s.stdout.on("data",(e=>process.stdout.write(e))),s.stderr.on("data",(e=>process.stderr.write(e))),s.on("close",(e=>{0===e?t():r(new Error(`Git init exited with code ${e}`))}))}))}options.init&&(options.backend||options.module||options.dbSql||options.backendDbSql||options.backendEmbeddedDbSql||options.frontendNextjs)?(console.log("Hello! I'm Paul Sundays, your backend architect. Let's craft an awesome backend together!"),inquirer.prompt([{type:"input",name:"projectName",message:"Name of the project:",validate:e=>!!e||"The name of the project can not be empty"}]).then((async({projectName:e})=>{const t=options.backend?"backend":options.backendEmbeddedDbSql?"backend-embedded-db-sql":options.backendDbSql?"backend-db-sql":options.frontendNextjs?"frontend-nextjs":options.module?"module":"db-sql",r=path.join(__dirname,`../templates/${t}`);let s,n,i;"."===e?(s=path.resolve("."),n=path.basename(s),fs.existsSync(path.join(s,"package.json"))&&(console.error("A package.json already exists in the current directory."),process.exit(1))):(n=e.toLowerCase().replace(/\s+/g,"-"),s=path.resolve(n),fs.existsSync(s)&&(console.error(`Directory "${n}" already exists.`),process.exit(1)),await fs.mkdir(s,{recursive:!0}));try{await fs.copy(r,s,{overwrite:!1,errorOnExist:!0,filter:(e,t)=>!0}),console.log("Template files copied successfully")}catch(e){console.error("Error copying the files:",e),process.exit(1)}if(i="db-sql"===t?{name:n,version:"0.0.1",description:"Knex Module",main:"dist/index.js",scripts:{test:"jest",format:"prettier --write .",build:"tsc",clean:"rimraf dist && npm run format && npm run build","npm:publish":"npm run clean && npm publish","migrate:create":"knex migrate:make migration -x ts","migrate:deploy":"knex migrate:latest","seed:create":"knex seed:make seed -x ts","seed:run":"knex seed:run"},repository:{type:"git",url:""},author:"",license:"MIT",bugs:{url:""},homepage:"",devDependencies:{"@eslint/js":"^9.23.0","@types/node":"^22.13.13",eslint:"^9.23.0",globals:"^16.0.0",prettier:"^3.5.3",rimraf:"^6.0.1","ts-node":"^10.9.2",typescript:"^5.8.2","typescript-eslint":"^8.28.0"},dependencies:{dotenv:"^16.4.7",knex:"^3.1.0",lodash:"^4.17.21",pg:"^8.14.1",uuid:"^11.1.0"}}:"backend"===t?{name:n,version:"1.0.0",description:"Backend project generated with Sundays Framework",main:"dist/server.js",scripts:{test:"jest",start:"node dist/server.js",build:"tsc","start:dev":"nodemon src/server.ts",format:"prettier --write .","create:controller":"sundaysf --create-controller"},dependencies:{morgan:"^1.10.0",cors:"^2.8.5",dotenv:"^16.4.7",express:"^4.18.2"},devDependencies:{"@types/morgan":"^1.9.9","@types/cors":"^2.8.17","@types/express":"^4.17.21",nodemon:"^3.0.2",prettier:"^3.5.3","ts-node":"^10.9.2",typescript:"^5.8.2","@eslint/js":"^9.23.0",eslint:"^9.23.0","typescript-eslint":"^8.28.0"},author:"",license:"MIT"}:"backend-db-sql"===t?{name:n,version:"1.0.0",description:"Backend project with database module generated with Sundays Framework",main:"dist/server.js",scripts:{test:"jest",start:"node dist/server.js",build:"tsc","start:dev":"nodemon src/server.ts",format:"prettier --write .","create:controller":"sundaysf --create-controller","migrate:create":"knex migrate:make migration -x ts --knexfile db/knexfile.ts","migrate:deploy":"knex migrate:latest --knexfile db/knexfile.ts","seed:create":"knex seed:make seed -x ts --knexfile db/knexfile.ts","seed:run":"knex seed:run --knexfile db/knexfile.ts","db:build":"tsc -p db/tsconfig.json","db:publish":"cd db && npm publish"},dependencies:{morgan:"^1.10.0",cors:"^2.8.5",dotenv:"^16.4.7",express:"^4.18.2",knex:"^3.1.0",lodash:"^4.17.21",pg:"^8.14.1",uuid:"^11.1.0"},devDependencies:{"@types/morgan":"^1.9.9","@types/cors":"^2.8.17","@types/express":"^4.17.21","@types/lodash":"^4.17.16","@types/node":"^22.13.13",nodemon:"^3.0.2",prettier:"^3.5.3",rimraf:"^6.0.1","ts-node":"^10.9.2",typescript:"^5.8.2","@eslint/js":"^9.23.0",eslint:"^9.23.0",globals:"^16.0.0","typescript-eslint":"^8.28.0"},author:"",license:"MIT"}:"backend-embedded-db-sql"===t?{name:n,version:"1.0.0",description:"Backend project with embedded database generated with Sundays Framework",main:"dist/server.js",scripts:{test:"jest",start:"node dist/server.js",build:"tsc","start:dev":"nodemon src/server.ts",format:"prettier --write .","create:controller":"sundaysf --create-controller","db:migrate":"npx knex migrate:latest --knexfile knexfile.ts","db:rollback":"npx knex migrate:rollback --knexfile knexfile.ts","db:seed":"npx knex seed:run --knexfile knexfile.ts","db:make-migration":"npx knex migrate:make --knexfile knexfile.ts -x ts"},dependencies:{morgan:"^1.10.0",cors:"^2.8.5",dotenv:"^16.4.7",express:"^4.18.2",knex:"^3.1.0",lodash:"^4.17.21",pg:"^8.14.1",uuid:"^11.1.0"},devDependencies:{"@types/morgan":"^1.9.9","@types/cors":"^2.8.17","@types/express":"^4.17.21","@types/lodash":"^4.17.16","@types/node":"^22.13.13",nodemon:"^3.0.2",prettier:"^3.5.3",rimraf:"^6.0.1","ts-node":"^10.9.2",typescript:"^5.8.2","@eslint/js":"^9.23.0",eslint:"^9.23.0",globals:"^16.0.0","typescript-eslint":"^8.28.0"},author:"",license:"MIT"}:"frontend-nextjs"===t?{name:n,version:"0.1.0",private:!0,scripts:{dev:"next dev",build:"next build",start:"next start",lint:"eslint ."},dependencies:{"@hookform/resolvers":"^3.9.1","@radix-ui/react-accordion":"1.2.12","@radix-ui/react-alert-dialog":"1.1.15","@radix-ui/react-aspect-ratio":"1.1.8","@radix-ui/react-avatar":"1.1.11","@radix-ui/react-checkbox":"1.3.3","@radix-ui/react-collapsible":"1.1.12","@radix-ui/react-context-menu":"2.2.16","@radix-ui/react-dialog":"1.1.15","@radix-ui/react-dropdown-menu":"2.1.16","@radix-ui/react-hover-card":"1.1.15","@radix-ui/react-label":"2.1.8","@radix-ui/react-menubar":"1.1.16","@radix-ui/react-navigation-menu":"1.2.14","@radix-ui/react-popover":"1.1.15","@radix-ui/react-progress":"1.1.8","@radix-ui/react-radio-group":"1.3.8","@radix-ui/react-scroll-area":"1.2.10","@radix-ui/react-select":"2.2.6","@radix-ui/react-separator":"1.1.8","@radix-ui/react-slider":"1.3.6","@radix-ui/react-slot":"1.2.4","@radix-ui/react-switch":"1.2.6","@radix-ui/react-tabs":"1.1.13","@radix-ui/react-toast":"1.2.15","@radix-ui/react-toggle":"1.1.10","@radix-ui/react-toggle-group":"1.1.11","@radix-ui/react-tooltip":"1.2.8",autoprefixer:"^10.4.20","class-variance-authority":"^0.7.1",clsx:"^2.1.1",cmdk:"1.1.1","date-fns":"4.1.0","embla-carousel-react":"8.6.0","framer-motion":"^12.38.0","input-otp":"1.4.2","lucide-react":"^0.564.0",next:"16.1.6","next-themes":"^0.4.6",react:"19.2.4","react-day-picker":"9.13.2","react-dom":"19.2.4","react-hook-form":"^7.54.1","react-resizable-panels":"^2.1.7",recharts:"2.15.0",sonner:"^1.7.1","tailwind-merge":"^3.3.1",vaul:"^1.1.2",zod:"^3.24.1"},devDependencies:{"@tailwindcss/postcss":"^4.2.0","@types/node":"^22","@types/react":"19.2.14","@types/react-dom":"19.2.3",postcss:"^8.5",tailwindcss:"^4.2.0","tw-animate-css":"1.3.3",typescript:"5.7.3"}}:{name:n,version:"1.0.0",description:"Module generated with Sundays Framework",main:"dist/index.js",types:"dist/index.d.ts",scripts:{test:"jest",build:"tsc",format:"prettier --write .",clean:"rimraf dist && npm run build"},dependencies:{},devDependencies:{prettier:"^3.5.3",rimraf:"^6.0.1",typescript:"^5.8.2"},author:"",license:"MIT"},await fs.writeJson(path.join(s,"package.json"),i,{spaces:2}),["backend","backend-db-sql","backend-embedded-db-sql"].includes(t)){const t=generateBasePostman(e);await fs.writeJson(path.join(s,"postman.json"),t,{spaces:2})}if("backend-db-sql"===t){const e={name:`${n}-db`,version:"0.0.1",description:"Database module",main:"dist/index.js",types:"dist/index.d.ts",scripts:{build:"tsc",clean:"rimraf dist && npm run build",format:"prettier --write .","npm:publish":"npm run clean && npm publish","migrate:create":"knex migrate:make migration -x ts","migrate:deploy":"knex migrate:latest","seed:create":"knex seed:make seed -x ts","seed:run":"knex seed:run"},dependencies:{dotenv:"^16.4.7",knex:"^3.1.0",lodash:"^4.17.21",pg:"^8.14.1",uuid:"^11.1.0"},devDependencies:{typescript:"^5.8.2","ts-node":"^10.9.2",rimraf:"^6.0.1",prettier:"^3.5.3","@types/node":"^22.13.13"}};await fs.writeJson(path.join(s,"db/package.json"),e,{spaces:2})}const a=ora("Git init...").start();await initGitRepo(s),a.succeed("Git initialized");const o=ora("Installing dependencies...").start();await runNpmInstall(s),o.succeed("Dependencies installed"),await runFormatter(s);const d="."===e?"Project created successfully in current directory":`Project '${e}' created successfully in ./${n}`;console.log(d)}))):options.createController?(fs.existsSync("./src/controllers")&&fs.existsSync("./postman.json")||(console.error("This command must be run inside a Sundays backend project."),console.error("Expected ./src/controllers/ and ./postman.json to exist."),process.exit(1)),inquirer.prompt([{type:"input",name:"controllerName",message:"Controller name:",validate:e=>e?!!/^[a-zA-Z][a-zA-Z0-9]*$/.test(e)||"Name must start with a letter and contain only letters and numbers":"The controller name is empty"}]).then((async({controllerName:e})=>{try{const t=e.charAt(0).toLowerCase()+e.slice(1),r=e.charAt(0).toUpperCase()+e.slice(1),s=`${r}Controller`,n=`${t}.controller.ts`,i=`${t}`,a=`${r}Router`,o=`${t}.router.ts`,d=`${t}`,c=`./src/controllers/${i}`,p=`./src/routes/${d}`;fs.existsSync(c)&&(console.error(`Controller directory "${c}" already exists.`),process.exit(1));const l=generateController(s),m=generateRouter(a,s,i),u=`${c}/${n}`,x=`${p}/${o}`;await fs.mkdir(c,{recursive:!0}),await fs.mkdir(p,{recursive:!0}),await fs.writeFile(u,l),await fs.writeFile(x,m);const b=await fs.readFile("./postman.json","utf-8"),f=JSON.parse(b),k=getItemFormatted(d,f.info.name);f.item.push(k),await fs.writeJson(path.join(".","postman.json"),f,{spaces:2}),await runFormatter("."),console.log(`Created ${s} in ${i}/${n} and ${a} in ${d}/${o}`)}catch(e){console.error("Error generating controller:",e.message),process.exit(1)}}))):program.help();
|
|
3
3
|
//# sourceMappingURL=index.js.map
|