Skip to content

Commit dc0adcd

Browse files
Documents for shared lib
1 parent bbb8e70 commit dc0adcd

File tree

2 files changed

+341
-9
lines changed

2 files changed

+341
-9
lines changed

README.md

Lines changed: 58 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ Use it to prototype architectures, onboard teams faster, or spin up reproducible
6060
- 🛠 Interactive wizard (or fully non-interactive via flags)
6161
- 🔁 Post-init extensibility: add services & plugins anytime
6262
- 📦 Shared package (`packages/shared`) for cross-service JS utilities
63+
- 📚 **Language-specific shared libraries** (Python packages, Go modules, Java libraries)
6364
- 🧪 Vitest test setup for the CLI itself
6465
- 🌈 Colorized dev logs & health probing for Node/frontend services
6566
- 🔥 Unified hot reload aggregator (`create-polyglot hot`) for Node, Next.js, Python (uvicorn), Go, and Java (Spring Boot)
@@ -167,8 +168,11 @@ create-polyglot dev --docker
167168
| `create-polyglot init <name>` | Scaffold a new workspace (root invocation without `init` is deprecated). |
168169
| `create-polyglot add service <name>` | Add a service after init (`--type`, `--port`, `--yes`). |
169170
| `create-polyglot add plugin <name>` | Create plugin skeleton under `plugins/<name>`. |
171+
| `create-polyglot add lib <name>` | Create a shared library (`--type python|go|java`, `--yes`). |
170172
| `create-polyglot remove service <name>` | Remove a service from the workspace (`--keep-files`, `--yes`). |
171173
| `create-polyglot remove plugin <name>` | Remove a plugin from the workspace (`--keep-files`, `--yes`). |
174+
| `create-polyglot remove lib <name>` | Remove a shared library from the workspace (`--keep-files`, `--yes`). |
175+
| `create-polyglot libraries` / `libs` | List all shared libraries (`--json`). |
172176
| `create-polyglot dev [--docker]` | Run Node & frontend services locally or all via compose. |
173177

174178
## Init Options
@@ -224,26 +228,52 @@ my-org/
224228

225229
## Development Workflow
226230
1. Scaffold with `init`.
227-
2. (Optional) Add more services or plugins.
231+
2. (Optional) Add more services, plugins, or shared libraries.
228232
3. Run `create-polyglot dev` (local) or `create-polyglot dev --docker`.
229233
4. Edit services under `services/<name>`.
230234
5. Extend infra / databases inside `compose.yaml`.
231235

232-
## Managing Services & Plugins
236+
## Managing Services, Plugins & Shared Libraries
233237

234238
### Adding Components
235-
Add services after initial scaffolding:
239+
Add services, plugins, and shared libraries after initial scaffolding:
236240
```bash
241+
# Add services
237242
create-polyglot add service payments --type node --port 4100
243+
244+
# Add plugins
238245
create-polyglot add plugin analytics
246+
247+
# Add shared libraries
248+
create-polyglot add lib common-utils --type python
249+
create-polyglot add lib shared-models --type go
250+
create-polyglot add lib data-types --type java
251+
```
252+
253+
### Listing Components
254+
```bash
255+
# List all services
256+
create-polyglot services
257+
258+
# List all shared libraries
259+
create-polyglot libraries
260+
261+
# Get JSON output
262+
create-polyglot libs --json
239263
```
240264

241265
### Removing Components
242-
Clean removal of services and plugins:
266+
Clean removal of services, plugins, and shared libraries:
243267
```bash
244268
# Remove a service (including files and configuration)
245269
create-polyglot remove service payments --yes
246270

271+
# Remove a shared library
272+
create-polyglot remove lib common-utils
273+
274+
# Keep files but remove from configuration
275+
create-polyglot remove lib common-utils --keep-files
276+
247277
# Remove a plugin
248278
create-polyglot remove plugin analytics --yes
249279

@@ -305,22 +335,40 @@ If `--frontend-generator create-next-app` is supplied, the tool shells out to `n
305335
Example:
306336
```jsonc
307337
{
308-
"name": "my-org",
338+
"name": "my-org",
309339
"preset": "none",
310340
"packageManager": "npm",
311341
"services": [
312342
{ "name": "node", "type": "node", "port": 3001, "path": "services/node" }
313-
]
343+
],
344+
"sharedLibs": [
345+
{ "name": "common-utils", "type": "python", "path": "packages/libs/common-utils", "createdAt": "2024-01-15T10:30:00.000Z" }
346+
],
347+
"plugins": {}
314348
}
315349
```
316-
Used by `add service` to assert uniqueness and regenerate `compose.yaml`.
350+
Used by `add service` and `add lib` to assert uniqueness and regenerate `compose.yaml`.
317351

318352
## Plugins
319353
`create-polyglot add plugin <name>` scaffolds `plugins/<name>/index.js` with a hook skeleton (`afterInit`). Future releases will execute hooks automatically during lifecycle events.
320354

321-
## Shared Package
355+
## Shared Libraries
322356
`packages/shared` shows cross-service Node utilities. Extend or add per-language shared modules.
323357

358+
For language-specific shared libraries:
359+
```bash
360+
# Create Python package
361+
create-polyglot add lib utils --type python
362+
363+
# Create Go module
364+
create-polyglot add lib common --type go
365+
366+
# Create Java library
367+
create-polyglot add lib models --type java
368+
```
369+
370+
See [Shared Libraries Guide](./docs/guide/shared-libraries.md) for detailed usage.
371+
324372
## Force Overwrite
325373
If the target directory already exists, the CLI aborts unless `--force` is passed. Use with caution.
326374

@@ -335,8 +383,9 @@ Generates ESLint + Prettier base configs at the root. Extend rules per service i
335383
- Healthchecks and depends_on in `compose.yaml`
336384
- Additional generators (Remix, Astro, SvelteKit)
337385
- Automatic test harness & CI workflow template
338-
- Language-specific shared libs (Python package, Go module)
339386
- Hot reload integration aggregator
387+
- Service dependency management
388+
- Cross-language testing utilities
340389

341390
## Contributing
342391
Contributions welcome! See `CONTRIBUTING.md` for guidelines. Please run tests before submitting a PR:

0 commit comments

Comments
 (0)