wmx-os-generators 0.1.3 → 0.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.
@@ -1,5 +1,6 @@
1
1
  interface ScaffoldAnswers {
2
2
  projectName: string;
3
+ language?: string;
3
4
  framework: string;
4
5
  backend: string;
5
6
  database: string;
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
- return 'react-express-mongo';
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",
3
+ "version": "0.1.4",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
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')) return 'react-express-mongo'
87
- return 'react-express-mongo'
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,9 @@
1
+ /** @type {import('drizzle-kit').Config} */
2
+ export default {
3
+ schema: './src/db/schema.js',
4
+ out: './drizzle',
5
+ driver: 'pg',
6
+ dbCredentials: {
7
+ connectionString: process.env.DATABASE_URL
8
+ }
9
+ }
@@ -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,12 @@
1
+ export const metadata = {
2
+ title: '__PROJECT_NAME__',
3
+ description: 'Built with Next.js 14 and PostgreSQL'
4
+ }
5
+
6
+ export default function RootLayout({ children }) {
7
+ return (
8
+ <html lang="en">
9
+ <body>{children}</body>
10
+ </html>
11
+ )
12
+ }
@@ -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,2 @@
1
+ PORT=5000
2
+ MONGODB_URI=mongodb://localhost:27017/__PROJECT_NAME__
@@ -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
@@ -0,0 +1,9 @@
1
+ import React from 'react'
2
+ import ReactDOM from 'react-dom/client'
3
+ import App from './App'
4
+
5
+ ReactDOM.createRoot(document.getElementById('root')).render(
6
+ <React.StrictMode>
7
+ <App />
8
+ </React.StrictMode>
9
+ )
@@ -0,0 +1,12 @@
1
+ import { defineConfig } from 'vite'
2
+ import react from '@vitejs/plugin-react'
3
+
4
+ export default defineConfig({
5
+ plugins: [react()],
6
+ server: {
7
+ port: 5173,
8
+ proxy: {
9
+ '/api': 'http://localhost:5000'
10
+ }
11
+ }
12
+ })