go-dev 0.1.0 → 0.1.2

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Giuliano Collacchioni
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README ADDED
@@ -0,0 +1,178 @@
1
+ # `go-dev`
2
+
3
+ A simple and robust orchestrator for streamlining local development environments in monorepos.
4
+
5
+ **`npx go-dev <preset>` – Go develop!**
6
+
7
+ ## 🚀 Introduction
8
+
9
+ In complex monorepos, starting your development environment can be a chore. You might need to spin up Docker containers, run multiple Node.js (or other language) development servers, handle pre-builds, and manage inter-service dependencies. `go-dev` simplifies this by allowing you to define your entire local development stack in a single YAML configuration file.
10
+
11
+ `go-dev` acts as a central command to bring up your `api`, `frontend`, `database`, and any other microservices, ensuring they start in the correct order, with the right modes, and provide clear, prefixed logs.
12
+
13
+ ## ✨ Features
14
+
15
+ * **Unified Configuration:** Define all your services, their modes (e.g., `dev`, `docker`, `serve`), and dependencies in a single `go-dev.yml` file.
16
+ * **Service Types:**
17
+ * **`cmd` services:** Run any command-line process (e.g., `npm run dev`, `rollup -w`, `python app.py`). Supports `preCommands` for setup tasks like builds.
18
+ * **`docker` services:** Manage Docker containers via `docker compose`. Automatically checks container status and performs health checks.
19
+ * **Mode-Aware Dependencies:** Services can depend on other services running in specific modes (e.g., your `api` dev mode might depend on `frontend` in `serve` mode).
20
+ * **Preset-Driven Startup:** Define different "presets" (e.g., `api`, `frontend`, `all`) to easily spin up specific combinations of services tailored to your current development focus.
21
+ * **Automatic Dependency Resolution:** `go-dev` builds an intelligent execution graph, starting services in the correct topological order.
22
+ * **Centralized Logging:** Prefixes logs from each service, making it easy to follow activity from multiple concurrent processes.
23
+ * **Robust Cleanup:** Handles graceful shutdown of all started processes and Docker services on exit (e.g., via `Ctrl+C`).
24
+
25
+ ## 🤔 Why `go-dev`?
26
+
27
+ While tools like `concurrently` manage parallel processes and `docker compose` handles containers, `go-dev` fills a crucial gap by:
28
+
29
+ * **Integrating `cmd` and `docker` services seamlessly:** It bridges the world of host-based processes and containerized applications under one roof.
30
+ * **Providing intelligent mode-aware dependency resolution:** It understands that "frontend" might mean a different set of commands (and dependencies) when you're actively developing the frontend vs. when it's just a dependency for API development.
31
+ * **Offering a single, declarative interface for your entire dev stack:** No more remembering multiple `npm` scripts or `docker compose` commands.
32
+
33
+ ## 📦 Installation
34
+
35
+ `go-dev` is distributed via npm and designed to be used with `npx`.
36
+
37
+ ```bash
38
+ # Install it as a devDependency in your monorepo's root
39
+ npm install --save-dev go-dev
40
+ # or
41
+ yarn add --dev go-dev
42
+ ```
43
+
44
+ ## 🚀 Usage
45
+
46
+ Once installed, simply run `go-dev` with the name of the preset you want to start:
47
+
48
+ ```bash
49
+ npx go-dev <preset_name> [config_path]
50
+ ```
51
+
52
+ * `<preset_name>`: The name of the preset defined in your `go-dev.yml` (e.g., `api`, `frontend`, `all`).
53
+ * `[config_path]`: (Optional) Path to your `go-dev.yml` file. Defaults to looking for `go-dev.yml`, `.go-dev.yml`, `go-dev.yaml`, or `.go-dev.yaml` in the current directory.
54
+
55
+ **Example:**
56
+
57
+ ```bash
58
+ npx go-dev api # Start the environment for API development
59
+ npx go-dev frontend # Start the environment for Frontend development
60
+ npx go-dev all # Start the full development environment
61
+ ```
62
+
63
+ Press `Ctrl+C` at any time to gracefully shut down all running services.
64
+
65
+ ## ⚙️ Configuration (`go-dev.yml`)
66
+
67
+ Create a configuration file in your project's root.
68
+
69
+ By default, `go-dev` automatically detects its configuration file. It looks for files named `go-dev` (or `.go-dev` for a hidden file), optionally including `.config` before the `.yml` or `.yaml` extension. It will search for these files in the directory where you run `npx go-dev`.
70
+
71
+ Common examples include: `go-dev.yml`, `.go-dev.yml`, and `go-dev.config.yaml`.
72
+
73
+ ```yaml
74
+ # go-dev.yml
75
+
76
+ # Define your individual services here
77
+ services:
78
+ # Example: A Docker-based PostgreSQL database
79
+ postgres:
80
+ type: docker # This service runs inside Docker
81
+ service: postgres # Name of the service in your docker-compose.yml
82
+ composeFile: infrastructure/docker-compose.yml # Path to the docker-compose file
83
+ healthCheck: true # Enable health checks for this Docker service
84
+
85
+ # Example: Your API service, which can run in 'dev' (cmd) or 'docker' mode
86
+ api:
87
+ type: hybrid # This service has multiple modes
88
+ defaultMode: dev # Default mode if not specified by a preset or dependency
89
+ # Note: The name of the modes is totally arbirtary
90
+ modes:
91
+ # API in active development mode (runs directly on host)
92
+ dev:
93
+ type: cmd # This mode runs a command-line process
94
+ commands:
95
+ start:
96
+ command: [npx, rollup, -c, -w] # The primary command for development
97
+ directory: ./api # Directory to run the command from
98
+ dependencies: # What this mode depends on
99
+ - postgres # API dev needs PostgreSQL (will use postgres's default docker mode)
100
+ - { service: frontend, mode: serve } # API dev needs frontend running in its 'serve' mode
101
+
102
+ # API running as a Docker container (e.g., for frontend-only dev)
103
+ docker:
104
+ type: docker
105
+ service: api
106
+ composeFile: infrastructure/docker-compose.yml
107
+ healthCheck: true
108
+ dependencies:
109
+ - postgres # Docker API also needs PostgreSQL
110
+
111
+ # Example: Your Frontend service, which can run in 'dev' (cmd) or 'serve' (cmd) mode
112
+ frontend:
113
+ type: hybrid
114
+ defaultMode: dev
115
+ modes:
116
+ # Frontend in active development (watch mode)
117
+ dev:
118
+ type: cmd
119
+ commands:
120
+ start:
121
+ command: [npx, rollup, -c, -w]
122
+ directory: ./frontend
123
+ dependencies:
124
+ # Frontend dev needs API (will use api's default docker mode for this preset)
125
+ # Note: No direct circular dependency between dev modes.
126
+ # Dev modes often assume peers will eventually be ready.
127
+ - { service: api, mode: docker }
128
+
129
+ # Frontend serving its built assets (e.g., when API depends on it)
130
+ serve:
131
+ type: cmd
132
+ preCommands: # Commands to run and await completion BEFORE the main 'start' command
133
+ - [npm, --prefix, frontend, run, build] # Build frontend assets first
134
+ commands:
135
+ start:
136
+ command: [node, ./localserver.mjs] # Then start the local server
137
+ directory: ./frontend
138
+ dependencies:
139
+ - api # Frontend serve needs API (will use api's default dev mode for this preset)
140
+
141
+
142
+ # Define different development presets (combinations of services and their modes)
143
+ presets:
144
+ # Preset: "api" development focus
145
+ # Starts API in dev mode, pulling in its dependencies (postgres, frontend:serve)
146
+ api:
147
+ services: [api] # Only explicitly list top-level services you want to run
148
+ modes:
149
+ # no explicit modes needed here, as defaultMode and dependency requests handle it
150
+ # api: dev # (already default)
151
+ # frontend: serve # (requested by api:dev)
152
+ # postgres: dev # (pulled by dependencies)
153
+
154
+ # Preset: "frontend" development focus
155
+ # Starts Frontend in dev mode, pulling in its dependencies (api:docker, postgres)
156
+ frontend:
157
+ services: [frontend]
158
+ modes:
159
+ # frontend: dev # (already default)
160
+ # api: docker # (requested by frontend:dev)
161
+ # postgres: dev # (pulled by dependencies)
162
+
163
+ # Preset: "all" development (both API and Frontend in dev mode concurrently)
164
+ all:
165
+ services: [api, frontend] # Explicitly list both as top-level focus
166
+ modes:
167
+ # api: dev # (already default)
168
+ # frontend: dev # (already default)
169
+ # No need to specify modes if they match the defaultMode
170
+ ```
171
+
172
+ ## 🤝 Contributing
173
+
174
+ Contributions are welcome! Feel free to open issues or submit pull requests.
175
+
176
+ ## 📄 License
177
+
178
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
package/bin/go-dev ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env node
2
+
3
+ const Orchestrator = require('../src/orchestrator');
4
+ const path = require('path');
5
+
6
+ const presetName = process.argv[2];
7
+ const configPath = process.argv[3];
8
+
9
+ if (!presetName) {
10
+ console.error('Error: Please specify a preset to run. Usage: dev-orchestrator <preset_name> [config_path]');
11
+ process.exit(1);
12
+ }
13
+
14
+ const orchestrator = new Orchestrator(configPath);
15
+
16
+ orchestrator.start(presetName);
package/package.json CHANGED
@@ -1,7 +1,10 @@
1
1
  {
2
2
  "name": "go-dev",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "main": "src/index.js",
5
+ "bin": {
6
+ "go-dev": "bin/go-dev"
7
+ },
5
8
  "scripts": {
6
9
  "test": "echo \"Error: no test specified\" && exit 1"
7
10
  },
package/src/config.js CHANGED
@@ -68,22 +68,26 @@ const configSchema = Joi.object({
68
68
  ).default({})
69
69
  });
70
70
 
71
- function findConfigFile() {
72
- const possibleNames = [
73
- 'dev-orchestrator',
74
- '.dev-orchestrator'
75
- ].flatMap(baseName => {
76
- return [
77
- baseName,
78
- `${baseName}.config`
79
- ];
80
- }).flatMap(baseName => {
81
- return [
82
- `${baseName}.yml`,
83
- `${baseName}.yaml`
84
- ];
85
- });
71
+ const possibleNames = [
72
+ 'go-dev'
73
+ ].flatMap(baseName => {
74
+ return [
75
+ baseName,
76
+ `.${baseName}`
77
+ ];
78
+ }).flatMap(baseName => {
79
+ return [
80
+ baseName,
81
+ `${baseName}.config`
82
+ ];
83
+ }).flatMap(baseName => {
84
+ return [
85
+ `${baseName}.yml`,
86
+ `${baseName}.yaml`
87
+ ];
88
+ });
86
89
 
90
+ function findConfigFile() {
87
91
  for (const name of possibleNames) {
88
92
  if (fs.existsSync(name)) {
89
93
  return name;