|
4 | 4 | * @file NewTemplates.hpp |
5 | 5 | * @author Gaspard Kirira |
6 | 6 | * |
7 | | - * Copyright 2025, Gaspard Kirira. All rights reserved. |
| 7 | + * Copyright 2025, Gaspard Kirira. All rights reserved. |
8 | 8 | * https://github.com/vixcpp/vix |
9 | 9 | * Use of this source code is governed by a MIT license |
10 | 10 | * that can be found in the License file. |
11 | 11 | * |
12 | | - * File content templates for the `vix new` command. |
13 | | - * All functions return the textual content of a generated file. |
| 12 | + * Public facade for all `vix new` file-content templates. |
14 | 13 | */ |
15 | 14 |
|
16 | | -#include <string> |
17 | | -#include <vix/cli/commands/new/NewTypes.hpp> |
18 | | - |
19 | | -namespace vix::commands::new_cmd::templates |
20 | | -{ |
21 | | - |
22 | | - // ------------------------------------------------------------------ |
23 | | - // Static content (inline constants) |
24 | | - // ------------------------------------------------------------------ |
25 | | - |
26 | | - /// src/main.cpp for a new App project |
27 | | - constexpr const char *kMainCpp = R"(#include <vix.hpp> |
28 | | -using namespace vix; |
29 | | -
|
30 | | -int main() |
31 | | -{ |
32 | | - App app; |
33 | | -
|
34 | | - // GET / |
35 | | - app.get("/", [](Request&, Response& res) { |
36 | | - res.send("Hello world"); |
37 | | - }); |
38 | | -
|
39 | | - app.run(8080); |
40 | | -} |
41 | | -)"; |
42 | | - |
43 | | - /// tests/test_basic.cpp for a new App project |
44 | | - constexpr const char *kBasicTestCpp_App = R"(#include <vix/tests/tests.hpp> |
45 | | -
|
46 | | -int main() |
47 | | -{ |
48 | | - using namespace vix::tests; |
49 | | -
|
50 | | - auto ®istry = TestRegistry::instance(); |
51 | | - registry.clear(); |
52 | | -
|
53 | | - registry.add(TestCase("app basic test", [] { |
54 | | - Assert::equal(2 + 2, 4); |
55 | | - })); |
56 | | -
|
57 | | - return TestRunner::run_all_and_exit(); |
58 | | -} |
59 | | -)"; |
60 | | - |
61 | | - /// config/app.json default content |
62 | | - constexpr const char *kAppConfigJson = R"JSON({ |
63 | | - "server": { |
64 | | - "port": 8080, |
65 | | - "request_timeout": 2000, |
66 | | - "io_threads": 0, |
67 | | - "session_timeout_sec": 20 |
68 | | - }, |
69 | | - "logging": { |
70 | | - "async": true, |
71 | | - "queue_max": 20000, |
72 | | - "drop_on_overflow": true |
73 | | - }, |
74 | | - "waf": { |
75 | | - "mode": "basic", |
76 | | - "max_target_len": 4096, |
77 | | - "max_body_bytes": 1048576 |
78 | | - }, |
79 | | - "database": { |
80 | | - "default": { |
81 | | - "host": "localhost", |
82 | | - "user": "root", |
83 | | - "password": "", |
84 | | - "name": "", |
85 | | - "port": 3306 |
86 | | - } |
87 | | - } |
88 | | -} |
89 | | -)JSON"; |
90 | | - |
91 | | - /// Default .env.example / .env content for an App project |
92 | | - constexpr const char *kEnvExample = R"(# ---------------------------------- |
93 | | -# Server |
94 | | -# ---------------------------------- |
95 | | -SERVER_PORT=8080 |
96 | | -
|
97 | | -# ---------------------------------- |
98 | | -# Database |
99 | | -# ---------------------------------- |
100 | | -DATABASE_ENGINE=mysql |
101 | | -DATABASE_DEFAULT_HOST=127.0.0.1 |
102 | | -DATABASE_DEFAULT_PORT=3306 |
103 | | -DATABASE_DEFAULT_USER=root |
104 | | -DATABASE_DEFAULT_PASSWORD= |
105 | | -DATABASE_DEFAULT_NAME=appdb |
106 | | -
|
107 | | -# ---------------------------------- |
108 | | -# Logging |
109 | | -# ---------------------------------- |
110 | | -LOGGING_ASYNC=true |
111 | | -
|
112 | | -# ---------------------------------- |
113 | | -# Security / WAF |
114 | | -# ---------------------------------- |
115 | | -WAF_MODE=basic |
116 | | -)"; |
117 | | - |
118 | | - // ------------------------------------------------------------------ |
119 | | - // Library scaffold helpers |
120 | | - // ------------------------------------------------------------------ |
121 | | - |
122 | | - /// include/<name>/<name>.hpp (header-only library stub) |
123 | | - std::string make_lib_header(const std::string &name); |
124 | | - |
125 | | - /// tests/test_basic.cpp for a library project |
126 | | - std::string make_basic_test_cpp_lib(const std::string &name); |
127 | | - |
128 | | - /// examples/basic.cpp for a library project |
129 | | - std::string make_basic_example_cpp_lib(const std::string &name); |
130 | | - |
131 | | - /// examples/CMakeLists.txt for a library project |
132 | | - std::string make_examples_cmakelists_lib(const std::string &name); |
133 | | - |
134 | | - // ------------------------------------------------------------------ |
135 | | - // README generators |
136 | | - // ------------------------------------------------------------------ |
137 | | - |
138 | | - std::string make_readme_app(const std::string &projectName); |
139 | | - std::string make_readme_vue_app(const std::string &projectName); |
140 | | - std::string make_readme_lib(const std::string &name); |
141 | | - |
142 | | - // ------------------------------------------------------------------ |
143 | | - // CMakePresets.json generators |
144 | | - // ------------------------------------------------------------------ |
145 | | - |
146 | | - std::string make_cmake_presets_json_app(const FeaturesSelection &f); |
147 | | - std::string make_cmake_presets_json_lib(); |
148 | | - |
149 | | - // ------------------------------------------------------------------ |
150 | | - // Project manifest (.vix) generators |
151 | | - // ------------------------------------------------------------------ |
152 | | - |
153 | | - std::string make_project_manifest_app(const std::string &name, const FeaturesSelection &f); |
154 | | - std::string make_project_manifest_lib(const std::string &name); |
155 | | - |
156 | | - // ------------------------------------------------------------------ |
157 | | - // vix.json generators |
158 | | - // ------------------------------------------------------------------ |
159 | | - |
160 | | - std::string make_vix_json_app(const std::string &name); |
161 | | - std::string make_vix_json_lib(const std::string &name); |
162 | | - std::string make_vix_json_vue_app(const std::string &name); |
163 | | - |
164 | | - // ------------------------------------------------------------------ |
165 | | - // Vue frontend generators |
166 | | - // ------------------------------------------------------------------ |
167 | | - |
168 | | - std::string make_vue_package_json(const std::string &projectName); |
169 | | - std::string make_vue_index_html(const std::string &projectName); |
170 | | - std::string make_vue_vite_config(); |
171 | | - std::string make_vue_main_js(); |
172 | | - std::string make_vue_app_vue(); |
173 | | - |
174 | | - // ------------------------------------------------------------------ |
175 | | - // Game generators |
176 | | - // ------------------------------------------------------------------ |
177 | | - |
178 | | - std::string make_game_main_cpp(const std::string &projectName); |
179 | | - std::string make_game_package_json(const std::string &projectName); |
180 | | - std::string make_readme_game(const std::string &projectName); |
181 | | - std::string make_project_manifest_game(const std::string &projectName); |
182 | | - std::string make_vix_json_game(const std::string &projectName); |
183 | | - |
184 | | - // ------------------------------------------------------------------ |
185 | | - // CMakeLists.txt generators |
186 | | - // ------------------------------------------------------------------ |
187 | | - |
188 | | - std::string make_cmakelists_app(const std::string &projectName, const FeaturesSelection &f); |
189 | | - std::string make_cmakelists_lib(const std::string &name); |
190 | | - |
191 | | -} // namespace vix::commands::new_cmd::templates |
| 15 | +#include <vix/cli/commands/new/templates/AppTemplates.hpp> |
| 16 | +#include <vix/cli/commands/new/templates/BackendTemplates.hpp> |
| 17 | +#include <vix/cli/commands/new/templates/CommonTemplates.hpp> |
| 18 | +#include <vix/cli/commands/new/templates/GameTemplates.hpp> |
| 19 | +#include <vix/cli/commands/new/templates/LibTemplates.hpp> |
| 20 | +#include <vix/cli/commands/new/templates/VueTemplates.hpp> |
0 commit comments