wmx-os-generators 0.1.3 → 0.1.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/dist/scaffold.d.ts +1 -0
- package/dist/scaffold.js +6 -4
- package/package.json +3 -3
- package/src/scaffold.ts +7 -3
- package/templates/nextjs-postgres-js/.env.example +1 -0
- package/templates/nextjs-postgres-js/README.md +13 -0
- package/templates/nextjs-postgres-js/drizzle.config.js +9 -0
- package/templates/nextjs-postgres-js/package.json +21 -0
- package/templates/nextjs-postgres-js/src/app/layout.jsx +12 -0
- package/templates/nextjs-postgres-js/src/app/page.jsx +8 -0
- package/templates/react-express-mongo-js/README.md +23 -0
- package/templates/react-express-mongo-js/backend/.env.example +2 -0
- package/templates/react-express-mongo-js/backend/package.json +18 -0
- package/templates/react-express-mongo-js/backend/src/db.js +18 -0
- package/templates/react-express-mongo-js/backend/src/index.js +22 -0
- package/templates/react-express-mongo-js/frontend/index.html +12 -0
- package/templates/react-express-mongo-js/frontend/package.json +18 -0
- package/templates/react-express-mongo-js/frontend/src/App.jsx +12 -0
- package/templates/react-express-mongo-js/frontend/src/main.jsx +9 -0
- package/templates/react-express-mongo-js/frontend/vite.config.js +12 -0
package/dist/scaffold.d.ts
CHANGED
package/dist/scaffold.js
CHANGED
|
@@ -61,11 +61,13 @@ export class ScaffoldGenerator {
|
|
|
61
61
|
const fw = answers.framework?.toLowerCase() ?? '';
|
|
62
62
|
const be = answers.backend?.toLowerCase() ?? '';
|
|
63
63
|
const db = answers.database?.toLowerCase() ?? '';
|
|
64
|
+
const isJs = answers.language?.toLowerCase() === 'javascript';
|
|
64
65
|
if (fw.includes('next'))
|
|
65
|
-
return 'nextjs-postgres';
|
|
66
|
-
if (fw.includes('react') && be.includes('express') && db.includes('mongo'))
|
|
67
|
-
return 'react-express-mongo';
|
|
68
|
-
|
|
66
|
+
return isJs ? 'nextjs-postgres-js' : 'nextjs-postgres';
|
|
67
|
+
if (fw.includes('react') && be.includes('express') && db.includes('mongo')) {
|
|
68
|
+
return isJs ? 'react-express-mongo-js' : 'react-express-mongo';
|
|
69
|
+
}
|
|
70
|
+
return isJs ? 'react-express-mongo-js' : 'react-express-mongo';
|
|
69
71
|
}
|
|
70
72
|
static async replaceInAllFiles(dir, search, replacement) {
|
|
71
73
|
const entries = await fs.readdir(dir, { withFileTypes: true });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wmx-os-generators",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"execa": "^8.0.0",
|
|
13
13
|
"fs-extra": "^11.0.0",
|
|
14
|
-
"wmx-os-core": "^0.1.
|
|
15
|
-
"wmx-os-scanners": "^0.1.
|
|
14
|
+
"wmx-os-core": "^0.1.4",
|
|
15
|
+
"wmx-os-scanners": "^0.1.2"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"@types/fs-extra": "^11.0.0",
|
package/src/scaffold.ts
CHANGED
|
@@ -8,6 +8,7 @@ const __dirname = path.dirname(__filename)
|
|
|
8
8
|
|
|
9
9
|
interface ScaffoldAnswers {
|
|
10
10
|
projectName: string
|
|
11
|
+
language?: string
|
|
11
12
|
framework: string
|
|
12
13
|
backend: string
|
|
13
14
|
database: string
|
|
@@ -81,10 +82,13 @@ export class ScaffoldGenerator {
|
|
|
81
82
|
const fw = answers.framework?.toLowerCase() ?? ''
|
|
82
83
|
const be = answers.backend?.toLowerCase() ?? ''
|
|
83
84
|
const db = answers.database?.toLowerCase() ?? ''
|
|
85
|
+
const isJs = answers.language?.toLowerCase() === 'javascript'
|
|
84
86
|
|
|
85
|
-
if (fw.includes('next')) return 'nextjs-postgres'
|
|
86
|
-
if (fw.includes('react') && be.includes('express') && db.includes('mongo'))
|
|
87
|
-
|
|
87
|
+
if (fw.includes('next')) return isJs ? 'nextjs-postgres-js' : 'nextjs-postgres'
|
|
88
|
+
if (fw.includes('react') && be.includes('express') && db.includes('mongo')) {
|
|
89
|
+
return isJs ? 'react-express-mongo-js' : 'react-express-mongo'
|
|
90
|
+
}
|
|
91
|
+
return isJs ? 'react-express-mongo-js' : 'react-express-mongo'
|
|
88
92
|
}
|
|
89
93
|
|
|
90
94
|
private static async replaceInAllFiles(dir: string, search: string, replacement: string): Promise<void> {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
DATABASE_URL=
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
```
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
"drizzle-kit": "^0.20.0"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
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.jsx</code> to begin.</p>
|
|
6
|
+
</main>
|
|
7
|
+
)
|
|
8
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
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.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "__PROJECT_NAME__-backend",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "commonjs",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"dev": "nodemon src/index.js",
|
|
7
|
+
"start": "node src/index.js"
|
|
8
|
+
},
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"cors": "^2.8.5",
|
|
11
|
+
"dotenv": "^16.0.0",
|
|
12
|
+
"express": "^4.18.0",
|
|
13
|
+
"mongoose": "^8.0.0"
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"nodemon": "^3.0.0"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const mongoose = require('mongoose')
|
|
2
|
+
|
|
3
|
+
async function connectDB() {
|
|
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
|
+
}
|
|
17
|
+
|
|
18
|
+
module.exports = { connectDB }
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const express = require('express')
|
|
2
|
+
const cors = require('cors')
|
|
3
|
+
const dotenv = require('dotenv')
|
|
4
|
+
const { connectDB } = require('./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
|
+
})
|
|
@@ -0,0 +1,12 @@
|
|
|
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.jsx"></script>
|
|
11
|
+
</body>
|
|
12
|
+
</html>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "__PROJECT_NAME__-frontend",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"dev": "vite",
|
|
7
|
+
"build": "vite build",
|
|
8
|
+
"preview": "vite preview"
|
|
9
|
+
},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"react": "^18.2.0",
|
|
12
|
+
"react-dom": "^18.2.0"
|
|
13
|
+
},
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"@vitejs/plugin-react": "^4.0.0",
|
|
16
|
+
"vite": "^5.0.0"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
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.jsx</code> to get started.</p>
|
|
8
|
+
</div>
|
|
9
|
+
)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export default App
|