wmx-os-generators 0.1.1 → 0.1.3
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 +4 -2
- package/package.json +2 -1
- package/src/scaffold.ts +5 -2
- package/templates/nextjs-postgres/.env.example +1 -0
- package/templates/nextjs-postgres/README.md +13 -0
- package/templates/nextjs-postgres/drizzle.config.ts +10 -0
- package/templates/nextjs-postgres/package.json +26 -0
- package/templates/nextjs-postgres/src/app/layout.tsx +14 -0
- package/templates/nextjs-postgres/src/app/page.tsx +8 -0
- package/templates/react-express-mongo/README.md +23 -0
- package/templates/react-express-mongo/backend/.env.example +3 -0
- package/templates/react-express-mongo/backend/package.json +23 -0
- package/templates/react-express-mongo/backend/src/db.ts +16 -0
- package/templates/react-express-mongo/backend/src/index.ts +22 -0
- package/templates/react-express-mongo/frontend/index.html +12 -0
- package/templates/react-express-mongo/frontend/package.json +21 -0
- package/templates/react-express-mongo/frontend/src/App.tsx +12 -0
- package/templates/react-express-mongo/frontend/src/main.tsx +9 -0
- package/templates/react-express-mongo/frontend/vite.config.ts +12 -0
package/dist/scaffold.d.ts
CHANGED
package/dist/scaffold.js
CHANGED
|
@@ -9,11 +9,13 @@ export class ScaffoldGenerator {
|
|
|
9
9
|
const templateName = ScaffoldGenerator.resolveTemplate(answers);
|
|
10
10
|
const templatesDir = path.join(__dirname, '..', 'templates');
|
|
11
11
|
const templatePath = path.join(templatesDir, templateName);
|
|
12
|
-
const targetPath =
|
|
12
|
+
const targetPath = answers.useCurrentDir
|
|
13
|
+
? process.cwd()
|
|
14
|
+
: path.join(process.cwd(), answers.projectName);
|
|
13
15
|
if (!(await fs.pathExists(templatePath))) {
|
|
14
16
|
throw new Error(`Template not found: ${templateName} (looked in ${templatePath})`);
|
|
15
17
|
}
|
|
16
|
-
if (await fs.pathExists(targetPath)) {
|
|
18
|
+
if (!answers.useCurrentDir && await fs.pathExists(targetPath)) {
|
|
17
19
|
throw new Error(`Directory already exists: ${targetPath}`);
|
|
18
20
|
}
|
|
19
21
|
console.log(`\nScaffolding "${answers.projectName}" from template "${templateName}"...`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wmx-os-generators",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"files": [
|
|
23
23
|
"dist",
|
|
24
24
|
"src",
|
|
25
|
+
"templates",
|
|
25
26
|
"package.json"
|
|
26
27
|
]
|
|
27
28
|
}
|
package/src/scaffold.ts
CHANGED
|
@@ -12,6 +12,7 @@ interface ScaffoldAnswers {
|
|
|
12
12
|
backend: string
|
|
13
13
|
database: string
|
|
14
14
|
packageManager: string
|
|
15
|
+
useCurrentDir?: boolean
|
|
15
16
|
features?: string[]
|
|
16
17
|
[key: string]: unknown
|
|
17
18
|
}
|
|
@@ -21,13 +22,15 @@ export class ScaffoldGenerator {
|
|
|
21
22
|
const templateName = ScaffoldGenerator.resolveTemplate(answers)
|
|
22
23
|
const templatesDir = path.join(__dirname, '..', 'templates')
|
|
23
24
|
const templatePath = path.join(templatesDir, templateName)
|
|
24
|
-
const targetPath =
|
|
25
|
+
const targetPath = answers.useCurrentDir
|
|
26
|
+
? process.cwd()
|
|
27
|
+
: path.join(process.cwd(), answers.projectName)
|
|
25
28
|
|
|
26
29
|
if (!(await fs.pathExists(templatePath))) {
|
|
27
30
|
throw new Error(`Template not found: ${templateName} (looked in ${templatePath})`)
|
|
28
31
|
}
|
|
29
32
|
|
|
30
|
-
if (await fs.pathExists(targetPath)) {
|
|
33
|
+
if (!answers.useCurrentDir && await fs.pathExists(targetPath)) {
|
|
31
34
|
throw new Error(`Directory already exists: ${targetPath}`)
|
|
32
35
|
}
|
|
33
36
|
|
|
@@ -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,26 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
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
|
+
}
|
|
@@ -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.tsx</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,23 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
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
|
+
})
|
|
@@ -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.tsx"></script>
|
|
11
|
+
</body>
|
|
12
|
+
</html>
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
}
|
|
@@ -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.tsx</code> to get started.</p>
|
|
8
|
+
</div>
|
|
9
|
+
)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export default App
|