skelr 3.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/CHANGELOG.md ADDED
@@ -0,0 +1,133 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [3.0.0] - 2026-02-08
9
+
10
+ ### Added
11
+
12
+ - **CRUD API Generation**: Generate complete Create, Read, Update, Delete operations
13
+ - Prisma ORM integration with configurable model names
14
+ - Pagination, search, and sorting support
15
+ - Soft delete with timestamp or boolean approach
16
+ - Duplicate checking and proper error handling
17
+ - **Configuration File Support**: Pre-configure defaults with `.skelrrc.json`
18
+ - Set default folder structure, language, and CRUD options
19
+ - Auto-detected from project root
20
+ - **ASCII Banner**: Beautiful ASCII art logo in CLI startup
21
+ - **Programmatic API**: Use skelr as a library in your own scripts
22
+ - Export all templates, generators, and utility functions
23
+
24
+ ### Changed
25
+
26
+ - **Major Architecture Refactor**: Restructured from single file to modular library
27
+ - Organized into `src/` with logical subdirectories
28
+ - Separated CLI, config, generators, prompts, templates, UI, and utils
29
+ - Added proper npm exports map for subpath imports
30
+ - Updated CLI entry point to `bin/skelr.js`
31
+ - Improved interactive prompts with more detailed explanations
32
+ - Enhanced success summary with next steps guidance
33
+
34
+ ### Technical
35
+
36
+ - 24 modular files across 8 directories
37
+ - Proper barrel exports for each module
38
+ - Package exports for programmatic usage
39
+
40
+ ### Migration
41
+
42
+ > ⚠️ **Repository Renamed**: This project has been renamed from `scaffold-service` to `skelr`.
43
+ >
44
+ > - **Old (Deprecated)**: https://github.com/abubakar-shaikh-dev/scaffold-service
45
+ > - **New**: https://github.com/abubakar-shaikh-dev/skelr
46
+ >
47
+ > The npm package name remains `skelr`. Please update your bookmarks and git remotes.
48
+
49
+ ---
50
+
51
+ ## [2.1.0] - 2026-02-06
52
+
53
+ ### Added
54
+
55
+ - **TypeScript Support**: Generate `.ts` files with proper type annotations
56
+ - New language selection prompt (Step 2)
57
+ - TypeScript templates for service, validation, controller, and routes
58
+ - Express `Request`/`Response` types in controller templates
59
+ - Zod type inference examples in validation templates
60
+ - **Non-Interactive CLI Mode**: Skip prompts with command-line flags
61
+ - `--name` / `-n`: Set service name directly
62
+ - `--structure` / `-s`: Set folder structure (`separate` or `modular`)
63
+ - `--typescript` / `-ts`: Generate TypeScript files
64
+ - `--help` / `-h`: Show usage information
65
+ - Quick Mode indicator when running with CLI flags
66
+
67
+ ### Changed
68
+
69
+ - Updated step numbering to accommodate language selection (5 steps total)
70
+ - Improved configuration preview to show selected language
71
+
72
+ ---
73
+
74
+ ## [2.0.0] - 2026-02-05
75
+
76
+ ### Added
77
+
78
+ - Complete rewrite with modern ES6+ modules
79
+ - Interactive CLI with inquirer for better user experience
80
+ - Colorful terminal output with chalk
81
+ - Two folder structure options: Separate and Modular
82
+ - Automatic generation of service, controller, validation, and route files
83
+ - Snake_case to camelCase naming conversion
84
+ - Configuration preview before file creation
85
+ - CLI tool installable via npm global or npx
86
+ - Support for both distributed and modular folder organizations
87
+
88
+ ### Changed
89
+
90
+ - Upgraded to ES modules (type: "module")
91
+ - Improved user interface with colors and formatting
92
+ - Enhanced error handling and user feedback
93
+ - Better file organization and structure
94
+
95
+ ### Technical
96
+
97
+ - Node.js >= 18.0.0 required
98
+ - Dependencies: chalk@^5.3.0, fs-extra@^11.2.0, inquirer@^12.3.0
99
+ - Published as CLI tool with bin entry point
100
+
101
+ ## [1.0.0] - 2025
102
+
103
+ ### Added
104
+
105
+ - Initial release
106
+ - Basic service scaffolding functionality
107
+ - Core CLI tool structure
108
+
109
+ ---
110
+
111
+ ## Release Notes
112
+
113
+ ### Version 2.0.0
114
+
115
+ This is a major release with significant improvements and modernization. The tool now provides:
116
+
117
+ - Better developer experience with interactive prompts
118
+ - Two folder structure options (Separate vs Modular)
119
+ - Automatic file generation for services, controllers, validations, and routes
120
+ - Modern JavaScript features and best practices
121
+ - Consistent naming conventions with snake_case input
122
+
123
+ ### Future Plans
124
+
125
+ - Add more template options
126
+ - Support for TypeScript
127
+ - Docker configuration generation
128
+ - CI/CD pipeline templates
129
+ - Testing setup inclusion
130
+
131
+ ---
132
+
133
+ For more information, visit [GitHub Repository](https://github.com/abubakar-shaikh-dev/scaffold-service)
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025-2026 ABUBAKAR SHAIKH
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,295 @@
1
+ <div align="center">
2
+
3
+ ![skelr banner](assets/banner.jpg)
4
+
5
+ **Service Scaffolding CLI — Generate production-ready service files in seconds.**
6
+
7
+ [![npm version](https://img.shields.io/npm/v/skelr.svg?style=flat-square&color=00afff)](https://www.npmjs.com/package/skelr)
8
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square)](https://opensource.org/licenses/MIT)
9
+ [![Node.js Version](https://img.shields.io/node/v/skelr.svg?style=flat-square)](https://nodejs.org)
10
+ [![Downloads](https://img.shields.io/npm/dt/skelr.svg?style=flat-square)](https://www.npmjs.com/package/skelr)
11
+
12
+ [Features](#-features) • [Installation](#-installation) • [Quick Start](#-quick-start) • [Configuration](#-configuration) • [API](#-api)
13
+
14
+ </div>
15
+
16
+ ---
17
+
18
+ > ⚠️ **Repository Renamed**: This project has moved from `scaffold-service` to `skelr`.
19
+ >
20
+ > - **Old (Deprecated)**: https://github.com/abubakar-shaikh-dev/scaffold-service
21
+ > - **New**: https://github.com/abubakar-shaikh-dev/skelr
22
+ >
23
+ > Please update your bookmarks and git remotes.
24
+
25
+ ---
26
+
27
+ ## ✨ Features
28
+
29
+ | Feature | Description |
30
+ |---------|-------------|
31
+ | 🏗️ **Two Architecture Modes** | Choose between **Separate** (layer-based) or **Modular** (domain-driven) structures |
32
+ | 📘 **TypeScript Support** | Generate `.ts` files with proper type annotations |
33
+ | ⚡ **CRUD Generation** | Auto-generate complete Create, Read, Update, Delete operations |
34
+ | 🔧 **Config File Support** | Pre-configure defaults with `.skelrrc.json` |
35
+ | 🚀 **Non-Interactive Mode** | Skip prompts with CLI flags for automation |
36
+ | 🎨 **Beautiful CLI** | Interactive prompts with color-coded output |
37
+ | 📦 **Zod Validations** | Pre-configured validation schemas with type inference |
38
+ | 🗑️ **Soft Delete** | Built-in soft delete support (timestamp or boolean) |
39
+
40
+ ---
41
+
42
+ ## 📦 Installation
43
+
44
+ ### Run with npx (Recommended)
45
+ ```bash
46
+ npx skelr
47
+ ```
48
+
49
+ ### Global Installation
50
+ ```bash
51
+ npm install -g skelr
52
+ ```
53
+
54
+ ---
55
+
56
+ ## 🚀 Quick Start
57
+
58
+ ### Interactive Mode
59
+
60
+ Simply run the command and follow the prompts:
61
+
62
+ ```bash
63
+ npx skelr
64
+ ```
65
+
66
+ The CLI will guide you through:
67
+ 1. **Folder Structure** — Separate or Modular
68
+ 2. **Language** — JavaScript or TypeScript
69
+ 3. **CRUD APIs** — Generate pre-made CRUD operations (optional)
70
+ 4. **Service Name** — Enter a snake_case name
71
+ 5. **Preview & Confirm** — Review and create files
72
+
73
+ ### Non-Interactive Mode
74
+
75
+ Skip all prompts with CLI flags:
76
+
77
+ ```bash
78
+ # TypeScript + Modular structure
79
+ skelr --name=payment --structure=modular --typescript
80
+
81
+ # JavaScript + Separate structure
82
+ skelr -n user_profile -s separate
83
+
84
+ # Show help
85
+ skelr --help
86
+ ```
87
+
88
+ ---
89
+
90
+ ## 🎛️ CLI Options
91
+
92
+ | Flag | Short | Description |
93
+ |------|-------|-------------|
94
+ | `--name <name>` | `-n` | Service name in snake_case |
95
+ | `--structure <type>` | `-s` | `separate` or `modular` |
96
+ | `--typescript` | `-ts` | Generate TypeScript files |
97
+ | `--help` | `-h` | Show help message |
98
+
99
+ ---
100
+
101
+ ## ⚙️ Configuration
102
+
103
+ Create a `.skelrrc.json` file in your project root to pre-configure defaults:
104
+
105
+ ```json
106
+ {
107
+ "structure": "modular",
108
+ "language": "ts",
109
+ "crud": {
110
+ "enabled": true,
111
+ "soft_delete": "timestamp"
112
+ }
113
+ }
114
+ ```
115
+
116
+ ### Configuration Options
117
+
118
+ | Option | Values | Description |
119
+ |--------|--------|-------------|
120
+ | `structure` | `"separate"` \| `"modular"` | Default folder structure |
121
+ | `language` | `"js"` \| `"ts"` | Default programming language |
122
+ | `crud.enabled` | `true` \| `false` | Enable CRUD generation by default |
123
+ | `crud.soft_delete` | `"timestamp"` \| `"boolean"` | Soft delete approach |
124
+
125
+ When a config file is detected, skelr will use these values as defaults (you can still override via CLI flags).
126
+
127
+ ---
128
+
129
+ ## 📂 Folder Structures
130
+
131
+ ### Option 1: Separate (Layer-Based)
132
+
133
+ *Best for: Traditional MVC, large teams with strict separation of concerns*
134
+
135
+ ```
136
+ src/
137
+ ├── controllers/
138
+ │ └── payment.controller.ts
139
+ ├── services/
140
+ │ └── payment.service.ts
141
+ ├── validations/
142
+ │ └── payment.validation.ts
143
+ └── routes/
144
+ └── v1/
145
+ └── payment.routes.ts
146
+ ```
147
+
148
+ ### Option 2: Modular (Domain-Driven)
149
+
150
+ *Best for: Microservices, feature-based organization, high cohesion*
151
+
152
+ ```
153
+ src/
154
+ └── modules/
155
+ └── payment/
156
+ ├── payment.controller.ts
157
+ ├── payment.service.ts
158
+ ├── payment.validation.ts
159
+ └── payment.routes.ts
160
+ ```
161
+
162
+ ---
163
+
164
+ ## 🔥 CRUD Generation
165
+
166
+ When you enable CRUD APIs, skelr generates complete implementations:
167
+
168
+ ### Generated Endpoints
169
+ | Method | Route | Description |
170
+ |--------|-------|-------------|
171
+ | `POST` | `/` | Create new record |
172
+ | `GET` | `/` | Get all records (paginated) |
173
+ | `GET` | `/:id` | Get record by ID |
174
+ | `PUT` | `/:id` | Update record by ID |
175
+ | `DELETE` | `/:id` | Soft delete record by ID |
176
+
177
+ ### Features Included
178
+ - ✅ Prisma ORM integration
179
+ - ✅ Zod request validation
180
+ - ✅ Pagination with search & sorting
181
+ - ✅ Duplicate checking
182
+ - ✅ Soft delete (timestamp or boolean)
183
+ - ✅ Proper error handling with `http-errors`
184
+
185
+ ---
186
+
187
+ ## 🛠️ Post-Scaffolding
188
+
189
+ After generating files, register your new route:
190
+
191
+ ```javascript
192
+ // src/routes/index.js
193
+ import paymentRoutes from './routes/v1/payment.routes.js';
194
+ // or for modular:
195
+ import paymentRoutes from './modules/payment/payment.routes.js';
196
+
197
+ router.use('/payments', paymentRoutes);
198
+ ```
199
+
200
+ ---
201
+
202
+ ## 📚 API (Programmatic Usage)
203
+
204
+ skelr can also be used programmatically in your own scripts:
205
+
206
+ ```javascript
207
+ import { generateFiles, snakeToCamel, snakeToPascal } from 'skelr';
208
+
209
+ // Generate files programmatically
210
+ await generateFiles('payment', 'payment', 'modular', 'ts', {
211
+ enabled: true,
212
+ modelName: 'payments',
213
+ softDeleteApproach: 'timestamp'
214
+ });
215
+
216
+ // Use utility functions
217
+ const camelCase = snakeToCamel('user_profile'); // 'userProfile'
218
+ const pascalCase = snakeToPascal('user_profile'); // 'UserProfile'
219
+ ```
220
+
221
+ ### Exports
222
+
223
+ ```javascript
224
+ // CLI
225
+ import { main, parseCliArgs, validateCliArgs, printHelp } from 'skelr';
226
+
227
+ // Config
228
+ import { loadConfig, CONFIG_FILE } from 'skelr';
229
+
230
+ // Generators
231
+ import { generateFiles } from 'skelr';
232
+
233
+ // Utils
234
+ import { snakeToCamel, snakeToPascal, c, printSuccess, printInfo, errorExit } from 'skelr';
235
+
236
+ // Templates (for customization)
237
+ import { getServiceTemplate, getCrudServiceTemplate, /* ... */ } from 'skelr';
238
+ ```
239
+
240
+ ---
241
+
242
+ ## 💻 Development
243
+
244
+ ```bash
245
+ # Clone the repository
246
+ git clone https://github.com/abubakar-shaikh-dev/skelr.git
247
+
248
+ # Install dependencies
249
+ npm install
250
+
251
+ # Run locally
252
+ npm start
253
+
254
+ # Or run directly
255
+ node bin/skelr.js
256
+ ```
257
+
258
+ ### Project Structure
259
+
260
+ ```
261
+ skelr/
262
+ ├── bin/skelr.js # CLI entry point
263
+ ├── src/
264
+ │ ├── index.js # Library exports
265
+ │ ├── cli/ # Argument parsing, help, main
266
+ │ ├── config/ # .skelrrc.json loader
267
+ │ ├── generators/ # File generation logic
268
+ │ ├── prompts/ # Interactive prompts
269
+ │ ├── templates/ # JS & TS templates
270
+ │ ├── ui/ # Banner, preview, summary
271
+ │ └── utils/ # Helpers & utilities
272
+ └── package.json
273
+ ```
274
+
275
+ ---
276
+
277
+ ## 🤝 Contributing
278
+
279
+ Contributions are welcome! Please feel free to submit a Pull Request.
280
+
281
+ 1. Fork the Project
282
+ 2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
283
+ 3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
284
+ 4. Push to the Branch (`git push origin feature/AmazingFeature`)
285
+ 5. Open a Pull Request
286
+
287
+ ---
288
+
289
+ ## 👤 Author
290
+
291
+ **ABUBAKAR SHAIKH**
292
+
293
+ - GitHub: [@abubakar-shaikh-dev](https://github.com/abubakar-shaikh-dev)
294
+ - Repository: [skelr](https://github.com/abubakar-shaikh-dev/skelr)
295
+
package/bin/skelr.js ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env node
2
+ // skelr - Service scaffolding CLI
3
+ // Author: Abubakar Shaikh (github.com/abubakar-shaikh-dev)
4
+
5
+ import { main } from "../src/cli/index.js";
6
+
7
+ // Run the main function
8
+ main();
package/package.json ADDED
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "skelr",
3
+ "version": "3.0.0",
4
+ "description": "Modern CLI tool to scaffold Express service files with CRUD generation",
5
+ "main": "src/index.js",
6
+ "type": "module",
7
+ "bin": {
8
+ "skelr": "./bin/skelr.js"
9
+ },
10
+ "exports": {
11
+ ".": "./src/index.js",
12
+ "./cli": "./src/cli/index.js",
13
+ "./templates": "./src/templates/index.js",
14
+ "./generators": "./src/generators/index.js",
15
+ "./utils": "./src/utils/index.js"
16
+ },
17
+ "files": [
18
+ "bin",
19
+ "src",
20
+ "README.md",
21
+ "LICENSE",
22
+ "CHANGELOG.md"
23
+ ],
24
+ "scripts": {
25
+ "start": "node bin/skelr.js",
26
+ "scaffold": "node bin/skelr.js",
27
+ "prepublishOnly": "node -e \"console.log('Publishing skelr v' + require('./package.json').version); if (require('fs').existsSync('.git/index')) { console.log('Git repo detected - ready to publish'); } else { console.warn('Warning: Not in a git repository'); }\""
28
+ },
29
+ "keywords": [
30
+ "scaffold",
31
+ "service",
32
+ "boilerplate",
33
+ "generator",
34
+ "cli",
35
+ "express",
36
+ "nodejs"
37
+ ],
38
+ "author": "ABUBAKAR SHAIKH <https://github.com/abubakar-shaikh-dev>",
39
+ "license": "MIT",
40
+ "repository": {
41
+ "type": "git",
42
+ "url": "git+https://github.com/abubakar-shaikh-dev/skelr.git"
43
+ },
44
+ "bugs": {
45
+ "url": "https://github.com/abubakar-shaikh-dev/skelr/issues"
46
+ },
47
+ "homepage": "https://github.com/abubakar-shaikh-dev/skelr#readme",
48
+ "engines": {
49
+ "node": ">=18.0.0"
50
+ },
51
+ "dependencies": {
52
+ "@clack/prompts": "^0.7.0",
53
+ "chalk": "^5.3.0"
54
+ }
55
+ }
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Parse CLI arguments from process.argv
3
+ * @param {string[]} argv - Command line arguments (process.argv.slice(2))
4
+ * @returns {Object} Parsed arguments object
5
+ */
6
+ export function parseCliArgs(argv) {
7
+ const args = {
8
+ name: null,
9
+ structure: null,
10
+ typescript: false,
11
+ help: false,
12
+ };
13
+
14
+ for (let i = 0; i < argv.length; i++) {
15
+ const arg = argv[i];
16
+
17
+ // Help flag
18
+ if (arg === "-h" || arg === "--help") {
19
+ args.help = true;
20
+ }
21
+ // TypeScript flag
22
+ else if (arg === "-ts" || arg === "--typescript") {
23
+ args.typescript = true;
24
+ }
25
+ // Name argument
26
+ else if (arg === "-n" || arg === "--name") {
27
+ args.name = argv[++i];
28
+ } else if (arg.startsWith("--name=")) {
29
+ args.name = arg.split("=")[1];
30
+ }
31
+ // Structure argument
32
+ else if (arg === "-s" || arg === "--structure") {
33
+ args.structure = argv[++i];
34
+ } else if (arg.startsWith("--structure=")) {
35
+ args.structure = arg.split("=")[1];
36
+ }
37
+ }
38
+
39
+ return args;
40
+ }
41
+
42
+ /**
43
+ * Validate CLI arguments
44
+ * @param {Object} args - Parsed CLI arguments
45
+ * @returns {string[]} Array of validation error messages
46
+ */
47
+ export function validateCliArgs(args) {
48
+ const errors = [];
49
+
50
+ if (args.name) {
51
+ const snakeCaseRegex = /^[a-z]+(_[a-z]+)*$/;
52
+ if (!snakeCaseRegex.test(args.name)) {
53
+ errors.push(
54
+ "Service name must be in snake_case or a single lowercase word",
55
+ );
56
+ }
57
+ }
58
+
59
+ if (args.structure) {
60
+ const validStructures = ["separate", "modular", "current"];
61
+ if (!validStructures.includes(args.structure.toLowerCase())) {
62
+ errors.push("Structure must be 'separate' or 'modular'");
63
+ }
64
+ }
65
+
66
+ return errors;
67
+ }
@@ -0,0 +1,64 @@
1
+ import chalk from "chalk";
2
+
3
+ /**
4
+ * Print CLI help message
5
+ */
6
+ export function printHelp() {
7
+ console.log("");
8
+ console.log(
9
+ chalk.bold.white(" skelr") + chalk.dim(" - Service scaffolding CLI"),
10
+ );
11
+ console.log("");
12
+ console.log(chalk.bold.white(" USAGE"));
13
+ console.log(
14
+ chalk.dim(" ─────────────────────────────────────────────────────────"),
15
+ );
16
+ console.log(" $ skelr [options]");
17
+ console.log("");
18
+ console.log(chalk.bold.white(" OPTIONS"));
19
+ console.log(
20
+ chalk.dim(" ─────────────────────────────────────────────────────────"),
21
+ );
22
+ console.log(
23
+ " " +
24
+ chalk.cyan("-n, --name <name>") +
25
+ " " +
26
+ chalk.dim("Service name (snake_case)"),
27
+ );
28
+ console.log(
29
+ " " +
30
+ chalk.cyan("-s, --structure <type>") +
31
+ " " +
32
+ chalk.dim("Folder structure: separate | modular"),
33
+ );
34
+ console.log(
35
+ " " +
36
+ chalk.cyan("-ts, --typescript") +
37
+ " " +
38
+ chalk.dim("Generate TypeScript files (.ts)"),
39
+ );
40
+ console.log(
41
+ " " +
42
+ chalk.cyan("-h, --help") +
43
+ " " +
44
+ chalk.dim("Show this help message"),
45
+ );
46
+ console.log("");
47
+ console.log(chalk.bold.white(" EXAMPLES"));
48
+ console.log(
49
+ chalk.dim(" ─────────────────────────────────────────────────────────"),
50
+ );
51
+ console.log(
52
+ " " +
53
+ chalk.dim("$") +
54
+ " skelr " +
55
+ chalk.cyan("--name=payment --structure=modular"),
56
+ );
57
+ console.log(
58
+ " " +
59
+ chalk.dim("$") +
60
+ " skelr " +
61
+ chalk.cyan("-n user_profile -s separate -ts"),
62
+ );
63
+ console.log("");
64
+ }