Skip to content

Commit 2eb3dba

Browse files
committed
fix(new): align production config templates
2 parents cddf497 + b5d794e commit 2eb3dba

4 files changed

Lines changed: 143 additions & 25 deletions

File tree

src/commands/new/templates/backend/BackendManifestTemplates.cpp

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ namespace vix::commands::new_cmd::templates
126126
std::string make_vix_json_backend(const std::string &projectName)
127127
{
128128
std::string s;
129-
s.reserve(5200);
129+
s.reserve(7200);
130130

131131
s += "{\n";
132132
s += " \"name\": \"" + projectName + "\",\n";
@@ -141,8 +141,12 @@ namespace vix::commands::new_cmd::templates
141141
s += " \"build\": \"vix build\",\n";
142142
s += " \"check\": \"vix check --tests --run\",\n";
143143
s += " \"test\": \"vix tests\",\n";
144-
s += " \"health\": \"vix health local\",\n";
144+
s += " \"env\": \"vix env check\",\n";
145+
s += " \"health\": \"vix health\",\n";
145146
s += " \"logs\": \"vix logs\",\n";
147+
s += " \"service\": \"vix service status\",\n";
148+
s += " \"proxy\": \"vix proxy nginx check\",\n";
149+
s += " \"doctor\": \"vix doctor production\",\n";
146150
s += " \"deploy\": \"vix deploy\",\n";
147151
s += " \"orm:status\": \"vix orm status\",\n";
148152
s += " \"orm:migrate\": \"vix orm migrate\",\n";
@@ -151,6 +155,9 @@ namespace vix::commands::new_cmd::templates
151155
s += " \"production\": {\n";
152156
s += " \"service\": {\n";
153157
s += " \"name\": \"" + projectName + "\",\n";
158+
s += " \"user\": \"\",\n";
159+
s += " \"working_dir\": \".\",\n";
160+
s += " \"exec\": \"bin/" + projectName + "\",\n";
154161
s += " \"restart\": \"always\",\n";
155162
s += " \"restart_sec\": 3,\n";
156163
s += " \"limit_nofile\": 65535\n";
@@ -159,31 +166,61 @@ namespace vix::commands::new_cmd::templates
159166
s += " \"http\": 8080,\n";
160167
s += " \"websocket\": 9090\n";
161168
s += " },\n";
169+
s += " \"websocket\": {\n";
170+
s += " \"host\": \"127.0.0.1\",\n";
171+
s += " \"port\": 9090,\n";
172+
s += " \"path\": \"/ws\",\n";
173+
s += " \"local_url\": \"ws://127.0.0.1:9090/ws\",\n";
174+
s += " \"public_url\": \"\",\n";
175+
s += " \"timeout_ms\": 5000,\n";
176+
s += " \"heartbeat\": true\n";
177+
s += " },\n";
162178
s += " \"proxy\": {\n";
163179
s += " \"type\": \"nginx\",\n";
164180
s += " \"domain\": \"\",\n";
165181
s += " \"tls\": false,\n";
166-
s += " \"websocket_path\": \"/ws\"\n";
182+
s += " \"websocket_path\": \"/ws\",\n";
183+
s += " \"certificate\": \"\",\n";
184+
s += " \"certificate_key\": \"\"\n";
167185
s += " },\n";
168186
s += " \"health\": {\n";
187+
s += " \"service\": \"" + projectName + "\",\n";
169188
s += " \"local\": \"http://127.0.0.1:8080/health\",\n";
170189
s += " \"public\": \"\",\n";
171-
s += " \"websocket\": \"\"\n";
190+
s += " \"websocket\": \"\",\n";
191+
s += " \"expected_status\": 200,\n";
192+
s += " \"timeout_ms\": 2000,\n";
193+
s += " \"max_response_ms\": 1000\n";
172194
s += " },\n";
173195
s += " \"deploy\": {\n";
174196
s += " \"pull\": true,\n";
175197
s += " \"branch\": \"main\",\n";
176198
s += " \"build\": \"vix build\",\n";
177199
s += " \"tests\": false,\n";
200+
s += " \"test_command\": \"vix tests\",\n";
178201
s += " \"service\": \"" + projectName + "\",\n";
179202
s += " \"health_local\": true,\n";
180203
s += " \"health_public\": false,\n";
181-
s += " \"logs_on_failure\": true\n";
204+
s += " \"proxy_check\": true,\n";
205+
s += " \"proxy_reload\": false,\n";
206+
s += " \"logs_on_failure\": true,\n";
207+
s += " \"log_lines\": 80,\n";
208+
s += " \"rollback\": false\n";
182209
s += " },\n";
183210
s += " \"logs\": {\n";
184-
s += " \"app\": \"journalctl -u " + projectName + "\",\n";
185-
s += " \"proxy_access\": \"/var/log/nginx/" + projectName + ".access.log\",\n";
186-
s += " \"proxy_error\": \"/var/log/nginx/" + projectName + ".error.log\"\n";
211+
s += " \"service\": \"" + projectName + "\",\n";
212+
s += " \"nginx_access\": \"/var/log/nginx/" + projectName + ".access.log\",\n";
213+
s += " \"nginx_error\": \"/var/log/nginx/" + projectName + ".error.log\",\n";
214+
s += " \"lines\": 120\n";
215+
s += " },\n";
216+
s += " \"env\": {\n";
217+
s += " \"required\": [\n";
218+
s += " \"APP_NAME\",\n";
219+
s += " \"APP_ENV\",\n";
220+
s += " \"SERVER_PORT\",\n";
221+
s += " \"DATABASE_ENGINE\",\n";
222+
s += " \"DATABASE_SQLITE_PATH\"\n";
223+
s += " ]\n";
187224
s += " },\n";
188225
s += " \"database\": {\n";
189226
s += " \"engine\": \"sqlite\",\n";

src/commands/new/templates/backend/BackendReadmeTemplates.cpp

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,8 @@ namespace vix::commands::new_cmd::templates
9494
readme += "storage/\n";
9595
readme += "migrations/\n";
9696
readme += "tests/\n";
97-
readme += "config/\n";
98-
readme += " production.json\n";
9997
readme += "\n";
98+
readme += ".env\n";
10099
readme += ".env.example\n";
101100
readme += "vix.app\n";
102101
readme += "vix.json\n";
@@ -178,11 +177,36 @@ namespace vix::commands::new_cmd::templates
178177
readme += "WEBSOCKET_ENABLED=false\n";
179178
readme += "```\n\n";
180179

181-
readme += "Production defaults are documented in:\n\n";
180+
readme += "## Configuration sources\n\n";
181+
readme += "This template intentionally keeps one Vix production configuration source:\n\n";
182182
readme += "```txt\n";
183-
readme += "config/production.json\n";
183+
readme += "vix.json\n";
184+
readme += "```\n\n";
185+
186+
readme += "`vix.json` describes what Vix needs to orchestrate the project:\n\n";
187+
readme += "- service generation\n";
188+
readme += "- Nginx proxy configuration\n";
189+
readme += "- health checks\n";
190+
readme += "- deployment workflow\n";
191+
readme += "- logs\n";
192+
readme += "- production ports\n";
193+
readme += "- required environment variables\n\n";
194+
195+
readme += "Runtime values and secrets stay in:\n\n";
196+
readme += "```txt\n";
197+
readme += ".env\n";
198+
readme += ".env.example\n";
184199
readme += "```\n\n";
185200

201+
readme += "Rule:\n\n";
202+
readme += "```txt\n";
203+
readme += "vix.json -> Vix orchestration config\n";
204+
readme += ".env -> local runtime values and secrets\n";
205+
readme += ".env.example -> documented expected variables\n";
206+
readme += "```\n\n";
207+
208+
readme += "This backend template does not generate `config/production.json` to avoid two competing production configuration files.\n\n";
209+
186210
readme += "## Build manifest\n\n";
187211
readme += "This project uses `vix.app` as its application manifest.\n";
188212
readme += "Vix generates an internal CMake project automatically under:\n\n";
@@ -202,12 +226,13 @@ namespace vix::commands::new_cmd::templates
202226
readme += "```\n\n";
203227

204228
readme += "## Production workflow\n\n";
205-
readme += "The generated `vix.json` contains production-oriented tasks and settings for service, proxy, health checks, logs, deploys, and database defaults.\n\n";
229+
readme += "`vix.json` is the production control file for Vix. It contains tasks and settings for service, proxy, health checks, logs, deploys, ports, environment requirements, and database defaults.\n\n";
206230

207231
readme += "Useful commands:\n\n";
208232
readme += "```bash\n";
209233
readme += "vix build --preset release\n";
210234
readme += "vix check --tests --run\n";
235+
readme += "vix env check --production\n";
211236
readme += "vix health local\n";
212237
readme += "vix logs\n";
213238
readme += "vix deploy\n";

src/commands/new/templates/web/WebManifestTemplates.cpp

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ namespace vix::commands::new_cmd::templates
125125
std::string make_vix_json_web(const std::string &projectName)
126126
{
127127
std::string s;
128-
s.reserve(4200);
128+
s.reserve(6800);
129129

130130
s += "{\n";
131131
s += " \"name\": \"" + projectName + "\",\n";
@@ -140,13 +140,20 @@ namespace vix::commands::new_cmd::templates
140140
s += " \"build\": \"vix build\",\n";
141141
s += " \"check\": \"vix check --tests --run\",\n";
142142
s += " \"test\": \"vix tests\",\n";
143-
s += " \"health\": \"curl http://127.0.0.1:8080/health\",\n";
143+
s += " \"env\": \"vix env check\",\n";
144+
s += " \"health\": \"vix health\",\n";
144145
s += " \"logs\": \"vix logs\",\n";
146+
s += " \"service\": \"vix service status\",\n";
147+
s += " \"proxy\": \"vix proxy nginx check\",\n";
148+
s += " \"doctor\": \"vix doctor production\",\n";
145149
s += " \"deploy\": \"vix deploy\"\n";
146150
s += " },\n";
147151
s += " \"production\": {\n";
148152
s += " \"service\": {\n";
149153
s += " \"name\": \"" + projectName + "\",\n";
154+
s += " \"user\": \"\",\n";
155+
s += " \"working_dir\": \".\",\n";
156+
s += " \"exec\": \"bin/" + projectName + "\",\n";
150157
s += " \"restart\": \"always\",\n";
151158
s += " \"restart_sec\": 3,\n";
152159
s += " \"limit_nofile\": 65535\n";
@@ -157,26 +164,47 @@ namespace vix::commands::new_cmd::templates
157164
s += " \"proxy\": {\n";
158165
s += " \"type\": \"nginx\",\n";
159166
s += " \"domain\": \"\",\n";
160-
s += " \"tls\": false\n";
167+
s += " \"tls\": false,\n";
168+
s += " \"certificate\": \"\",\n";
169+
s += " \"certificate_key\": \"\"\n";
161170
s += " },\n";
162171
s += " \"health\": {\n";
172+
s += " \"service\": \"" + projectName + "\",\n";
163173
s += " \"local\": \"http://127.0.0.1:8080/health\",\n";
164-
s += " \"public\": \"\"\n";
174+
s += " \"public\": \"\",\n";
175+
s += " \"expected_status\": 200,\n";
176+
s += " \"timeout_ms\": 2000,\n";
177+
s += " \"max_response_ms\": 1000\n";
165178
s += " },\n";
166179
s += " \"deploy\": {\n";
167180
s += " \"pull\": true,\n";
168181
s += " \"branch\": \"main\",\n";
169182
s += " \"build\": \"vix build\",\n";
170183
s += " \"tests\": false,\n";
184+
s += " \"test_command\": \"vix tests\",\n";
171185
s += " \"service\": \"" + projectName + "\",\n";
172186
s += " \"health_local\": true,\n";
173187
s += " \"health_public\": false,\n";
174-
s += " \"logs_on_failure\": true\n";
188+
s += " \"proxy_check\": true,\n";
189+
s += " \"proxy_reload\": false,\n";
190+
s += " \"logs_on_failure\": true,\n";
191+
s += " \"log_lines\": 80,\n";
192+
s += " \"rollback\": false\n";
175193
s += " },\n";
176194
s += " \"logs\": {\n";
177-
s += " \"app\": \"journalctl -u " + projectName + "\",\n";
178-
s += " \"proxy_access\": \"/var/log/nginx/" + projectName + ".access.log\",\n";
179-
s += " \"proxy_error\": \"/var/log/nginx/" + projectName + ".error.log\"\n";
195+
s += " \"service\": \"" + projectName + "\",\n";
196+
s += " \"nginx_access\": \"/var/log/nginx/" + projectName + ".access.log\",\n";
197+
s += " \"nginx_error\": \"/var/log/nginx/" + projectName + ".error.log\",\n";
198+
s += " \"lines\": 120\n";
199+
s += " },\n";
200+
s += " \"env\": {\n";
201+
s += " \"required\": [\n";
202+
s += " \"APP_NAME\",\n";
203+
s += " \"APP_ENV\",\n";
204+
s += " \"SERVER_PORT\",\n";
205+
s += " \"PUBLIC_PATH\",\n";
206+
s += " \"VIEWS_PATH\"\n";
207+
s += " ]\n";
180208
s += " },\n";
181209
s += " \"web\": {\n";
182210
s += " \"views\": \"views\",\n";

src/commands/new/templates/web/WebReadmeTemplates.cpp

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,8 @@ namespace vix::commands::new_cmd::templates
8181
readme += "\n";
8282
readme += "storage/\n";
8383
readme += "tests/\n";
84-
readme += "config/\n";
85-
readme += " production.json\n";
8684
readme += "\n";
85+
readme += ".env\n";
8786
readme += ".env.example\n";
8887
readme += "vix.app\n";
8988
readme += "vix.json\n";
@@ -173,11 +172,37 @@ namespace vix::commands::new_cmd::templates
173172
readme += "VIEWS_PATH=views\n";
174173
readme += "```\n\n";
175174

176-
readme += "Production defaults are documented in:\n\n";
175+
readme += "## Configuration sources\n\n";
176+
readme += "This template intentionally keeps one Vix production configuration source:\n\n";
177177
readme += "```txt\n";
178-
readme += "config/production.json\n";
178+
readme += "vix.json\n";
179+
readme += "```\n\n";
180+
181+
readme += "`vix.json` describes what Vix needs to orchestrate the project:\n\n";
182+
readme += "- service generation\n";
183+
readme += "- Nginx proxy configuration\n";
184+
readme += "- health checks\n";
185+
readme += "- deployment workflow\n";
186+
readme += "- logs\n";
187+
readme += "- production ports\n";
188+
readme += "- required environment variables\n";
189+
readme += "- web template and public file settings\n\n";
190+
191+
readme += "Runtime values and secrets stay in:\n\n";
192+
readme += "```txt\n";
193+
readme += ".env\n";
194+
readme += ".env.example\n";
179195
readme += "```\n\n";
180196

197+
readme += "Rule:\n\n";
198+
readme += "```txt\n";
199+
readme += "vix.json -> Vix orchestration config\n";
200+
readme += ".env -> local runtime values and secrets\n";
201+
readme += ".env.example -> documented expected variables\n";
202+
readme += "```\n\n";
203+
204+
readme += "This web template does not generate `config/production.json` to avoid two competing production configuration files.\n\n";
205+
181206
readme += "## Common commands\n\n";
182207
readme += "```bash\n";
183208
readme += "vix dev\n";
@@ -188,10 +213,13 @@ namespace vix::commands::new_cmd::templates
188213
readme += "```\n\n";
189214

190215
readme += "## Production workflow\n\n";
216+
readme += "`vix.json` is the production control file for Vix. It contains tasks and settings for service, proxy, health checks, logs, deploys, ports, environment requirements, and web runtime defaults.\n\n";
191217
readme += "Useful commands:\n\n";
192218
readme += "```bash\n";
193219
readme += "vix build --preset release\n";
194220
readme += "vix check --tests --run\n";
221+
readme += "vix env check --production\n";
222+
readme += "vix health\n";
195223
readme += "vix logs\n";
196224
readme += "vix deploy\n";
197225
readme += "```\n\n";

0 commit comments

Comments
 (0)