wmx-os-generators 0.1.0 → 0.1.1
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/dist/deployGenerator.d.ts +18 -0
- package/dist/deployGenerator.js +106 -0
- package/dist/docsGenerator.d.ts +5 -0
- package/dist/docsGenerator.js +283 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/scaffold.d.ts +15 -0
- package/dist/scaffold.js +89 -0
- package/package.json +10 -5
- package/src/deployGenerator.d.ts +18 -0
- package/src/deployGenerator.js +106 -0
- package/src/docsGenerator.d.ts +5 -0
- package/src/docsGenerator.js +283 -0
- package/src/index.d.ts +3 -0
- package/src/index.js +3 -0
- package/src/scaffold.d.ts +15 -0
- package/src/scaffold.js +89 -0
- package/templates/nextjs-postgres/.env.example +0 -1
- package/templates/nextjs-postgres/README.md +0 -13
- package/templates/nextjs-postgres/drizzle.config.ts +0 -10
- package/templates/nextjs-postgres/package.json +0 -26
- package/templates/nextjs-postgres/src/app/layout.tsx +0 -14
- package/templates/nextjs-postgres/src/app/page.tsx +0 -8
- package/templates/react-express-mongo/README.md +0 -23
- package/templates/react-express-mongo/backend/.env.example +0 -3
- package/templates/react-express-mongo/backend/package.json +0 -23
- package/templates/react-express-mongo/backend/src/db.ts +0 -16
- package/templates/react-express-mongo/backend/src/index.ts +0 -22
- package/templates/react-express-mongo/frontend/index.html +0 -12
- package/templates/react-express-mongo/frontend/package.json +0 -21
- package/templates/react-express-mongo/frontend/src/App.tsx +0 -12
- package/templates/react-express-mongo/frontend/src/main.tsx +0 -9
- package/templates/react-express-mongo/frontend/vite.config.ts +0 -12
- package/tsconfig.json +0 -8
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { AnalysisResult, RouteEntry } from 'wmx-os-scanners';
|
|
2
|
+
export declare function generateAnalysis(result: AnalysisResult, outputDir: string): Promise<void>;
|
|
3
|
+
export declare function generateReadme(cwd: string): Promise<string>;
|
|
4
|
+
export declare function generateArchitectureDocs(analysis: AnalysisResult): string;
|
|
5
|
+
export declare function generateApiDocs(routes: RouteEntry[]): string;
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
import fs from 'fs-extra';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
// ── Existing helpers ──────────────────────────────────────────────────────────
|
|
4
|
+
function topImports(imports, n = 10) {
|
|
5
|
+
const counts = new Map();
|
|
6
|
+
for (const imp of imports) {
|
|
7
|
+
counts.set(imp.to, (counts.get(imp.to) ?? 0) + 1);
|
|
8
|
+
}
|
|
9
|
+
return [...counts.entries()]
|
|
10
|
+
.sort((a, b) => b[1] - a[1])
|
|
11
|
+
.slice(0, n)
|
|
12
|
+
.map(([module, count]) => ({ module, count }));
|
|
13
|
+
}
|
|
14
|
+
export async function generateAnalysis(result, outputDir) {
|
|
15
|
+
await fs.ensureDir(outputDir);
|
|
16
|
+
const top = topImports(result.imports);
|
|
17
|
+
const routeTable = result.routes.length > 0
|
|
18
|
+
? [
|
|
19
|
+
'| Method | Path | File | Line |',
|
|
20
|
+
'|--------|------|------|------|',
|
|
21
|
+
...result.routes.map(r => `| \`${r.method}\` | \`${r.path}\` | ${r.file} | ${r.line} |`)
|
|
22
|
+
].join('\n')
|
|
23
|
+
: '_No Express or Next.js routes detected._';
|
|
24
|
+
const importList = top.length > 0
|
|
25
|
+
? top.map((t, i) => `${i + 1}. \`${t.module}\` — imported **${t.count}** time${t.count === 1 ? '' : 's'}`).join('\n')
|
|
26
|
+
: '_No imports detected._';
|
|
27
|
+
const md = `# Project Architecture
|
|
28
|
+
|
|
29
|
+
_Generated by wmx analyze on ${new Date().toISOString()}_
|
|
30
|
+
|
|
31
|
+
## Folder Structure
|
|
32
|
+
|
|
33
|
+
\`\`\`
|
|
34
|
+
${result.folderTree}
|
|
35
|
+
\`\`\`
|
|
36
|
+
|
|
37
|
+
## API Routes
|
|
38
|
+
|
|
39
|
+
${routeTable}
|
|
40
|
+
|
|
41
|
+
## Top Imports
|
|
42
|
+
|
|
43
|
+
${importList}
|
|
44
|
+
|
|
45
|
+
## Exports Summary
|
|
46
|
+
|
|
47
|
+
Total exported symbols: **${result.exports.length}**
|
|
48
|
+
|
|
49
|
+
| Type | Count |
|
|
50
|
+
|------|-------|
|
|
51
|
+
| Functions | ${result.exports.filter(e => e.type === 'function').length} |
|
|
52
|
+
| Classes | ${result.exports.filter(e => e.type === 'class').length} |
|
|
53
|
+
| Constants | ${result.exports.filter(e => e.type === 'const').length} |
|
|
54
|
+
| Types | ${result.exports.filter(e => e.type === 'type').length} |
|
|
55
|
+
`;
|
|
56
|
+
await fs.writeFile(path.join(outputDir, 'analysis.md'), md, 'utf8');
|
|
57
|
+
await fs.writeFile(path.join(outputDir, 'analysis.json'), JSON.stringify(result, null, 2), 'utf8');
|
|
58
|
+
}
|
|
59
|
+
// ── Project structure tree helper (for generateReadme) ────────────────────────
|
|
60
|
+
const PROJ_IGNORE_DIRS = new Set(['node_modules', '.git', 'dist', '.wmx']);
|
|
61
|
+
const PROJ_IGNORE_FILES = new Set(['.env', '.env.example']);
|
|
62
|
+
async function buildProjectStructure(dir, maxDepth, depth = 0) {
|
|
63
|
+
if (depth >= maxDepth)
|
|
64
|
+
return '';
|
|
65
|
+
let entries;
|
|
66
|
+
try {
|
|
67
|
+
entries = await fs.readdir(dir);
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
return '';
|
|
71
|
+
}
|
|
72
|
+
const filtered = entries.filter(e => {
|
|
73
|
+
if (PROJ_IGNORE_DIRS.has(e))
|
|
74
|
+
return false;
|
|
75
|
+
if (PROJ_IGNORE_FILES.has(e))
|
|
76
|
+
return false;
|
|
77
|
+
if (/\.lock$/.test(e))
|
|
78
|
+
return false;
|
|
79
|
+
return true;
|
|
80
|
+
});
|
|
81
|
+
filtered.sort();
|
|
82
|
+
const indent = ' '.repeat(depth);
|
|
83
|
+
const lines = [];
|
|
84
|
+
for (const entry of filtered) {
|
|
85
|
+
const fullPath = path.join(dir, entry);
|
|
86
|
+
let isDir = false;
|
|
87
|
+
try {
|
|
88
|
+
const stat = await fs.stat(fullPath);
|
|
89
|
+
isDir = stat.isDirectory();
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
if (isDir) {
|
|
95
|
+
lines.push(`${indent}${entry}/`);
|
|
96
|
+
const sub = await buildProjectStructure(fullPath, maxDepth, depth + 1);
|
|
97
|
+
if (sub)
|
|
98
|
+
lines.push(sub);
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
lines.push(`${indent}${entry}`);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return lines.join('\n');
|
|
105
|
+
}
|
|
106
|
+
// ── generateReadme ────────────────────────────────────────────────────────────
|
|
107
|
+
export async function generateReadme(cwd) {
|
|
108
|
+
// Read package.json
|
|
109
|
+
let pkg = {};
|
|
110
|
+
try {
|
|
111
|
+
const raw = await fs.readFile(path.join(cwd, 'package.json'), 'utf8');
|
|
112
|
+
pkg = JSON.parse(raw);
|
|
113
|
+
}
|
|
114
|
+
catch { /* missing or invalid — use defaults */ }
|
|
115
|
+
// Read .wmxrc.json
|
|
116
|
+
let wmxrc = {};
|
|
117
|
+
try {
|
|
118
|
+
const raw = await fs.readFile(path.join(cwd, '.wmxrc.json'), 'utf8');
|
|
119
|
+
wmxrc = JSON.parse(raw);
|
|
120
|
+
}
|
|
121
|
+
catch { /* missing — use defaults */ }
|
|
122
|
+
// Read .env.example
|
|
123
|
+
let envExampleRaw = '';
|
|
124
|
+
try {
|
|
125
|
+
envExampleRaw = await fs.readFile(path.join(cwd, '.env.example'), 'utf8');
|
|
126
|
+
}
|
|
127
|
+
catch { /* missing — handled below */ }
|
|
128
|
+
// 1. Title
|
|
129
|
+
const title = pkg.name ?? 'My Project';
|
|
130
|
+
// 2. Description
|
|
131
|
+
const description = pkg.description ?? 'A project built with wmx';
|
|
132
|
+
// 3. Tech Stack
|
|
133
|
+
const deps = pkg.dependencies ?? {};
|
|
134
|
+
const devDeps = pkg.devDependencies ?? {};
|
|
135
|
+
const allDeps = { ...deps, ...devDeps };
|
|
136
|
+
const techMap = [
|
|
137
|
+
['react', 'React'],
|
|
138
|
+
['express', 'Express'],
|
|
139
|
+
['mongoose', 'MongoDB'],
|
|
140
|
+
['next', 'Next.js'],
|
|
141
|
+
['pg', 'PostgreSQL'],
|
|
142
|
+
['vue', 'Vue'],
|
|
143
|
+
];
|
|
144
|
+
const detectedTech = techMap
|
|
145
|
+
.filter(([key]) => key in allDeps)
|
|
146
|
+
.map(([, label]) => `- ${label}`);
|
|
147
|
+
const techStackSection = detectedTech.length > 0
|
|
148
|
+
? detectedTech.join('\n')
|
|
149
|
+
: '_No tech stack detected._';
|
|
150
|
+
// 4. Prerequisites
|
|
151
|
+
const packageManager = wmxrc.packageManager;
|
|
152
|
+
const prereqItems = ['- Node.js >= 18', ...(packageManager ? [`- ${packageManager}`] : [])];
|
|
153
|
+
const prerequisitesSection = prereqItems.join('\n');
|
|
154
|
+
// 5. Installation
|
|
155
|
+
const repoObj = pkg.repository;
|
|
156
|
+
const repoUrl = typeof repoObj === 'string'
|
|
157
|
+
? repoObj
|
|
158
|
+
: (repoObj?.url ?? 'https://github.com/your-org/your-repo');
|
|
159
|
+
const projectName = pkg.name ?? 'your-project';
|
|
160
|
+
const installCmd = packageManager === 'pnpm' ? 'pnpm install'
|
|
161
|
+
: packageManager === 'bun' ? 'bun install'
|
|
162
|
+
: packageManager === 'yarn' ? 'yarn install'
|
|
163
|
+
: 'npm install';
|
|
164
|
+
// 6. Environment Variables
|
|
165
|
+
const envKeys = envExampleRaw
|
|
166
|
+
.split('\n')
|
|
167
|
+
.filter(line => line.includes('=') && !line.trimStart().startsWith('#'))
|
|
168
|
+
.map(line => line.split('=')[0].trim())
|
|
169
|
+
.filter(Boolean);
|
|
170
|
+
const envSection = envKeys.length > 0
|
|
171
|
+
? '```bash\n' + envKeys.map(k => `${k}=`).join('\n') + '\n```'
|
|
172
|
+
: '_No environment variables required._';
|
|
173
|
+
// 7. Available Scripts
|
|
174
|
+
const scripts = pkg.scripts ?? {};
|
|
175
|
+
const scriptEntries = Object.entries(scripts);
|
|
176
|
+
const scriptsSection = scriptEntries.length > 0
|
|
177
|
+
? scriptEntries.map(([key, val]) => `- \`npm run ${key}\` — ${val}`).join('\n')
|
|
178
|
+
: '_No scripts defined._';
|
|
179
|
+
// 8. Project Structure (2 levels deep)
|
|
180
|
+
const structure = await buildProjectStructure(cwd, 2);
|
|
181
|
+
// 9. License
|
|
182
|
+
const license = pkg.license ?? 'MIT';
|
|
183
|
+
return `# ${title}
|
|
184
|
+
|
|
185
|
+
${description}
|
|
186
|
+
|
|
187
|
+
## Tech Stack
|
|
188
|
+
|
|
189
|
+
${techStackSection}
|
|
190
|
+
|
|
191
|
+
## Prerequisites
|
|
192
|
+
|
|
193
|
+
${prerequisitesSection}
|
|
194
|
+
|
|
195
|
+
## Installation
|
|
196
|
+
|
|
197
|
+
\`\`\`bash
|
|
198
|
+
1. git clone ${repoUrl}
|
|
199
|
+
2. cd ${projectName}
|
|
200
|
+
3. ${installCmd}
|
|
201
|
+
\`\`\`
|
|
202
|
+
|
|
203
|
+
## Environment Variables
|
|
204
|
+
|
|
205
|
+
${envSection}
|
|
206
|
+
|
|
207
|
+
## Available Scripts
|
|
208
|
+
|
|
209
|
+
${scriptsSection}
|
|
210
|
+
|
|
211
|
+
## Project Structure
|
|
212
|
+
|
|
213
|
+
\`\`\`
|
|
214
|
+
${structure}
|
|
215
|
+
\`\`\`
|
|
216
|
+
|
|
217
|
+
## License
|
|
218
|
+
|
|
219
|
+
This project is licensed under the ${license} license.
|
|
220
|
+
`;
|
|
221
|
+
}
|
|
222
|
+
// ── generateArchitectureDocs ──────────────────────────────────────────────────
|
|
223
|
+
export function generateArchitectureDocs(analysis) {
|
|
224
|
+
// Derive a unique source-file count from the data available in AnalysisResult
|
|
225
|
+
const uniqueFiles = new Set([
|
|
226
|
+
...analysis.imports.map(i => i.from),
|
|
227
|
+
...analysis.exports.map(e => e.file),
|
|
228
|
+
...analysis.routes.map(r => r.file),
|
|
229
|
+
]).size;
|
|
230
|
+
// API Routes table
|
|
231
|
+
const routeTable = analysis.routes.length > 0
|
|
232
|
+
? [
|
|
233
|
+
'| Method | Endpoint | File | Description |',
|
|
234
|
+
'|--------|----------|------|-------------|',
|
|
235
|
+
...analysis.routes.map(r => `| \`${r.method}\` | \`${r.path}\` | ${r.file} | |`)
|
|
236
|
+
].join('\n')
|
|
237
|
+
: '_No API routes detected._';
|
|
238
|
+
// Key Dependencies — external (non-relative) import targets, deduped
|
|
239
|
+
const externalDeps = [...new Set(analysis.imports
|
|
240
|
+
.map(i => i.to)
|
|
241
|
+
.filter(m => !m.startsWith('.') && !m.startsWith('/')))].sort();
|
|
242
|
+
const depsSection = externalDeps.length > 0
|
|
243
|
+
? externalDeps.map(d => `- \`${d}\``).join('\n')
|
|
244
|
+
: '_No external dependencies detected._';
|
|
245
|
+
return `# Project Architecture
|
|
246
|
+
|
|
247
|
+
## Overview
|
|
248
|
+
|
|
249
|
+
This document describes the architecture of the project.
|
|
250
|
+
|
|
251
|
+
Analyzed **${uniqueFiles}** source files.
|
|
252
|
+
|
|
253
|
+
## Folder Structure
|
|
254
|
+
|
|
255
|
+
\`\`\`
|
|
256
|
+
${analysis.folderTree}
|
|
257
|
+
\`\`\`
|
|
258
|
+
|
|
259
|
+
## API Routes
|
|
260
|
+
|
|
261
|
+
${routeTable}
|
|
262
|
+
|
|
263
|
+
## Key Dependencies
|
|
264
|
+
|
|
265
|
+
${depsSection}
|
|
266
|
+
`;
|
|
267
|
+
}
|
|
268
|
+
// ── generateApiDocs ───────────────────────────────────────────────────────────
|
|
269
|
+
export function generateApiDocs(routes) {
|
|
270
|
+
const routeTable = routes.length > 0
|
|
271
|
+
? [
|
|
272
|
+
'| Method | Endpoint | File | Description |',
|
|
273
|
+
'|--------|----------|------|-------------|',
|
|
274
|
+
...routes.map(r => `| \`${r.method}\` | \`${r.path}\` | ${r.file} | |`)
|
|
275
|
+
].join('\n')
|
|
276
|
+
: '_No routes detected._';
|
|
277
|
+
return `# API Reference
|
|
278
|
+
|
|
279
|
+
${routeTable}
|
|
280
|
+
|
|
281
|
+
_Update the Description column with endpoint-specific documentation._
|
|
282
|
+
`;
|
|
283
|
+
}
|
package/src/index.d.ts
ADDED
package/src/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
interface ScaffoldAnswers {
|
|
2
|
+
projectName: string;
|
|
3
|
+
framework: string;
|
|
4
|
+
backend: string;
|
|
5
|
+
database: string;
|
|
6
|
+
packageManager: string;
|
|
7
|
+
features?: string[];
|
|
8
|
+
[key: string]: unknown;
|
|
9
|
+
}
|
|
10
|
+
export declare class ScaffoldGenerator {
|
|
11
|
+
static generate(answers: ScaffoldAnswers): Promise<void>;
|
|
12
|
+
private static resolveTemplate;
|
|
13
|
+
private static replaceInAllFiles;
|
|
14
|
+
}
|
|
15
|
+
export {};
|
package/src/scaffold.js
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { fileURLToPath } from 'url';
|
|
3
|
+
import fs from 'fs-extra';
|
|
4
|
+
import { execa } from 'execa';
|
|
5
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
6
|
+
const __dirname = path.dirname(__filename);
|
|
7
|
+
export class ScaffoldGenerator {
|
|
8
|
+
static async generate(answers) {
|
|
9
|
+
const templateName = ScaffoldGenerator.resolveTemplate(answers);
|
|
10
|
+
const templatesDir = path.join(__dirname, '..', 'templates');
|
|
11
|
+
const templatePath = path.join(templatesDir, templateName);
|
|
12
|
+
const targetPath = path.join(process.cwd(), answers.projectName);
|
|
13
|
+
if (!(await fs.pathExists(templatePath))) {
|
|
14
|
+
throw new Error(`Template not found: ${templateName} (looked in ${templatePath})`);
|
|
15
|
+
}
|
|
16
|
+
if (await fs.pathExists(targetPath)) {
|
|
17
|
+
throw new Error(`Directory already exists: ${targetPath}`);
|
|
18
|
+
}
|
|
19
|
+
console.log(`\nScaffolding "${answers.projectName}" from template "${templateName}"...`);
|
|
20
|
+
await fs.copy(templatePath, targetPath);
|
|
21
|
+
await ScaffoldGenerator.replaceInAllFiles(targetPath, '__PROJECT_NAME__', answers.projectName);
|
|
22
|
+
const wmxrc = {
|
|
23
|
+
projectName: answers.projectName,
|
|
24
|
+
framework: answers.framework,
|
|
25
|
+
backend: answers.backend,
|
|
26
|
+
database: answers.database,
|
|
27
|
+
packageManager: answers.packageManager,
|
|
28
|
+
features: answers.features ?? [],
|
|
29
|
+
scaffoldedAt: new Date().toISOString(),
|
|
30
|
+
template: templateName
|
|
31
|
+
};
|
|
32
|
+
await fs.writeJson(path.join(targetPath, '.wmxrc.json'), wmxrc, { spaces: 2 });
|
|
33
|
+
console.log(`\nRunning ${answers.packageManager} install...`);
|
|
34
|
+
try {
|
|
35
|
+
if (templateName === 'react-express-mongo') {
|
|
36
|
+
await execa(answers.packageManager, ['install'], {
|
|
37
|
+
cwd: path.join(targetPath, 'frontend'),
|
|
38
|
+
stdio: 'inherit'
|
|
39
|
+
});
|
|
40
|
+
await execa(answers.packageManager, ['install'], {
|
|
41
|
+
cwd: path.join(targetPath, 'backend'),
|
|
42
|
+
stdio: 'inherit'
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
await execa(answers.packageManager, ['install'], {
|
|
47
|
+
cwd: targetPath,
|
|
48
|
+
stdio: 'inherit'
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
catch (err) {
|
|
53
|
+
console.warn(`\nPackage install failed (you can run it manually): ${err.message}`);
|
|
54
|
+
}
|
|
55
|
+
console.log(`\n✅ Project "${answers.projectName}" created at ${targetPath}`);
|
|
56
|
+
console.log(` cd ${answers.projectName} and follow the README to get started.\n`);
|
|
57
|
+
}
|
|
58
|
+
static resolveTemplate(answers) {
|
|
59
|
+
const fw = answers.framework?.toLowerCase() ?? '';
|
|
60
|
+
const be = answers.backend?.toLowerCase() ?? '';
|
|
61
|
+
const db = answers.database?.toLowerCase() ?? '';
|
|
62
|
+
if (fw.includes('next'))
|
|
63
|
+
return 'nextjs-postgres';
|
|
64
|
+
if (fw.includes('react') && be.includes('express') && db.includes('mongo'))
|
|
65
|
+
return 'react-express-mongo';
|
|
66
|
+
return 'react-express-mongo';
|
|
67
|
+
}
|
|
68
|
+
static async replaceInAllFiles(dir, search, replacement) {
|
|
69
|
+
const entries = await fs.readdir(dir, { withFileTypes: true });
|
|
70
|
+
for (const entry of entries) {
|
|
71
|
+
const fullPath = path.join(dir, entry.name);
|
|
72
|
+
if (entry.isDirectory()) {
|
|
73
|
+
await ScaffoldGenerator.replaceInAllFiles(fullPath, search, replacement);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
try {
|
|
77
|
+
const content = await fs.readFile(fullPath, 'utf8');
|
|
78
|
+
if (content.includes(search)) {
|
|
79
|
+
const updated = content.split(search).join(replacement);
|
|
80
|
+
await fs.writeFile(fullPath, updated, 'utf8');
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
// Skip binary files silently
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
DATABASE_URL=
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
# __PROJECT_NAME__
|
|
2
|
-
|
|
3
|
-
A Next.js 14 + PostgreSQL + Drizzle ORM starter, scaffolded by WMX CLI.
|
|
4
|
-
|
|
5
|
-
## Getting started
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
cp .env.example .env
|
|
9
|
-
# Set DATABASE_URL in .env (e.g. postgresql://user:pass@localhost:5432/dbname)
|
|
10
|
-
npm install
|
|
11
|
-
npm run db:push # push schema to your database
|
|
12
|
-
npm run dev # start dev server on http://localhost:3000
|
|
13
|
-
```
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "__PROJECT_NAME__",
|
|
3
|
-
"version": "0.1.0",
|
|
4
|
-
"scripts": {
|
|
5
|
-
"dev": "next dev",
|
|
6
|
-
"build": "next build",
|
|
7
|
-
"start": "next start",
|
|
8
|
-
"db:generate": "drizzle-kit generate",
|
|
9
|
-
"db:push": "drizzle-kit push"
|
|
10
|
-
},
|
|
11
|
-
"dependencies": {
|
|
12
|
-
"next": "^14.0.0",
|
|
13
|
-
"react": "^18.2.0",
|
|
14
|
-
"react-dom": "^18.2.0",
|
|
15
|
-
"pg": "^8.11.0",
|
|
16
|
-
"drizzle-orm": "^0.29.0"
|
|
17
|
-
},
|
|
18
|
-
"devDependencies": {
|
|
19
|
-
"@types/node": "^20.0.0",
|
|
20
|
-
"@types/pg": "^8.10.0",
|
|
21
|
-
"@types/react": "^18.2.0",
|
|
22
|
-
"@types/react-dom": "^18.2.0",
|
|
23
|
-
"drizzle-kit": "^0.20.0",
|
|
24
|
-
"typescript": "^5.0.0"
|
|
25
|
-
}
|
|
26
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { Metadata } from 'next'
|
|
2
|
-
|
|
3
|
-
export const metadata: Metadata = {
|
|
4
|
-
title: '__PROJECT_NAME__',
|
|
5
|
-
description: 'Built with Next.js 14 and PostgreSQL'
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export default function RootLayout({ children }: { children: React.ReactNode }) {
|
|
9
|
-
return (
|
|
10
|
-
<html lang="en">
|
|
11
|
-
<body>{children}</body>
|
|
12
|
-
</html>
|
|
13
|
-
)
|
|
14
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export default function Home() {
|
|
2
|
-
return (
|
|
3
|
-
<main style={{ fontFamily: 'sans-serif', textAlign: 'center', marginTop: '4rem' }}>
|
|
4
|
-
<h1>Welcome to __PROJECT_NAME__</h1>
|
|
5
|
-
<p>Next.js 14 + PostgreSQL + Drizzle ORM starter — edit <code>src/app/page.tsx</code> to begin.</p>
|
|
6
|
-
</main>
|
|
7
|
-
)
|
|
8
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
# __PROJECT_NAME__
|
|
2
|
-
|
|
3
|
-
A full-stack starter built with React 18 + Express + MongoDB, scaffolded by WMX CLI.
|
|
4
|
-
|
|
5
|
-
## Getting started
|
|
6
|
-
|
|
7
|
-
### Backend
|
|
8
|
-
```bash
|
|
9
|
-
cd backend
|
|
10
|
-
cp .env.example .env
|
|
11
|
-
# Fill in MONGODB_URI and JWT_SECRET in .env
|
|
12
|
-
npm install
|
|
13
|
-
npm run dev
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
### Frontend
|
|
17
|
-
```bash
|
|
18
|
-
cd frontend
|
|
19
|
-
npm install
|
|
20
|
-
npm run dev
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
The frontend runs on http://localhost:5173 and proxies `/api` requests to the backend on port 5000.
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "__PROJECT_NAME__-backend",
|
|
3
|
-
"version": "0.1.0",
|
|
4
|
-
"type": "commonjs",
|
|
5
|
-
"scripts": {
|
|
6
|
-
"dev": "ts-node-dev --respawn src/index.ts",
|
|
7
|
-
"build": "tsc",
|
|
8
|
-
"start": "node dist/index.js"
|
|
9
|
-
},
|
|
10
|
-
"dependencies": {
|
|
11
|
-
"cors": "^2.8.5",
|
|
12
|
-
"dotenv": "^16.0.0",
|
|
13
|
-
"express": "^4.18.0",
|
|
14
|
-
"mongoose": "^8.0.0"
|
|
15
|
-
},
|
|
16
|
-
"devDependencies": {
|
|
17
|
-
"@types/cors": "^2.8.13",
|
|
18
|
-
"@types/express": "^4.17.21",
|
|
19
|
-
"@types/node": "^20.0.0",
|
|
20
|
-
"ts-node-dev": "^2.0.0",
|
|
21
|
-
"typescript": "^5.0.0"
|
|
22
|
-
}
|
|
23
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import mongoose from 'mongoose'
|
|
2
|
-
|
|
3
|
-
export async function connectDB(): Promise<void> {
|
|
4
|
-
const uri = process.env.MONGODB_URI
|
|
5
|
-
if (!uri) {
|
|
6
|
-
console.warn('MONGODB_URI not set — skipping DB connection')
|
|
7
|
-
return
|
|
8
|
-
}
|
|
9
|
-
try {
|
|
10
|
-
await mongoose.connect(uri)
|
|
11
|
-
console.log('MongoDB connected')
|
|
12
|
-
} catch (err) {
|
|
13
|
-
console.error('MongoDB connection error:', err)
|
|
14
|
-
process.exit(1)
|
|
15
|
-
}
|
|
16
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import express from 'express'
|
|
2
|
-
import cors from 'cors'
|
|
3
|
-
import dotenv from 'dotenv'
|
|
4
|
-
import { connectDB } from './db'
|
|
5
|
-
|
|
6
|
-
dotenv.config()
|
|
7
|
-
|
|
8
|
-
const app = express()
|
|
9
|
-
const PORT = process.env.PORT || 5000
|
|
10
|
-
|
|
11
|
-
app.use(cors())
|
|
12
|
-
app.use(express.json())
|
|
13
|
-
|
|
14
|
-
app.get('/api/health', (_req, res) => {
|
|
15
|
-
res.json({ status: 'ok', project: '__PROJECT_NAME__' })
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
connectDB().then(() => {
|
|
19
|
-
app.listen(PORT, () => {
|
|
20
|
-
console.log(`__PROJECT_NAME__ backend running on http://localhost:${PORT}`)
|
|
21
|
-
})
|
|
22
|
-
})
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
-
<title>__PROJECT_NAME__</title>
|
|
7
|
-
</head>
|
|
8
|
-
<body>
|
|
9
|
-
<div id="root"></div>
|
|
10
|
-
<script type="module" src="/src/main.tsx"></script>
|
|
11
|
-
</body>
|
|
12
|
-
</html>
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "__PROJECT_NAME__-frontend",
|
|
3
|
-
"version": "0.1.0",
|
|
4
|
-
"type": "module",
|
|
5
|
-
"scripts": {
|
|
6
|
-
"dev": "vite",
|
|
7
|
-
"build": "tsc && vite build",
|
|
8
|
-
"preview": "vite preview"
|
|
9
|
-
},
|
|
10
|
-
"dependencies": {
|
|
11
|
-
"react": "^18.2.0",
|
|
12
|
-
"react-dom": "^18.2.0"
|
|
13
|
-
},
|
|
14
|
-
"devDependencies": {
|
|
15
|
-
"@types/react": "^18.2.0",
|
|
16
|
-
"@types/react-dom": "^18.2.0",
|
|
17
|
-
"@vitejs/plugin-react": "^4.0.0",
|
|
18
|
-
"typescript": "^5.0.0",
|
|
19
|
-
"vite": "^5.0.0"
|
|
20
|
-
}
|
|
21
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
|
|
3
|
-
function App() {
|
|
4
|
-
return (
|
|
5
|
-
<div style={{ fontFamily: 'sans-serif', textAlign: 'center', marginTop: '4rem' }}>
|
|
6
|
-
<h1>Welcome to __PROJECT_NAME__</h1>
|
|
7
|
-
<p>React + Express + MongoDB starter — edit <code>src/App.tsx</code> to get started.</p>
|
|
8
|
-
</div>
|
|
9
|
-
)
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export default App
|