create-backlist 6.1.1 → 6.1.4
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 +153 -61
- package/package.json +1 -1
- package/src/generators/node.js +17 -3
package/README.md
CHANGED
|
@@ -1,97 +1,189 @@
|
|
|
1
|
-
# 🚀 Create Backlist
|
|
2
1
|
|
|
3
|
-
|
|
4
|
-
[](https://opensource.org/licenses/MIT)
|
|
2
|
+
# 🚀 Create Backlist CLI
|
|
5
3
|
|
|
6
|
-
|
|
4
|
+
[](https://www.npmjs.com/package/create-backlist)
|
|
5
|
+
[](https://www.npmjs.com/package/create-backlist)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
[](https://github.com/WAH-ISHAN/create-backlist/graphs/commit-activity)
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
> **The World's First AST-Powered Polyglot Backend Generator.**
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
**`create-backlist`** is an intelligent CLI tool that **Reverse Engineers** your frontend source code to automatically generate production-ready backends.
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
Unlike traditional scaffolders that rely on static templates, it uses **Abstract Syntax Tree (AST) Analysis** to deep-scan your code (React, Vue, etc.), understand your API intent, and generate a custom backend in **Node.js, Python, Java, or C#** with full **Docker support**.
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
- **🌐 Multi-Language Support:** Generate a backend in your preferred stack.
|
|
16
|
-
- ✅ **Currently Supports:**
|
|
17
|
-
- Node.js (with TypeScript & Express)
|
|
18
|
-
- C# (with ASP.NET Core Web API)
|
|
19
|
-
- ⏳ **Coming Soon:**
|
|
20
|
-
- Python (with FastAPI)
|
|
21
|
-
- Java (with Spring Boot)
|
|
22
|
-
- **⚡️ Fully Automated:** A single command handles everything from project scaffolding to dependency installation.
|
|
23
|
-
- **🔧 Zero-Configuration:** No complex config files needed. Just run the command and answer a few simple questions.
|
|
24
|
-
- **🧼 Clean Code Generation:** Creates a well-structured backend, ready for you to implement your business logic.
|
|
15
|
+
---
|
|
25
16
|
|
|
26
|
-
##
|
|
17
|
+
## 🧠 The Core Technology (AST Analysis)
|
|
18
|
+
|
|
19
|
+
Why is this tool unique? It doesn't just "read" text; it "understands" structure.
|
|
20
|
+
|
|
21
|
+
We use an **Abstract Syntax Tree (AST)** engine to break down your frontend code into its fundamental components. This allows us to ignore comments, spacing, and formatting, focusing purely on the logic.
|
|
22
|
+
|
|
23
|
+
```mermaid
|
|
24
|
+
%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#007ACC', 'edgeLabelBackground':'#ffffff', 'tertiaryColor': '#f4f4f4'}}}%%
|
|
25
|
+
graph TD
|
|
26
|
+
subgraph Frontend Source
|
|
27
|
+
Code["fetch('/api/users', { method: 'POST' })"]
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
Code -->|Parser| AST[AST Node: CallExpression]
|
|
31
|
+
|
|
32
|
+
subgraph AST Logic Engine
|
|
33
|
+
AST -->|Detect| Type[Callee: fetch]
|
|
34
|
+
AST -->|Extract| Arg1[Arg 0: '/api/users']
|
|
35
|
+
AST -->|Extract| Arg2[Prop: method = 'POST']
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
subgraph Backend Generation
|
|
39
|
+
Arg1 & Arg2 -->|Map to| Route["Route: POST /api/users"]
|
|
40
|
+
Route -->|Generate| Controller["Controller: createUser()"]
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
style AST fill:#ffcc00,color:black
|
|
44
|
+
style Route fill:#00cc66,color:white
|
|
45
|
+
|
|
46
|
+
```
|
|
27
47
|
|
|
28
|
-
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## 🏗️ System Architecture
|
|
51
|
+
|
|
52
|
+
Our **3-Stage Compilation Process** ensures that one frontend codebase can generate backends in multiple languages.
|
|
53
|
+
|
|
54
|
+
```mermaid
|
|
55
|
+
graph LR
|
|
56
|
+
subgraph Input [Stage 1: Analysis]
|
|
57
|
+
A[Frontend Files] -->|AST Parsing| B(Scanner Engine)
|
|
58
|
+
end
|
|
59
|
+
subgraph Core [Stage 2: Abstraction]
|
|
60
|
+
B -->|Extracts Endpoints| C{Intermediate JSON Bridge}
|
|
61
|
+
end
|
|
62
|
+
subgraph Output [Stage 3: Generation]
|
|
63
|
+
C -->|Transpiles| D[Node.js (Express)]
|
|
64
|
+
C -->|Transpiles| E[Python (FastAPI)]
|
|
65
|
+
C -->|Transpiles| F[Java (Spring Boot)]
|
|
66
|
+
C -->|Transpiles| G[C# (.NET Core)]
|
|
67
|
+
end
|
|
68
|
+
style C fill:#ff9900,stroke:#333,stroke-width:2px,color:white
|
|
29
69
|
|
|
30
|
-
```bash
|
|
31
|
-
npm create backlist@latest
|
|
32
70
|
```
|
|
33
71
|
|
|
34
|
-
The
|
|
72
|
+
1. **Stage 1 (Analysis):** The engine scans source files (prioritizing active editor context) to build an AST.
|
|
73
|
+
2. **Stage 2 (Abstraction):** Extracted logic is converted into a universal **JSON Intermediate Representation (IR)**. This acts as a "Bridge" between languages.
|
|
74
|
+
3. **Stage 3 (Generation):** Language-specific compilers read the JSON IR and write production-ready code.
|
|
75
|
+
|
|
76
|
+
---
|
|
35
77
|
|
|
36
|
-
|
|
37
|
-
2. **Select the backend stack:** (e.g., `Node.js (TypeScript, Express)`)
|
|
38
|
-
3. **Enter the path to your frontend `src` directory:** (default: `src`)
|
|
78
|
+
## ⚡ Real-World Example
|
|
39
79
|
|
|
40
|
-
|
|
80
|
+
See how `create-backlist` transforms your code instantly.
|
|
41
81
|
|
|
42
|
-
###
|
|
82
|
+
### 1️⃣ Input (Your Frontend Code)
|
|
43
83
|
|
|
44
|
-
|
|
84
|
+
Imagine you have this simple API call in your React component:
|
|
45
85
|
|
|
46
86
|
```javascript
|
|
47
|
-
//
|
|
48
|
-
|
|
87
|
+
// user-profile.jsx
|
|
88
|
+
axios.post('/api/v1/users', { name: "Ishan", role: "Admin" });
|
|
89
|
+
|
|
49
90
|
```
|
|
50
91
|
|
|
51
|
-
|
|
92
|
+
### 2️⃣ Output (Generated Backend)
|
|
52
93
|
|
|
53
|
-
|
|
94
|
+
Running `npx create-backlist` automatically detects the route and body, generating:
|
|
54
95
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
| **NestJS CLI** | Static Scaffolding & Code Generation | Start a *new, structured* NestJS project and add parts manually. |
|
|
59
|
-
| **`create-backlist`** | **Dynamic & Context-Aware Scaffolding** | Generate a backend that is **tailor-made** for an *existing* frontend. |
|
|
96
|
+
```typescript
|
|
97
|
+
// Generated Controller (Node.js/Express)
|
|
98
|
+
import { Request, Response } from 'express';
|
|
60
99
|
|
|
61
|
-
|
|
100
|
+
export const createUsers = async (req: Request, res: Response) => {
|
|
101
|
+
try {
|
|
102
|
+
// Logic for POST /api/v1/users
|
|
103
|
+
const { name, role } = req.body;
|
|
104
|
+
res.status(201).json({ message: "Resource created successfully" });
|
|
105
|
+
} catch (error) {
|
|
106
|
+
res.status(500).json({ error: "Internal Server Error" });
|
|
107
|
+
}
|
|
108
|
+
};
|
|
62
109
|
|
|
63
|
-
|
|
110
|
+
```
|
|
64
111
|
|
|
65
|
-
|
|
112
|
+
*It also automatically updates `routes.ts` and creates a `Dockerfile`!*
|
|
66
113
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## ✨ Key Features & Innovation
|
|
117
|
+
|
|
118
|
+
| Feature | Description |
|
|
119
|
+
| --- | --- |
|
|
120
|
+
| **🤖 AST-Powered Engine** | Uses advanced static analysis to detect endpoints dynamically. Superior to Regex because it understands code structure. |
|
|
121
|
+
| **🌐 Polyglot Support** | **One Tool, Four Stacks.** <br>
|
|
122
|
+
|
|
123
|
+
<br>✅ **Node.js** (Production Ready)<br>
|
|
124
|
+
|
|
125
|
+
<br>🚀 **Python, Java, C#** (Beta Support) |
|
|
126
|
+
| **🐳 Auto-Dockerization** | Instantly generates optimized `Dockerfile` and `docker-compose.yml` for zero-config deployment. |
|
|
127
|
+
| **🧠 Active Context Analysis** | Smartly prioritizes scanning the file currently open in your VS Code editor to capture complex endpoints missed by global scans. |
|
|
128
|
+
| **⚡ Zero-Config Boilerplate** | No manual setup. It scaffolds folders, installs dependencies (`package.json`, `pom.xml`, `requirements.txt`), and starts the server. |
|
|
71
129
|
|
|
72
|
-
|
|
130
|
+
---
|
|
73
131
|
|
|
74
|
-
##
|
|
132
|
+
## 📦 Installation & Usage
|
|
75
133
|
|
|
76
|
-
|
|
134
|
+
No global installation needed. Just run this command inside your existing frontend project's root:
|
|
77
135
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
5. Open a Pull Request
|
|
136
|
+
```bash
|
|
137
|
+
npx create-backlist@latest
|
|
138
|
+
|
|
139
|
+
```
|
|
83
140
|
|
|
84
|
-
|
|
141
|
+
### 🚀 Interactive Walkthrough
|
|
85
142
|
|
|
86
|
-
|
|
143
|
+
The CLI will guide you through **3 Simple Steps**:
|
|
87
144
|
|
|
88
|
-
|
|
145
|
+
1. **Select Stack:** Choose between Node.js, Python, Java, or C#.
|
|
146
|
+
2. **Name Backend:** Choose a folder name (e.g., `my-server`).
|
|
147
|
+
3. **Locate Source:** Point to your frontend folder (e.g., `src`).
|
|
89
148
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
## 💡 Technical Comparison: Why AST?
|
|
152
|
+
|
|
153
|
+
Why did we choose Abstract Syntax Trees over simple Text Search (Regex)?
|
|
154
|
+
|
|
155
|
+
| Method | Can Read Comments? | Understands Variables? | Accuracy |
|
|
156
|
+
| --- | --- | --- | --- |
|
|
157
|
+
| **Regex (Others)** | ❌ No (Might detect commented code) | ❌ No | Low |
|
|
158
|
+
| **AST (Us)** | ✅ Yes (Ignores comments) | ✅ Yes (Trace variable values) | **High** |
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
## 🗺️ Roadmap & Research Goals
|
|
163
|
+
|
|
164
|
+
This tool is an ongoing research project aimed at automating software infrastructure.
|
|
165
|
+
|
|
166
|
+
* [x] **Phase 1: Core Engine** (AST Parsing & Node.js Support) - *Completed*
|
|
167
|
+
* [x] **Phase 2: Polyglot Architecture** (Python, Java, C# Support & Docker) - *Completed*
|
|
168
|
+
* [ ] **Phase 3: Intelligent Data Modeling** (Auto-generate Prisma/TypeORM schemas from request bodies)
|
|
169
|
+
* [ ] **Phase 4: Security Automation** (Auto-generate JWT auth and basic security headers)
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
## 🤝 Contributing & Feedback
|
|
174
|
+
|
|
175
|
+
This is an open-source project built for the developer community. We welcome contributions!
|
|
176
|
+
|
|
177
|
+
* Found a bug? [Open an Issue](https://github.com/WAH-ISHAN/create-backlist/issues).
|
|
178
|
+
* Want to contribute? [Submit a Pull Request](https://www.google.com/search?q=https://github.com/WAH-ISHAN/create-backlist/pulls).
|
|
179
|
+
|
|
180
|
+
Give us a ⭐ on GitHub if this saved you time!
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
*Built with ❤️ for builders by [W.A.H. ISHAN](https://github.com/WAH-ISHAN).*
|
|
185
|
+
|
|
186
|
+
```
|
|
94
187
|
|
|
95
188
|
---
|
|
96
189
|
|
|
97
|
-
_Built with ❤️ by [W.A.H. ISHAN](https://github.com/WAH-ISHAN)._
|
package/package.json
CHANGED
package/src/generators/node.js
CHANGED
|
@@ -85,7 +85,7 @@ async function generateNodeProject(options) {
|
|
|
85
85
|
console.log(chalk.yellow(' -> No API endpoints found. A basic project will be created.'));
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
|
|
88
|
+
// --- Step 2: Identify Models to Generate ---
|
|
89
89
|
const modelsToGenerate = new Map();
|
|
90
90
|
endpoints.forEach(ep => {
|
|
91
91
|
// 🔥 FIX: 'ep.schemaFields' තිබ්බත් නැතත් Controller එක හදන්න ඕන.
|
|
@@ -228,10 +228,22 @@ async function generateNodeProject(options) {
|
|
|
228
228
|
}
|
|
229
229
|
|
|
230
230
|
// --- Step 9: Generate Main Route File & Inject Logic into Server ---
|
|
231
|
-
//
|
|
232
|
-
|
|
231
|
+
// 🔥 FIX: Auth Endpoints ටික routes.ts එකට යවන්න එපා.
|
|
232
|
+
// මොකද ඒවා Auth.routes.ts එකෙන් වෙනම හැන්ඩ්ල් වෙනවා.
|
|
233
|
+
const nonAuthEndpoints = endpoints.filter(ep => ep.controllerName !== 'Auth');
|
|
234
|
+
|
|
235
|
+
// IMPORTANT: Pass 'nonAuthEndpoints' instead of 'endpoints'
|
|
236
|
+
await renderAndWrite(
|
|
237
|
+
getTemplatePath('node-ts-express/partials/routes.ts.ejs'),
|
|
238
|
+
path.join(destSrcDir, 'routes.ts'),
|
|
239
|
+
{ endpoints: nonAuthEndpoints, addAuth, dbType }
|
|
240
|
+
);
|
|
233
241
|
|
|
234
242
|
let serverFileContent = await fs.readFile(path.join(destSrcDir, 'server.ts'), 'utf-8');
|
|
243
|
+
|
|
244
|
+
// =========================================================================
|
|
245
|
+
// 👇 මේ ටික තමයි උඹේ Code එකෙන් Missing වෙලා තිබ්බේ. මේක නැතුව DB Connect වෙන්නේ නෑ.
|
|
246
|
+
// =========================================================================
|
|
235
247
|
let dbConnectionCode = '', swaggerInjector = '', authRoutesInjector = '';
|
|
236
248
|
|
|
237
249
|
if (dbType === 'mongoose') {
|
|
@@ -253,6 +265,8 @@ async function generateNodeProject(options) {
|
|
|
253
265
|
const listenRegex = /(app\.listen\()/;
|
|
254
266
|
serverFileContent = serverFileContent.replace(listenRegex, `${swaggerInjector}\n$1`);
|
|
255
267
|
await fs.writeFile(path.join(destSrcDir, 'server.ts'), serverFileContent);
|
|
268
|
+
// =========================================================================
|
|
269
|
+
|
|
256
270
|
|
|
257
271
|
// --- Step 10: Install Dependencies & Run Post-install Scripts ---
|
|
258
272
|
console.log(chalk.magenta(' -> Installing dependencies... This may take a moment.'));
|