@decohere/scaffold 0.0.1-dev.18 → 0.0.1-dev.20261105.46

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.
Files changed (264) hide show
  1. package/LICENSE +15 -0
  2. package/commonjs/src/add-api.action.js +37 -0
  3. package/commonjs/src/add-api.command.js +39 -0
  4. package/commonjs/src/add.command.js +22 -0
  5. package/commonjs/src/add.module.js +24 -0
  6. package/commonjs/src/auth0-configure.action.js +28 -0
  7. package/commonjs/src/auth0-configure.command.js +24 -0
  8. package/commonjs/src/auth0-login.action.js +28 -0
  9. package/commonjs/src/auth0-login.command.js +23 -0
  10. package/commonjs/src/auth0.command.js +22 -0
  11. package/commonjs/src/auth0.module.js +28 -0
  12. package/commonjs/src/cli.js +8 -0
  13. package/commonjs/src/create.command.js +22 -0
  14. package/commonjs/src/create.module.js +24 -0
  15. package/commonjs/src/domain/prompt.js +62 -0
  16. package/commonjs/src/index.js +48 -0
  17. package/commonjs/src/models/compose.model.js +258 -0
  18. package/commonjs/src/models/config-yaml.model.js +86 -0
  19. package/commonjs/src/models/const.js +30 -0
  20. package/commonjs/src/models/dev-container.model.js +172 -0
  21. package/commonjs/src/models/docker-image.model.js +277 -0
  22. package/commonjs/src/models/env-file.model.js +48 -0
  23. package/commonjs/src/models/gitignore.model.js +48 -0
  24. package/commonjs/src/models/launch-json.model.js +70 -0
  25. package/commonjs/src/models/package-json.model.js +156 -0
  26. package/commonjs/src/models/project.model.js +132 -0
  27. package/commonjs/src/models/source-file.js +4 -0
  28. package/commonjs/src/models/tsconfig.model.js +32 -0
  29. package/commonjs/src/models/vitest-config.model.js +33 -0
  30. package/commonjs/src/models/vscode-settings.model.js +29 -0
  31. package/commonjs/src/program.js +64 -0
  32. package/commonjs/src/resolve-target-dir.js +17 -0
  33. package/commonjs/src/services/scaffold.service.js +60 -0
  34. package/commonjs/src/version.js +55 -0
  35. package/commonjs/src/webapi/api-name.js +93 -0
  36. package/commonjs/src/webapi/auth0-commands.js +250 -0
  37. package/commonjs/src/webapi/authorize-scopes.js +79 -0
  38. package/commonjs/src/webapi/cli-options.js +99 -0
  39. package/commonjs/src/webapi/const.js +54 -0
  40. package/commonjs/src/webapi/create-api.js +265 -0
  41. package/commonjs/src/webapi/devcontainer/codebase-rag-mcp.js +164 -0
  42. package/commonjs/src/webapi/devcontainer/codebase-rag-mcp.ts +182 -0
  43. package/commonjs/src/webapi/devcontainer/host-scripts.js +50 -0
  44. package/commonjs/src/webapi/devcontainer/templates/codebase-rag.env.example +3 -0
  45. package/commonjs/src/webapi/devcontainer/templates/initialize.sh +169 -0
  46. package/commonjs/src/webapi/devcontainer/templates/post-create.sh +35 -0
  47. package/commonjs/src/webapi/devcontainer/templates/post-start.sh +65 -0
  48. package/commonjs/src/webapi/devcontainer/templates/tty-prompt.sh +38 -0
  49. package/commonjs/src/webapi/features/auth.feature.js +408 -0
  50. package/commonjs/src/webapi/features/auth0-cli.js +472 -0
  51. package/commonjs/src/webapi/features/biome-format.js +47 -0
  52. package/commonjs/src/webapi/features/database.feature.js +433 -0
  53. package/commonjs/src/webapi/features/finalize.feature.js +93 -0
  54. package/commonjs/src/webapi/features/postman.feature.js +322 -0
  55. package/commonjs/src/webapi/models/api-package-json.model.js +58 -0
  56. package/commonjs/src/webapi/models/auth-config.model.js +24 -0
  57. package/commonjs/src/webapi/models/controller-source-file.model.js +190 -0
  58. package/commonjs/src/webapi/models/github-ci.model.js +193 -0
  59. package/commonjs/src/webapi/models/main-source-file.model.js +165 -0
  60. package/commonjs/src/webapi/models/production-dockerfile.model.js +75 -0
  61. package/commonjs/src/webapi/models/sample-files.model.js +58 -0
  62. package/commonjs/src/webapi/models/webapi-image.model.js +25 -0
  63. package/commonjs/src/webapi/postman/hello-openapi.js +173 -0
  64. package/commonjs/src/webapi/postman/local-view.js +182 -0
  65. package/commonjs/src/webapi/postman/openapi-to-postman.js +238 -0
  66. package/commonjs/src/webapi/workspace-readme.js +109 -0
  67. package/commonjs/src/webapi.action.js +28 -0
  68. package/commonjs/src/webapi.command.js +43 -0
  69. package/es6/src/add-api.action.js +27 -0
  70. package/es6/src/add-api.command.js +29 -0
  71. package/es6/src/add.command.js +12 -0
  72. package/es6/src/add.module.js +14 -0
  73. package/es6/src/auth0-configure.action.js +18 -0
  74. package/es6/src/auth0-configure.command.js +14 -0
  75. package/es6/src/auth0-login.action.js +18 -0
  76. package/es6/src/auth0-login.command.js +13 -0
  77. package/es6/src/auth0.command.js +12 -0
  78. package/es6/src/auth0.module.js +18 -0
  79. package/es6/src/cli.js +4 -0
  80. package/es6/src/create.command.js +12 -0
  81. package/es6/src/create.module.js +14 -0
  82. package/es6/src/domain/prompt.js +41 -0
  83. package/es6/src/index.js +9 -0
  84. package/es6/src/models/compose.model.js +254 -0
  85. package/es6/src/models/config-yaml.model.js +74 -0
  86. package/es6/src/models/const.js +20 -0
  87. package/es6/src/models/dev-container.model.js +162 -0
  88. package/es6/src/models/docker-image.model.js +235 -0
  89. package/es6/src/models/env-file.model.js +44 -0
  90. package/es6/src/models/gitignore.model.js +38 -0
  91. package/es6/src/models/launch-json.model.js +60 -0
  92. package/es6/src/models/package-json.model.js +141 -0
  93. package/es6/src/models/project.model.js +117 -0
  94. package/es6/src/models/source-file.js +1 -0
  95. package/es6/src/models/tsconfig.model.js +22 -0
  96. package/es6/src/models/vitest-config.model.js +23 -0
  97. package/es6/src/models/vscode-settings.model.js +19 -0
  98. package/es6/src/program.js +50 -0
  99. package/es6/src/resolve-target-dir.js +7 -0
  100. package/es6/src/services/scaffold.service.js +50 -0
  101. package/es6/src/version.js +34 -0
  102. package/es6/src/webapi/api-name.js +57 -0
  103. package/es6/src/webapi/auth0-commands.js +185 -0
  104. package/es6/src/webapi/authorize-scopes.js +55 -0
  105. package/es6/src/webapi/cli-options.js +34 -0
  106. package/es6/src/webapi/const.js +21 -0
  107. package/es6/src/webapi/create-api.js +245 -0
  108. package/es6/src/webapi/devcontainer/codebase-rag-mcp.js +154 -0
  109. package/es6/src/webapi/devcontainer/codebase-rag-mcp.ts +182 -0
  110. package/es6/src/webapi/devcontainer/host-scripts.js +29 -0
  111. package/es6/src/webapi/devcontainer/templates/codebase-rag.env.example +3 -0
  112. package/es6/src/webapi/devcontainer/templates/initialize.sh +169 -0
  113. package/es6/src/webapi/devcontainer/templates/post-create.sh +35 -0
  114. package/es6/src/webapi/devcontainer/templates/post-start.sh +65 -0
  115. package/es6/src/webapi/devcontainer/templates/tty-prompt.sh +38 -0
  116. package/es6/src/webapi/features/auth.feature.js +357 -0
  117. package/es6/src/webapi/features/auth0-cli.js +406 -0
  118. package/es6/src/webapi/features/biome-format.js +40 -0
  119. package/es6/src/webapi/features/database.feature.js +423 -0
  120. package/es6/src/webapi/features/finalize.feature.js +83 -0
  121. package/es6/src/webapi/features/postman.feature.js +256 -0
  122. package/es6/src/webapi/models/api-package-json.model.js +53 -0
  123. package/es6/src/webapi/models/auth-config.model.js +20 -0
  124. package/es6/src/webapi/models/controller-source-file.model.js +181 -0
  125. package/{src/webapi/models/github-ci.model.ts → es6/src/webapi/models/github-ci.model.js} +27 -29
  126. package/es6/src/webapi/models/main-source-file.model.js +161 -0
  127. package/es6/src/webapi/models/production-dockerfile.model.js +66 -0
  128. package/es6/src/webapi/models/sample-files.model.js +40 -0
  129. package/es6/src/webapi/models/webapi-image.model.js +18 -0
  130. package/es6/src/webapi/postman/hello-openapi.js +166 -0
  131. package/es6/src/webapi/postman/local-view.js +167 -0
  132. package/es6/src/webapi/postman/openapi-to-postman.js +179 -0
  133. package/es6/src/webapi/workspace-readme.js +88 -0
  134. package/es6/src/webapi.action.js +18 -0
  135. package/es6/src/webapi.command.js +33 -0
  136. package/package.json +19 -9
  137. package/types/src/add-api.action.d.ts +13 -0
  138. package/types/src/add-api.command.d.ts +7 -0
  139. package/types/src/add.command.d.ts +6 -0
  140. package/types/src/add.module.d.ts +14 -0
  141. package/types/src/auth0-configure.action.d.ts +7 -0
  142. package/types/src/auth0-configure.command.d.ts +6 -0
  143. package/types/src/auth0-login.action.d.ts +4 -0
  144. package/types/src/auth0-login.command.d.ts +6 -0
  145. package/types/src/auth0.command.d.ts +6 -0
  146. package/types/src/auth0.module.d.ts +18 -0
  147. package/types/src/cli.d.ts +2 -0
  148. package/types/src/create.command.d.ts +6 -0
  149. package/types/src/create.module.d.ts +14 -0
  150. package/types/src/domain/prompt.d.ts +4 -0
  151. package/{src/index.ts → types/src/index.d.ts} +4 -0
  152. package/types/src/models/compose.model.d.ts +73 -0
  153. package/types/src/models/config-yaml.model.d.ts +27 -0
  154. package/types/src/models/const.d.ts +20 -0
  155. package/types/src/models/dev-container.model.d.ts +49 -0
  156. package/types/src/models/docker-image.model.d.ts +90 -0
  157. package/types/src/models/env-file.model.d.ts +16 -0
  158. package/types/src/models/gitignore.model.d.ts +9 -0
  159. package/types/src/models/launch-json.model.d.ts +7 -0
  160. package/types/src/models/package-json.model.d.ts +36 -0
  161. package/types/src/models/project.model.d.ts +60 -0
  162. package/{src/models/source-file.ts → types/src/models/source-file.d.ts} +4 -6
  163. package/types/src/models/tsconfig.model.d.ts +5 -0
  164. package/types/src/models/vitest-config.model.d.ts +5 -0
  165. package/types/src/models/vscode-settings.model.d.ts +7 -0
  166. package/types/src/program.d.ts +8 -0
  167. package/{src/resolve-target-dir.ts → types/src/resolve-target-dir.d.ts} +1 -4
  168. package/types/src/services/scaffold.service.d.ts +22 -0
  169. package/types/src/version.d.ts +6 -0
  170. package/types/src/webapi/api-name.d.ts +14 -0
  171. package/types/src/webapi/auth0-commands.d.ts +11 -0
  172. package/types/src/webapi/authorize-scopes.d.ts +7 -0
  173. package/types/src/webapi/cli-options.d.ts +6 -0
  174. package/{src/webapi/const.ts → types/src/webapi/const.d.ts} +9 -21
  175. package/types/src/webapi/create-api.d.ts +15 -0
  176. package/types/src/webapi/devcontainer/codebase-rag-mcp.d.ts +32 -0
  177. package/types/src/webapi/devcontainer/codebase-rag-mcp.ts +182 -0
  178. package/types/src/webapi/devcontainer/host-scripts.d.ts +7 -0
  179. package/types/src/webapi/devcontainer/templates/codebase-rag.env.example +3 -0
  180. package/types/src/webapi/devcontainer/templates/initialize.sh +169 -0
  181. package/types/src/webapi/devcontainer/templates/post-create.sh +35 -0
  182. package/types/src/webapi/devcontainer/templates/post-start.sh +65 -0
  183. package/types/src/webapi/devcontainer/templates/tty-prompt.sh +38 -0
  184. package/types/src/webapi/features/auth.feature.d.ts +10 -0
  185. package/types/src/webapi/features/auth0-cli.d.ts +84 -0
  186. package/types/src/webapi/features/biome-format.d.ts +5 -0
  187. package/types/src/webapi/features/database.feature.d.ts +7 -0
  188. package/types/src/webapi/features/finalize.feature.d.ts +2 -0
  189. package/types/src/webapi/features/postman.feature.d.ts +16 -0
  190. package/types/src/webapi/models/api-package-json.model.d.ts +18 -0
  191. package/types/src/webapi/models/auth-config.model.d.ts +26 -0
  192. package/types/src/webapi/models/controller-source-file.model.d.ts +46 -0
  193. package/types/src/webapi/models/github-ci.model.d.ts +9 -0
  194. package/types/src/webapi/models/main-source-file.model.d.ts +54 -0
  195. package/types/src/webapi/models/production-dockerfile.model.d.ts +18 -0
  196. package/types/src/webapi/models/sample-files.model.d.ts +7 -0
  197. package/types/src/webapi/models/webapi-image.model.d.ts +12 -0
  198. package/types/src/webapi/postman/hello-openapi.d.ts +19 -0
  199. package/types/src/webapi/postman/local-view.d.ts +17 -0
  200. package/types/src/webapi/postman/openapi-to-postman.d.ts +62 -0
  201. package/types/src/webapi/workspace-readme.d.ts +18 -0
  202. package/types/src/webapi.action.d.ts +14 -0
  203. package/types/src/webapi.command.d.ts +11 -0
  204. package/src/add-api.action.ts +0 -25
  205. package/src/add-api.command.ts +0 -31
  206. package/src/add.command.ts +0 -20
  207. package/src/add.module.ts +0 -11
  208. package/src/cli.ts +0 -4
  209. package/src/create.command.ts +0 -20
  210. package/src/create.module.ts +0 -11
  211. package/src/domain/prompt.ts +0 -50
  212. package/src/models/compose.model.ts +0 -205
  213. package/src/models/config-yaml.model.ts +0 -83
  214. package/src/models/const.ts +0 -20
  215. package/src/models/dev-container.model.ts +0 -136
  216. package/src/models/docker-image.model.ts +0 -343
  217. package/src/models/env-file.model.ts +0 -45
  218. package/src/models/gitignore.model.ts +0 -35
  219. package/src/models/launch-json.model.ts +0 -60
  220. package/src/models/package-json.model.ts +0 -169
  221. package/src/models/project.model.ts +0 -141
  222. package/src/models/tsconfig.model.ts +0 -29
  223. package/src/models/vitest-config.model.ts +0 -26
  224. package/src/models/vscode-settings.model.ts +0 -24
  225. package/src/program.ts +0 -63
  226. package/src/services/scaffold.service.ts +0 -89
  227. package/src/version.ts +0 -56
  228. package/src/webapi/api-name.ts +0 -73
  229. package/src/webapi/cli-options.ts +0 -56
  230. package/src/webapi/create-api.ts +0 -275
  231. package/src/webapi/devcontainer/host-scripts.ts +0 -35
  232. package/src/webapi/features/auth.feature.ts +0 -454
  233. package/src/webapi/features/auth0-cli.ts +0 -421
  234. package/src/webapi/features/biome-format.ts +0 -34
  235. package/src/webapi/features/database.feature.ts +0 -522
  236. package/src/webapi/features/finalize.feature.ts +0 -112
  237. package/src/webapi/features/postman.feature.ts +0 -287
  238. package/src/webapi/models/api-package-json.model.ts +0 -60
  239. package/src/webapi/models/auth-config.model.ts +0 -36
  240. package/src/webapi/models/controller-source-file.model.ts +0 -232
  241. package/src/webapi/models/main-source-file.model.ts +0 -208
  242. package/src/webapi/models/production-dockerfile.model.ts +0 -162
  243. package/src/webapi/models/sample-files.model.ts +0 -45
  244. package/src/webapi/models/webapi-image.model.ts +0 -21
  245. package/src/webapi/postman/hello-openapi.ts +0 -92
  246. package/src/webapi/postman/local-view.ts +0 -195
  247. package/src/webapi/postman/openapi-to-postman.ts +0 -208
  248. package/src/webapi/workspace-readme.ts +0 -192
  249. package/src/webapi.action.ts +0 -22
  250. package/src/webapi.command.ts +0 -41
  251. package/tests/auth-postman.wiring.spec.ts +0 -263
  252. package/tests/auth0-cli.spec.ts +0 -232
  253. package/tests/biome-format.spec.ts +0 -49
  254. package/tests/cli.integration.spec.ts +0 -658
  255. package/tests/compose.model.spec.ts +0 -51
  256. package/tests/container-image.model.spec.ts +0 -162
  257. package/tests/dev-container.model.spec.ts +0 -29
  258. package/tests/devcontainer-base-image.spec.ts +0 -32
  259. package/tests/hello-di-inject.scaffold.spec.ts +0 -18
  260. package/tests/hello-route.contract.spec.ts +0 -94
  261. package/tests/package-json.order.spec.ts +0 -59
  262. package/tests/postman-from-openapi.spec.ts +0 -197
  263. package/tests/seed-devcontainer-templates.ts +0 -40
  264. package/tests/webapi/devcontainer/codebase-rag-mcp.spec.ts +0 -96
@@ -1,205 +0,0 @@
1
- import { WELL_KNOWN_FILES } from "./const.js";
2
- import type { KeyedModel } from "./source-file.js";
3
-
4
- export type ComposeNetworkRef =
5
- | string
6
- | {
7
- /** Network key under `networks:` on this service */
8
- [networkKey: string]: { aliases?: string[] };
9
- };
10
-
11
- export interface ComposeHealthcheck {
12
- test: string[];
13
- interval?: string;
14
- timeout?: string;
15
- retries?: number;
16
- }
17
-
18
- export interface ComposeService {
19
- build?: string;
20
- image?: string;
21
- container_name?: string;
22
- /** Quoted in YAML (`0:0` must not parse as a number). */
23
- user?: string;
24
- env_file?: string[];
25
- environment?: Record<string, string>;
26
- ports?: string[];
27
- volumes?: string[];
28
- command?: string;
29
- restart?: string;
30
- depends_on?: string[];
31
- /** Compose profiles (service only starts when profile is enabled). */
32
- profiles?: string[];
33
- /** Attach to compose networks (string name or map with aliases). */
34
- networks?: ComposeNetworkRef[];
35
- healthcheck?: ComposeHealthcheck;
36
- }
37
-
38
- export type ComposeNetwork = {
39
- /** Fixed Docker network name (shareable across compose projects). */
40
- name: string;
41
- external?: boolean;
42
- };
43
-
44
- /**
45
- * Live builder for `docker-compose.yml`.
46
- *
47
- * Features call `addService` / `addVolume` / `addNetwork` in their scaffold phases.
48
- */
49
- export class DockerCompose implements KeyedModel {
50
- public readonly key = WELL_KNOWN_FILES.DOCKER_COMPOSE;
51
- private _projectName: string | undefined;
52
- private readonly _headerComments: string[] = [];
53
- private readonly _services: Map<string, ComposeService> = new Map();
54
- private readonly _volumes: Set<string> = new Set();
55
- private readonly _networks: Map<string, ComposeNetwork> = new Map();
56
-
57
- /** Compose project name (`name:` top-level) — isolates containers/volumes. */
58
- public setProjectName(name: string): this {
59
- this._projectName = name;
60
- return this;
61
- }
62
-
63
- /** File-level `#` comments rendered above `name:` / `services:`. */
64
- public addHeaderComment(...lines: string[]): this {
65
- this._headerComments.push(...lines);
66
- return this;
67
- }
68
-
69
- public addService(name: string, config: ComposeService): this {
70
- this._services.set(name, config);
71
- return this;
72
- }
73
-
74
- public files() {
75
- return [
76
- {
77
- filePath: ".devcontainer/docker-compose.yml",
78
- content: this.getContent(),
79
- },
80
- ];
81
- }
82
-
83
- public addVolume(name: string): this {
84
- this._volumes.add(name);
85
- return this;
86
- }
87
-
88
- public addNetwork(key: string, network: ComposeNetwork): this {
89
- this._networks.set(key, network);
90
- return this;
91
- }
92
-
93
- /** Append an env_file path to an existing service. */
94
- public addEnvFile(serviceName: string, filePath: string): this {
95
- const svc = this._services.get(serviceName);
96
- if (svc) svc.env_file = [...(svc.env_file ?? []), filePath];
97
- return this;
98
- }
99
-
100
- public getContent(): string {
101
- const lines: string[] = [];
102
- for (const comment of this._headerComments) {
103
- lines.push(comment.startsWith("#") ? comment : `# ${comment}`);
104
- }
105
- if (this._headerComments.length > 0) {
106
- lines.push("");
107
- }
108
- if (this._projectName) {
109
- lines.push(`name: ${this._projectName}`, "");
110
- }
111
- lines.push("services:");
112
-
113
- for (const [name, svc] of this._services) {
114
- lines.push(` ${name}:`);
115
- if (svc.build) lines.push(` build: ${svc.build}`);
116
- if (svc.image) lines.push(` image: ${svc.image}`);
117
- if (svc.container_name) lines.push(` container_name: ${svc.container_name}`);
118
- if (svc.command) lines.push(` command: ${svc.command}`);
119
- if (svc.user) lines.push(` user: "${svc.user}"`);
120
- if (svc.restart) lines.push(` restart: ${svc.restart}`);
121
-
122
- if (svc.profiles && svc.profiles.length > 0) {
123
- lines.push(" profiles:");
124
- for (const p of svc.profiles) lines.push(` - ${p}`);
125
- }
126
-
127
- if (svc.env_file && svc.env_file.length > 0) {
128
- lines.push(" env_file:");
129
- for (const f of svc.env_file) lines.push(` - ${f}`);
130
- }
131
-
132
- if (svc.environment && Object.keys(svc.environment).length > 0) {
133
- lines.push(" environment:");
134
- for (const [k, v] of Object.entries(svc.environment)) {
135
- lines.push(` ${k}: ${v}`);
136
- }
137
- }
138
-
139
- if (svc.ports && svc.ports.length > 0) {
140
- lines.push(" ports:");
141
- for (const p of svc.ports) lines.push(` - "${p}"`);
142
- }
143
-
144
- if (svc.volumes && svc.volumes.length > 0) {
145
- lines.push(" volumes:");
146
- for (const v of svc.volumes) lines.push(` - ${v}`);
147
- }
148
-
149
- if (svc.networks && svc.networks.length > 0) {
150
- const onlyStrings = svc.networks.every((n) => typeof n === "string");
151
- if (onlyStrings) {
152
- lines.push(" networks:");
153
- for (const n of svc.networks) lines.push(` - ${n as string}`);
154
- } else {
155
- lines.push(" networks:");
156
- for (const n of svc.networks) {
157
- if (typeof n === "string") {
158
- lines.push(` ${n}:`);
159
- } else {
160
- for (const [netKey, cfg] of Object.entries(n)) {
161
- lines.push(` ${netKey}:`);
162
- if (cfg.aliases && cfg.aliases.length > 0) {
163
- lines.push(" aliases:");
164
- for (const a of cfg.aliases) lines.push(` - ${a}`);
165
- }
166
- }
167
- }
168
- }
169
- }
170
- }
171
-
172
- if (svc.depends_on && svc.depends_on.length > 0) {
173
- lines.push(" depends_on:");
174
- for (const d of svc.depends_on) lines.push(` - ${d}`);
175
- }
176
-
177
- if (svc.healthcheck) {
178
- const hc = svc.healthcheck;
179
- lines.push(" healthcheck:");
180
- lines.push(` test: ${JSON.stringify(hc.test)}`);
181
- if (hc.interval) lines.push(` interval: ${hc.interval}`);
182
- if (hc.timeout) lines.push(` timeout: ${hc.timeout}`);
183
- if (hc.retries != null) lines.push(` retries: ${hc.retries}`);
184
- }
185
- }
186
-
187
- if (this._networks.size > 0) {
188
- lines.push("");
189
- lines.push("networks:");
190
- for (const [key, net] of this._networks) {
191
- lines.push(` ${key}:`);
192
- lines.push(` name: ${net.name}`);
193
- if (net.external) lines.push(" external: true");
194
- }
195
- }
196
-
197
- if (this._volumes.size > 0) {
198
- lines.push("");
199
- lines.push("volumes:");
200
- for (const v of this._volumes) lines.push(` ${v}:`);
201
- }
202
-
203
- return `${lines.join("\n")}\n`;
204
- }
205
- }
@@ -1,83 +0,0 @@
1
- import { readFileSync } from "node:fs";
2
- import type { KeyedModel, SourceFile } from "./source-file.js";
3
-
4
- /**
5
- * Builder for a YAML config file (e.g. config/config.yaml or config/config.dev.yaml).
6
- *
7
- * Starts with a base section passed to the constructor. Features call
8
- * `addSection(yaml)` during their scaffold phase to append their own block.
9
- * `files()` joins all sections with a blank line separator.
10
- */
11
- export class ConfigYaml implements KeyedModel {
12
- private readonly _sections: string[] = [];
13
-
14
- public constructor(
15
- public readonly key: string,
16
- private readonly filePath: string,
17
- baseContent: string,
18
- ) {
19
- this._sections.push(baseContent);
20
- }
21
-
22
- public addSection(yaml: string): this {
23
- this._sections.push(yaml);
24
- return this;
25
- }
26
-
27
- /** True when a datasource with this `name:` already appears in the file. */
28
- public hasDataSource(name: string): boolean {
29
- return this._sections.join("\n").includes(`name: ${name}\n`);
30
- }
31
-
32
- public hasDataSources(): boolean {
33
- return this._sections.join("\n").includes("dataSources:");
34
- }
35
-
36
- /**
37
- * Insert a `dataSources` list item. Used by `webapi add` so we do not write a
38
- * second top-level `database:` key (YAML last-key-wins).
39
- */
40
- public appendDataSource(item: string): this {
41
- const current = this._sections.join("\n");
42
- this._sections.length = 0;
43
- this._sections.push(injectYamlDataSource(current, item));
44
- return this;
45
- }
46
-
47
- public static fromFile(key: string, relativePath: string, absolutePath: string): ConfigYaml {
48
- const content = readFileSync(absolutePath, "utf8");
49
- return new ConfigYaml(key, relativePath, content);
50
- }
51
-
52
- public files(): SourceFile[] {
53
- return [{ filePath: this.filePath, content: this._sections.join("\n") }];
54
- }
55
- }
56
-
57
- /** Insert a YAML list item under `dataSources:`; append a new `database:` block if missing. */
58
- export function injectYamlDataSource(yaml: string, item: string): string {
59
- const block = item.replace(/\n$/, "");
60
- if (!yaml.includes("dataSources:")) {
61
- const prefix = yaml.trimEnd();
62
- const section = `database:\n dataSources:\n${block}\n`;
63
- return prefix.length > 0 ? `${prefix}\n\n${section}` : section;
64
- }
65
- const lines = yaml.split("\n");
66
- const dsIndex = lines.findIndex((line) => /^\s*dataSources:\s*$/.test(line));
67
- if (dsIndex < 0) {
68
- return `${yaml.trimEnd()}\n\ndatabase:\n dataSources:\n${block}\n`;
69
- }
70
- let insertAt = lines.length;
71
- for (let i = dsIndex + 1; i < lines.length; i++) {
72
- if (/^[A-Za-z]/.test(lines[i] ?? "")) {
73
- insertAt = i;
74
- break;
75
- }
76
- }
77
- const insertLines = block.split("\n");
78
- if (insertAt < lines.length && lines[insertAt - 1] !== "") {
79
- insertLines.push("");
80
- }
81
- lines.splice(insertAt, 0, ...insertLines);
82
- return lines.join("\n");
83
- }
@@ -1,20 +0,0 @@
1
- export const WELL_KNOWN_FILES = {
2
- VSCODE_SETTINGS: "VSCODE_SETTINGS",
3
- LAUNCH_JSON: "LAUNCH_JSON",
4
- DOCKER_COMPOSE: "DOCKER_COMPOSE",
5
- DEVCONTAINER_JSON: "DEVCONTAINER_JSON",
6
- DOCKERFILE: "DOCKERFILE",
7
- PRODUCTION_DOCKERFILE: "PRODUCTION_DOCKERFILE",
8
- GITHUB_CI: "GITHUB_CI",
9
- PACKAGE_JSON: "PACKAGE_JSON",
10
- API_PACKAGE_JSON: "API_PACKAGE_JSON",
11
- TSCONFIG: "TSCONFIG",
12
- VITEST_CONFIG: "VITEST_CONFIG",
13
- MAIN_TS: "MAIN_TS",
14
- CONTROLLER_TS: "CONTROLLER_TS",
15
- CONFIG_YAML: "CONFIG_YAML",
16
- CONFIG_DEV_YAML: "CONFIG_DEV_YAML",
17
- GITIGNORE: "GITIGNORE",
18
- AUTH_CONFIG: "AUTH_CONFIG",
19
- ENV_FILE: "ENV_FILE",
20
- };
@@ -1,136 +0,0 @@
1
- import { WELL_KNOWN_FILES } from "./const.js";
2
- import type { KeyedModel, SourceFile } from "./source-file.js";
3
-
4
- /**
5
- * Model for `.devcontainer/devcontainer.json`.
6
- *
7
- * Features call builder methods (`addExtension`, `forwardPort`, etc.) during
8
- * their configure phase. `MonoRepoScaffold` calls `files()` at render time.
9
- */
10
-
11
- export type PortAttributes = {
12
- label?: string;
13
- /** When true, host port must match the container port (no random remap). */
14
- requireLocalPort?: boolean;
15
- onAutoForward?: "notify" | "openBrowser" | "openPreview" | "silent" | "ignore";
16
- };
17
-
18
- export class DevContainer implements KeyedModel {
19
- public readonly key = WELL_KNOWN_FILES.DEVCONTAINER_JSON;
20
- private readonly _extensions: string[] = [];
21
- private readonly _ports: number[] = [];
22
- private readonly _portAttributes = new Map<number, PortAttributes>();
23
- private readonly _mounts: string[];
24
- private _postCreateCommand?: string;
25
- private _updateContentCommand?: string;
26
- private _postStartCommand?: string;
27
- private _initializeCommand?: string;
28
- private _remoteUser = "node";
29
- private _useCompose = false;
30
-
31
- public constructor() {
32
- this._mounts = ["source=..,target=/workspace,type=bind,consistency=cached"];
33
- }
34
-
35
- public addExtension(...ids: string[]): this {
36
- this._extensions.push(...ids);
37
- return this;
38
- }
39
-
40
- public forwardPort(...ports: number[]): this {
41
- this._ports.push(...ports);
42
- return this;
43
- }
44
-
45
- public setPortAttributes(port: number, attrs: PortAttributes): this {
46
- this._portAttributes.set(port, attrs);
47
- return this;
48
- }
49
-
50
- public setPostCreateCommand(cmd: string): this {
51
- this._postCreateCommand = cmd;
52
- return this;
53
- }
54
-
55
- public setUpdateContentCommand(cmd: string): this {
56
- this._updateContentCommand = cmd;
57
- return this;
58
- }
59
-
60
- public setPostStartCommand(cmd: string): this {
61
- this._postStartCommand = cmd;
62
- return this;
63
- }
64
-
65
- public setInitializeCommand(cmd: string): this {
66
- this._initializeCommand = cmd;
67
- return this;
68
- }
69
-
70
- public setRemoteUser(user: string): this {
71
- this._remoteUser = user;
72
- return this;
73
- }
74
-
75
- public useCompose(): this {
76
- this._useCompose = true;
77
- return this;
78
- }
79
-
80
- public files(): SourceFile[] {
81
- const config: Record<string, unknown> = {};
82
-
83
- if (this._useCompose) {
84
- config.dockerComposeFile = "docker-compose.yml";
85
- config.service = "devcontainer";
86
- config.workspaceFolder = "/workspace";
87
- }
88
-
89
- if (this._initializeCommand) {
90
- config.initializeCommand = this._initializeCommand;
91
- }
92
-
93
- if (this._mounts) {
94
- config.mounts = this._mounts;
95
- }
96
-
97
- if (this._extensions.length > 0) {
98
- config.customizations = { vscode: { extensions: this._extensions } };
99
- }
100
-
101
- if (this._ports.length > 0) {
102
- config.forwardPorts = this._ports;
103
- }
104
-
105
- if (this._portAttributes.size > 0) {
106
- const portsAttributes: Record<string, PortAttributes> = {};
107
- for (const [port, attrs] of this._portAttributes) {
108
- portsAttributes[String(port)] = attrs;
109
- }
110
- config.portsAttributes = portsAttributes;
111
- }
112
-
113
- if (this._postCreateCommand) {
114
- config.postCreateCommand = this._postCreateCommand;
115
- }
116
-
117
- if (this._updateContentCommand) {
118
- config.updateContentCommand = this._updateContentCommand;
119
- }
120
-
121
- if (this._postStartCommand) {
122
- config.postStartCommand = this._postStartCommand;
123
- }
124
-
125
- if (this._remoteUser) {
126
- config.remoteUser = this._remoteUser;
127
- }
128
-
129
- return [
130
- {
131
- filePath: ".devcontainer/devcontainer.json",
132
- content: JSON.stringify(config, null, 2),
133
- },
134
- ];
135
- }
136
- }