Skip to content

Commit a39b5bc

Browse files
committed
feat: implement monorepo scaffolding with interactive prompts and service management
Signed-off-by: kaifcoder <kaifmohd2014@gmail.com>
1 parent 15ceae8 commit a39b5bc

File tree

13 files changed

+796
-517
lines changed

13 files changed

+796
-517
lines changed

README.md

Lines changed: 62 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# create-polyglot
22

3-
CLI to scaffold a polyglot microservice monorepo (Node.js, Python/FastAPI, Go, Java Spring Boot, Next.js frontend) with optional Turborepo or Nx presets, Docker assets, shared packages, and an interactive wizard.
3+
CLI to scaffold a polyglot microservice monorepo (Node.js, Python/FastAPI, Go, Java Spring Boot, Next.js frontend) with optional Turborepo or Nx presets, Docker assets, shared packages, an interactive wizard, post-init service/plugin additions, and a persisted `polyglot.json` config.
44

55
## Installation (local dev)
66

@@ -12,16 +12,34 @@ npm link # or: pnpm link --global / yarn link / bun link
1212
Then run (non-interactive example):
1313

1414
```bash
15-
create-polyglot my-org -s node,python,go,java,frontend --git
15+
create-polyglot init my-org -s node,python,go,java,frontend --git --yes
1616
```
1717

1818
Interactive (wizard prompts for any missing info):
1919

2020
```bash
21-
create-polyglot my-org
21+
create-polyglot init my-org
2222
```
2323

24-
## Options
24+
Add a service later:
25+
```bash
26+
create-polyglot add service payments --type node --port 4100
27+
```
28+
29+
Add a plugin scaffold:
30+
```bash
31+
create-polyglot add plugin postgres
32+
```
33+
34+
## Commands
35+
36+
| Command | Description |
37+
|---------|-------------|
38+
| `create-polyglot init <name>` | Scaffold a new workspace (root invocation without `init` is deprecated). |
39+
| `create-polyglot add service <name>` | Add a service after init (`--type`, `--port`, `--yes`). |
40+
| `create-polyglot add plugin <name>` | Create plugin skeleton under `plugins/<name>`. |
41+
42+
## Init Options
2543

2644
| Flag | Description |
2745
|------|-------------|
@@ -30,42 +48,31 @@ create-polyglot my-org
3048
| `--git` | Initialize git repo & initial commit |
3149
| `--no-install` | Skip dependency installation step |
3250
| `--package-manager <pm>` | One of `npm|pnpm|yarn|bun` (default: detect or npm) |
33-
| `--frontend-generator <gen>` | Currently: `create-next-app` (else falls back to template) |
51+
| `--frontend-generator` | Use `create-next-app` (falls back to template on failure) |
3452
| `--force` | Overwrite existing target directory if it exists |
3553

3654
If you omit flags, the wizard will prompt interactively (similar to `create-next-app`).
3755

3856
## Generated Structure
3957
```
4058
my-org/
41-
apps/
42-
node/
43-
python/
44-
go/
45-
java/ (spring-boot template)
46-
frontend/
47-
packages/
48-
package.json
49-
```
50-
51-
### Generated Structure (Baseline)
52-
53-
```
54-
my-org/
55-
apps/
56-
node/ # Express + nodemon dev script
59+
services/
60+
node/ # Express + dev script
5761
python/ # FastAPI + uvicorn
58-
go/ # net/http service
62+
go/ # Go net/http service
5963
java/ # Spring Boot (Maven)
6064
frontend/ # Next.js (template or create-next-app output)
65+
gateway/
66+
infra/
6167
packages/
62-
shared/ # Example shared util (Node)
63-
docker/ # Per-service Dockerfiles (if not placed inline) *optional*
64-
compose.yaml # Generated docker-compose for all selected services
65-
package.json # Workspaces + scripts
68+
shared/
69+
plugins/ # created when adding plugins
70+
compose.yaml
71+
polyglot.json # persisted configuration
72+
package.json
6673
turbo.json / nx.json (if preset chosen)
6774
scripts/
68-
dev-basic.cjs # Basic concurrent runner (no preset)
75+
dev-basic.cjs
6976
```
7077

7178
### Presets
@@ -74,15 +81,15 @@ my-org/
7481
- Basic: Provides a minimal setup plus `scripts/dev-basic.cjs` for simple concurrency.
7582

7683
### Basic Dev Runner
77-
When no preset is chosen, `npm run dev` (or your selected package manager) invokes `scripts/dev-basic.cjs` which:
84+
When no preset is chosen, `npm run dev` uses `scripts/dev-basic.cjs`:
7885
1. Detects package manager (pnpm > yarn > bun > npm fallback)
79-
2. Scans `apps/` directories
80-
3. Starts only services with a `package.json` containing a `dev` script
81-
4. Prefixes each line of output with the service name
86+
2. Scans `services/` for Node services
87+
3. Runs those with a `dev` script
88+
4. Prefixes log lines with service name
8289

83-
Non-Node services (Python/Go/Spring) are skipped automatically; start them manually as needed:
90+
Non-Node services start manually or via compose:
8491
```
85-
cd apps/python && uvicorn main:app --reload
92+
cd services/python && uvicorn app.main:app --reload
8693
```
8794

8895
### Docker & Compose
@@ -95,8 +102,25 @@ You can extend compose with volumes, env vars, or database services after genera
95102
### Frontend Generation
96103
If `--frontend-generator create-next-app` is supplied, the tool shells out to `npx create-next-app` (respecting the chosen package manager for installs). If it fails, a fallback static template is used.
97104

105+
### polyglot.json
106+
Example:
107+
```jsonc
108+
{
109+
"name": "my-org",
110+
"preset": "none",
111+
"packageManager": "npm",
112+
"services": [
113+
{ "name": "node", "type": "node", "port": 3001, "path": "services/node" }
114+
]
115+
}
116+
```
117+
Used by `add service` to assert uniqueness and regenerate `compose.yaml`.
118+
119+
### Plugins
120+
`create-polyglot add plugin <name>` scaffolds `plugins/<name>/index.js` with a hook skeleton (`afterInit`). Future releases will execute hooks automatically during lifecycle events.
121+
98122
### Shared Package
99-
An example `packages/shared` workspace demonstrates sharing Node utilities across services. Expand or add more workspaces as needed.
123+
`packages/shared` shows cross-service Node utilities. Extend or add per-language shared modules.
100124

101125
### Force Overwrite
102126
If the target directory already exists, the CLI aborts unless `--force` is passed. Use with caution.
@@ -108,11 +132,13 @@ Pass `--git` to automatically run `git init`, create an initial commit, and (if
108132
Generates ESLint + Prettier base configs at the root. Extend rules per service if needed.
109133

110134
### Roadmap / Ideas
135+
- Plugin hook execution pipeline
111136
- Healthchecks and depends_on in `compose.yaml`
112-
- Additional generators (e.g. Remix, Astro, SvelteKit)
137+
- Additional generators (Remix, Astro, SvelteKit)
113138
- Automatic test harness & CI workflow template
114-
- Language-specific shared libs examples (Python package, Go module)
139+
- Language-specific shared libs (Python package, Go module)
115140
- Hot reload integration aggregator
141+
- Remove service / remove plugin commands
116142

117143
## License
118144
MIT

0 commit comments

Comments
 (0)