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

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 (240) hide show
  1. package/commonjs/src/add-api.action.js +39 -0
  2. package/commonjs/src/add-api.command.js +41 -0
  3. package/commonjs/src/add.command.js +24 -0
  4. package/commonjs/src/add.module.js +26 -0
  5. package/commonjs/src/cli.js +9 -0
  6. package/commonjs/src/create.command.js +24 -0
  7. package/commonjs/src/create.module.js +26 -0
  8. package/commonjs/src/domain/prompt.js +64 -0
  9. package/commonjs/src/index.js +38 -0
  10. package/commonjs/src/models/compose.model.js +150 -0
  11. package/commonjs/src/models/config-yaml.model.js +88 -0
  12. package/commonjs/src/models/const.js +32 -0
  13. package/commonjs/src/models/dev-container.model.js +116 -0
  14. package/commonjs/src/models/docker-image.model.js +259 -0
  15. package/commonjs/src/models/env-file.model.js +50 -0
  16. package/commonjs/src/models/gitignore.model.js +43 -0
  17. package/commonjs/src/models/launch-json.model.js +74 -0
  18. package/commonjs/src/models/package-json.model.js +149 -0
  19. package/commonjs/src/models/project.model.js +134 -0
  20. package/commonjs/src/models/source-file.js +6 -0
  21. package/commonjs/src/models/tsconfig.model.js +34 -0
  22. package/commonjs/src/models/vitest-config.model.js +35 -0
  23. package/commonjs/src/models/vscode-settings.model.js +31 -0
  24. package/commonjs/src/program.js +57 -0
  25. package/commonjs/src/resolve-target-dir.js +19 -0
  26. package/commonjs/src/services/scaffold.service.js +62 -0
  27. package/commonjs/src/version.js +57 -0
  28. package/commonjs/src/webapi/api-name.js +95 -0
  29. package/commonjs/src/webapi/cli-options.js +101 -0
  30. package/commonjs/src/webapi/const.js +50 -0
  31. package/commonjs/src/webapi/create-api.js +237 -0
  32. package/commonjs/src/webapi/devcontainer/codebase-rag-mcp.js +166 -0
  33. package/commonjs/src/webapi/devcontainer/codebase-rag-mcp.ts +182 -0
  34. package/commonjs/src/webapi/devcontainer/host-scripts.js +52 -0
  35. package/commonjs/src/webapi/devcontainer/templates/codebase-rag.env.example +3 -0
  36. package/commonjs/src/webapi/devcontainer/templates/initialize.sh +169 -0
  37. package/commonjs/src/webapi/devcontainer/templates/post-create.sh +35 -0
  38. package/commonjs/src/webapi/devcontainer/templates/post-start.sh +65 -0
  39. package/commonjs/src/webapi/devcontainer/templates/tty-prompt.sh +38 -0
  40. package/commonjs/src/webapi/features/auth.feature.js +441 -0
  41. package/commonjs/src/webapi/features/auth0-cli.js +435 -0
  42. package/commonjs/src/webapi/features/biome-format.js +49 -0
  43. package/commonjs/src/webapi/features/database.feature.js +433 -0
  44. package/commonjs/src/webapi/features/finalize.feature.js +95 -0
  45. package/commonjs/src/webapi/features/postman.feature.js +324 -0
  46. package/commonjs/src/webapi/models/api-package-json.model.js +60 -0
  47. package/commonjs/src/webapi/models/auth-config.model.js +26 -0
  48. package/commonjs/src/webapi/models/controller-source-file.model.js +193 -0
  49. package/commonjs/src/webapi/models/github-ci.model.js +193 -0
  50. package/commonjs/src/webapi/models/main-source-file.model.js +167 -0
  51. package/commonjs/src/webapi/models/production-dockerfile.model.js +157 -0
  52. package/commonjs/src/webapi/models/sample-files.model.js +60 -0
  53. package/commonjs/src/webapi/models/webapi-image.model.js +27 -0
  54. package/commonjs/src/webapi/postman/hello-openapi.js +175 -0
  55. package/commonjs/src/webapi/postman/local-view.js +184 -0
  56. package/commonjs/src/webapi/postman/openapi-to-postman.js +202 -0
  57. package/commonjs/src/webapi/workspace-readme.js +110 -0
  58. package/commonjs/src/webapi.action.js +30 -0
  59. package/commonjs/src/webapi.command.js +45 -0
  60. package/es6/src/add-api.action.js +29 -0
  61. package/es6/src/add-api.command.js +31 -0
  62. package/es6/src/add.command.js +14 -0
  63. package/es6/src/add.module.js +16 -0
  64. package/es6/src/cli.js +5 -0
  65. package/es6/src/create.command.js +14 -0
  66. package/es6/src/create.module.js +16 -0
  67. package/es6/src/domain/prompt.js +43 -0
  68. package/es6/src/index.js +8 -0
  69. package/es6/src/models/compose.model.js +144 -0
  70. package/es6/src/models/config-yaml.model.js +76 -0
  71. package/es6/src/models/const.js +22 -0
  72. package/es6/src/models/dev-container.model.js +106 -0
  73. package/es6/src/models/docker-image.model.js +217 -0
  74. package/es6/src/models/env-file.model.js +46 -0
  75. package/es6/src/models/gitignore.model.js +33 -0
  76. package/es6/src/models/launch-json.model.js +64 -0
  77. package/es6/src/models/package-json.model.js +137 -0
  78. package/es6/src/models/project.model.js +119 -0
  79. package/es6/src/models/source-file.js +3 -0
  80. package/es6/src/models/tsconfig.model.js +24 -0
  81. package/es6/src/models/vitest-config.model.js +25 -0
  82. package/es6/src/models/vscode-settings.model.js +21 -0
  83. package/es6/src/program.js +39 -0
  84. package/es6/src/resolve-target-dir.js +9 -0
  85. package/es6/src/services/scaffold.service.js +52 -0
  86. package/es6/src/version.js +36 -0
  87. package/es6/src/webapi/api-name.js +59 -0
  88. package/es6/src/webapi/cli-options.js +36 -0
  89. package/es6/src/webapi/const.js +20 -0
  90. package/es6/src/webapi/create-api.js +217 -0
  91. package/es6/src/webapi/devcontainer/codebase-rag-mcp.js +156 -0
  92. package/es6/src/webapi/devcontainer/codebase-rag-mcp.ts +182 -0
  93. package/es6/src/webapi/devcontainer/host-scripts.js +31 -0
  94. package/es6/src/webapi/devcontainer/templates/codebase-rag.env.example +3 -0
  95. package/es6/src/webapi/devcontainer/templates/initialize.sh +169 -0
  96. package/es6/src/webapi/devcontainer/templates/post-create.sh +35 -0
  97. package/es6/src/webapi/devcontainer/templates/post-start.sh +65 -0
  98. package/es6/src/webapi/devcontainer/templates/tty-prompt.sh +38 -0
  99. package/es6/src/webapi/features/auth.feature.js +390 -0
  100. package/es6/src/webapi/features/auth0-cli.js +375 -0
  101. package/es6/src/webapi/features/biome-format.js +42 -0
  102. package/es6/src/webapi/features/database.feature.js +423 -0
  103. package/es6/src/webapi/features/finalize.feature.js +85 -0
  104. package/es6/src/webapi/features/postman.feature.js +258 -0
  105. package/es6/src/webapi/models/api-package-json.model.js +55 -0
  106. package/es6/src/webapi/models/auth-config.model.js +22 -0
  107. package/es6/src/webapi/models/controller-source-file.model.js +184 -0
  108. package/es6/src/webapi/models/github-ci.model.js +186 -0
  109. package/es6/src/webapi/models/main-source-file.model.js +163 -0
  110. package/es6/src/webapi/models/production-dockerfile.model.js +148 -0
  111. package/es6/src/webapi/models/sample-files.model.js +42 -0
  112. package/es6/src/webapi/models/webapi-image.model.js +20 -0
  113. package/es6/src/webapi/postman/hello-openapi.js +168 -0
  114. package/es6/src/webapi/postman/local-view.js +169 -0
  115. package/es6/src/webapi/postman/openapi-to-postman.js +179 -0
  116. package/es6/src/webapi/workspace-readme.js +89 -0
  117. package/es6/src/webapi.action.js +20 -0
  118. package/es6/src/webapi.command.js +35 -0
  119. package/package.json +8 -8
  120. package/types/src/add-api.action.d.ts +13 -0
  121. package/types/src/add-api.command.d.ts +7 -0
  122. package/types/src/add.command.d.ts +6 -0
  123. package/types/src/add.module.d.ts +14 -0
  124. package/types/src/cli.d.ts +2 -0
  125. package/types/src/create.command.d.ts +6 -0
  126. package/types/src/create.module.d.ts +14 -0
  127. package/types/src/domain/prompt.d.ts +4 -0
  128. package/types/src/models/compose.model.d.ts +64 -0
  129. package/types/src/models/config-yaml.model.d.ts +27 -0
  130. package/types/src/models/const.d.ts +20 -0
  131. package/types/src/models/dev-container.model.d.ts +37 -0
  132. package/types/src/models/docker-image.model.d.ts +84 -0
  133. package/types/src/models/env-file.model.d.ts +16 -0
  134. package/types/src/models/gitignore.model.d.ts +7 -0
  135. package/types/src/models/launch-json.model.d.ts +7 -0
  136. package/types/src/models/package-json.model.d.ts +35 -0
  137. package/types/src/models/project.model.d.ts +60 -0
  138. package/{src/models/source-file.ts → types/src/models/source-file.d.ts} +4 -6
  139. package/types/src/models/tsconfig.model.d.ts +5 -0
  140. package/types/src/models/vitest-config.model.d.ts +5 -0
  141. package/types/src/models/vscode-settings.model.d.ts +7 -0
  142. package/types/src/program.d.ts +3 -0
  143. package/{src/resolve-target-dir.ts → types/src/resolve-target-dir.d.ts} +1 -4
  144. package/types/src/services/scaffold.service.d.ts +22 -0
  145. package/types/src/version.d.ts +6 -0
  146. package/types/src/webapi/api-name.d.ts +14 -0
  147. package/types/src/webapi/cli-options.d.ts +6 -0
  148. package/{src/webapi/const.ts → types/src/webapi/const.d.ts} +7 -21
  149. package/types/src/webapi/create-api.d.ts +15 -0
  150. package/types/src/webapi/devcontainer/codebase-rag-mcp.d.ts +32 -0
  151. package/types/src/webapi/devcontainer/codebase-rag-mcp.ts +182 -0
  152. package/types/src/webapi/devcontainer/host-scripts.d.ts +7 -0
  153. package/types/src/webapi/devcontainer/templates/codebase-rag.env.example +3 -0
  154. package/types/src/webapi/devcontainer/templates/initialize.sh +169 -0
  155. package/types/src/webapi/devcontainer/templates/post-create.sh +35 -0
  156. package/types/src/webapi/devcontainer/templates/post-start.sh +65 -0
  157. package/types/src/webapi/devcontainer/templates/tty-prompt.sh +38 -0
  158. package/types/src/webapi/features/auth.feature.d.ts +10 -0
  159. package/types/src/webapi/features/auth0-cli.d.ts +80 -0
  160. package/types/src/webapi/features/biome-format.d.ts +5 -0
  161. package/types/src/webapi/features/database.feature.d.ts +7 -0
  162. package/types/src/webapi/features/finalize.feature.d.ts +2 -0
  163. package/types/src/webapi/features/postman.feature.d.ts +16 -0
  164. package/types/src/webapi/models/api-package-json.model.d.ts +18 -0
  165. package/types/src/webapi/models/auth-config.model.d.ts +26 -0
  166. package/types/src/webapi/models/controller-source-file.model.d.ts +46 -0
  167. package/types/src/webapi/models/github-ci.model.d.ts +9 -0
  168. package/types/src/webapi/models/main-source-file.model.d.ts +54 -0
  169. package/types/src/webapi/models/production-dockerfile.model.d.ts +23 -0
  170. package/types/src/webapi/models/sample-files.model.d.ts +7 -0
  171. package/types/src/webapi/models/webapi-image.model.d.ts +12 -0
  172. package/types/src/webapi/postman/hello-openapi.d.ts +19 -0
  173. package/types/src/webapi/postman/local-view.d.ts +17 -0
  174. package/types/src/webapi/postman/openapi-to-postman.d.ts +62 -0
  175. package/types/src/webapi/workspace-readme.d.ts +18 -0
  176. package/types/src/webapi.action.d.ts +14 -0
  177. package/types/src/webapi.command.d.ts +11 -0
  178. package/src/add-api.action.ts +0 -25
  179. package/src/add-api.command.ts +0 -31
  180. package/src/add.command.ts +0 -20
  181. package/src/add.module.ts +0 -11
  182. package/src/cli.ts +0 -4
  183. package/src/create.command.ts +0 -20
  184. package/src/create.module.ts +0 -11
  185. package/src/domain/prompt.ts +0 -50
  186. package/src/models/compose.model.ts +0 -205
  187. package/src/models/config-yaml.model.ts +0 -83
  188. package/src/models/const.ts +0 -20
  189. package/src/models/dev-container.model.ts +0 -136
  190. package/src/models/docker-image.model.ts +0 -343
  191. package/src/models/env-file.model.ts +0 -45
  192. package/src/models/gitignore.model.ts +0 -35
  193. package/src/models/launch-json.model.ts +0 -60
  194. package/src/models/package-json.model.ts +0 -169
  195. package/src/models/project.model.ts +0 -141
  196. package/src/models/tsconfig.model.ts +0 -29
  197. package/src/models/vitest-config.model.ts +0 -26
  198. package/src/models/vscode-settings.model.ts +0 -24
  199. package/src/program.ts +0 -63
  200. package/src/services/scaffold.service.ts +0 -89
  201. package/src/version.ts +0 -56
  202. package/src/webapi/api-name.ts +0 -73
  203. package/src/webapi/cli-options.ts +0 -56
  204. package/src/webapi/create-api.ts +0 -275
  205. package/src/webapi/devcontainer/host-scripts.ts +0 -35
  206. package/src/webapi/features/auth.feature.ts +0 -454
  207. package/src/webapi/features/auth0-cli.ts +0 -421
  208. package/src/webapi/features/biome-format.ts +0 -34
  209. package/src/webapi/features/database.feature.ts +0 -522
  210. package/src/webapi/features/finalize.feature.ts +0 -112
  211. package/src/webapi/features/postman.feature.ts +0 -287
  212. package/src/webapi/models/api-package-json.model.ts +0 -60
  213. package/src/webapi/models/auth-config.model.ts +0 -36
  214. package/src/webapi/models/controller-source-file.model.ts +0 -232
  215. package/src/webapi/models/github-ci.model.ts +0 -188
  216. package/src/webapi/models/main-source-file.model.ts +0 -208
  217. package/src/webapi/models/production-dockerfile.model.ts +0 -162
  218. package/src/webapi/models/sample-files.model.ts +0 -45
  219. package/src/webapi/models/webapi-image.model.ts +0 -21
  220. package/src/webapi/postman/hello-openapi.ts +0 -92
  221. package/src/webapi/postman/local-view.ts +0 -195
  222. package/src/webapi/postman/openapi-to-postman.ts +0 -208
  223. package/src/webapi/workspace-readme.ts +0 -192
  224. package/src/webapi.action.ts +0 -22
  225. package/src/webapi.command.ts +0 -41
  226. package/tests/auth-postman.wiring.spec.ts +0 -263
  227. package/tests/auth0-cli.spec.ts +0 -232
  228. package/tests/biome-format.spec.ts +0 -49
  229. package/tests/cli.integration.spec.ts +0 -658
  230. package/tests/compose.model.spec.ts +0 -51
  231. package/tests/container-image.model.spec.ts +0 -162
  232. package/tests/dev-container.model.spec.ts +0 -29
  233. package/tests/devcontainer-base-image.spec.ts +0 -32
  234. package/tests/hello-di-inject.scaffold.spec.ts +0 -18
  235. package/tests/hello-route.contract.spec.ts +0 -94
  236. package/tests/package-json.order.spec.ts +0 -59
  237. package/tests/postman-from-openapi.spec.ts +0 -197
  238. package/tests/seed-devcontainer-templates.ts +0 -40
  239. package/tests/webapi/devcontainer/codebase-rag-mcp.spec.ts +0 -96
  240. /package/{src/index.ts → types/src/index.d.ts} +0 -0
@@ -1,275 +0,0 @@
1
- import { existsSync } from "node:fs";
2
- import { basename, join, resolve } from "node:path";
3
- import { DockerCompose } from "../models/compose.model.js";
4
- import { ConfigYaml } from "../models/config-yaml.model.js";
5
- import { WELL_KNOWN_FILES } from "../models/const.js";
6
- import { DevContainer } from "../models/dev-container.model.js";
7
- import { commandHistory } from "../models/docker-image.model.js";
8
- import { EnvFile } from "../models/env-file.model.js";
9
- import { Gitignore } from "../models/gitignore.model.js";
10
- import { LaunchJson } from "../models/launch-json.model.js";
11
- import { PackageJson } from "../models/package-json.model.js";
12
- import { MonoRepoScaffold, ProjectScaffold } from "../models/project.model.js";
13
- import { TsConfig } from "../models/tsconfig.model.js";
14
- import { VitestConfig } from "../models/vitest-config.model.js";
15
- import { VSCodeSettings } from "../models/vscode-settings.model.js";
16
- import { ScaffoldService } from "../services/scaffold.service.js";
17
- import {
18
- CreateCliError,
19
- isDecohereWorkspace,
20
- listExistingApiNames,
21
- parseApiNames,
22
- } from "./api-name.js";
23
- import {
24
- DEFAULT_WEBAPI_NAME,
25
- webapiPackageName,
26
- webapiPort,
27
- webapiProjectDir,
28
- webapiReleaseEntry,
29
- } from "./const.js";
30
- import { DevContainerHostScripts } from "./devcontainer/host-scripts.js";
31
- import { AuthFeature } from "./features/auth.feature.js";
32
- import { DatabaseFeature } from "./features/database.feature.js";
33
- import { FinalizeFeature } from "./features/finalize.feature.js";
34
- import { PostmanFeature } from "./features/postman.feature.js";
35
- import { ApiPackageJson } from "./models/api-package-json.model.js";
36
- import { ControllerSourceFile } from "./models/controller-source-file.model.js";
37
- import { GithubCiWorkflows } from "./models/github-ci.model.js";
38
- import { MainSourceFile } from "./models/main-source-file.model.js";
39
- import { WebapiProductionDockerfile } from "./models/production-dockerfile.model.js";
40
- import { SampleConfigModel, SampleServiceModel } from "./models/sample-files.model.js";
41
- import { WebapiDevContainer } from "./models/webapi-image.model.js";
42
-
43
- export { WEBAPI_PROJECT_DIR, WEBAPI_RELEASE_ENTRY } from "./const.js";
44
-
45
- export type ApiOptions = {
46
- d?: string;
47
- /** Host project name (directory basename). Required when scaffolding into `/workspace`. */
48
- projectName?: string;
49
- /** API slugs under `projects/`. Default `["api"]`. Repeatable `--name`. */
50
- names?: string[];
51
- /** Add APIs to an existing Decohere workspace instead of creating a new one. */
52
- add?: boolean;
53
- authProvider?: "auth0" | "none";
54
- databaseProvider?: "none" | "postgres/typeorm";
55
- postmanProvider?: "api" | "local" | "none";
56
- installDependencies?: "yes" | "no";
57
- };
58
-
59
- const features = [DatabaseFeature, AuthFeature, PostmanFeature, FinalizeFeature];
60
-
61
- export async function scaffoldApi(cliOptions: ApiOptions) {
62
- const targetDir = resolve(cliOptions.d ?? ".");
63
- const projectName =
64
- cliOptions.projectName?.trim() ||
65
- process.env.DECOHERE_PROJECT_NAME?.trim() ||
66
- basename(targetDir);
67
- const names = parseApiNames(cliOptions.names);
68
- const workspace = cliOptions.add
69
- ? createAddWorkspace(targetDir, projectName, names)
70
- : createWorkspace(targetDir, projectName, names);
71
- await ScaffoldService.scaffold(workspace, { ...cliOptions, names }, features);
72
- }
73
-
74
- function createWorkspace(
75
- targetDir: string,
76
- projectName: string,
77
- apiNames: readonly string[],
78
- ): MonoRepoScaffold {
79
- const monoRepo = new MonoRepoScaffold();
80
- monoRepo.targetDir = targetDir;
81
- monoRepo.setName(projectName);
82
- const name = monoRepo.name;
83
-
84
- const compose = new DockerCompose()
85
- .setProjectName(name)
86
- .addHeaderComment(
87
- "Merge .cursor/mcp.json in the service command. postStartCommand runs after Cursor's first MCP snapshot.",
88
- )
89
- .addNetwork(name, { name: `samples-${name}` })
90
- .addService("devcontainer", {
91
- build: ".",
92
- volumes: [
93
- // Workspace-local (created by initialize.sh as the host user).
94
- // Do NOT bind ${HOME}/.npm/... — Docker creates missing host paths as root.
95
- "./npm-auth:/home/node/.npm-config",
96
- "./gh-auth:/home/node/.config/gh",
97
- "webapi-node-modules:/workspace/node_modules",
98
- // Named volume (not a Cursor-only mount) so CLI recreates keep Up-arrow history.
99
- `${commandHistory.volumeName}:${commandHistory.dir}`,
100
- ],
101
- env_file: ["./gh.env"],
102
- environment: { NPM_CONFIG_USERCONFIG: "/home/node/.npm-config/.npmrc" },
103
- command:
104
- "'bash -c \"CODEBASE_RAG_WORKSPACE=/workspace node --experimental-strip-types /workspace/.devcontainer/codebase-rag-mcp.ts merge || true && exec sleep infinity\"'",
105
- networks: [name],
106
- })
107
- .addVolume("webapi-node-modules")
108
- .addVolume(commandHistory.volumeName);
109
-
110
- const installCmd = "bash .devcontainer/post-create.sh";
111
- const devContainer = new DevContainer()
112
- .addExtension("biomejs.biome", "vitest.explorer")
113
- .setInitializeCommand("bash .devcontainer/initialize.sh")
114
- .setPostCreateCommand(installCmd)
115
- .setUpdateContentCommand(installCmd)
116
- .setPostStartCommand("bash .devcontainer/post-start.sh")
117
- .useCompose();
118
-
119
- for (const [index, apiName] of apiNames.entries()) {
120
- const port = webapiPort(index);
121
- devContainer.forwardPort(port);
122
- devContainer.setPortAttributes(port, {
123
- label: apiName === DEFAULT_WEBAPI_NAME ? "API" : apiName,
124
- requireLocalPort: true,
125
- });
126
- }
127
-
128
- // Workspace-level models (repo root)
129
- monoRepo.addModel(compose);
130
- monoRepo.addModel(devContainer);
131
- monoRepo.addModel(new WebapiDevContainer());
132
- monoRepo.addModel(new WebapiProductionDockerfile(apiNames));
133
- monoRepo.addModel(new GithubCiWorkflows());
134
- monoRepo.addModel(new VSCodeSettings(name));
135
- monoRepo.addModel(new LaunchJson(apiNames));
136
- monoRepo.addModel(new TsConfig());
137
- monoRepo.addModel(new VitestConfig());
138
- monoRepo.addModel(new PackageJson(`${name}.api`, { apiNames, workspaceName: name }));
139
- monoRepo.addModel(new ConfigYaml(WELL_KNOWN_FILES.CONFIG_YAML, "config/config.yaml", ""));
140
- monoRepo.addModel(
141
- new ConfigYaml(WELL_KNOWN_FILES.CONFIG_DEV_YAML, "config/config.dev.yaml", ""),
142
- );
143
- monoRepo.addModel(new Gitignore());
144
- monoRepo.addModel(new EnvFile());
145
- monoRepo.addFile(new DevContainerHostScripts());
146
-
147
- // Biome formatter/linter config
148
- monoRepo.addFile({
149
- files: () => [
150
- {
151
- filePath: "biome.json",
152
- content: JSON.stringify(
153
- {
154
- $schema: "https://biomejs.dev/schemas/2.0.0/schema.json",
155
- files: {
156
- includes: ["**/*.ts", "**/*.js", "**/*.json", "**/*.yml", "**/*.yaml"],
157
- },
158
- assist: { actions: { source: { organizeImports: "on" } } },
159
- vcs: { enabled: true, clientKind: "git", useIgnoreFile: true },
160
- formatter: {
161
- enabled: true,
162
- formatWithErrors: true,
163
- indentStyle: "tab",
164
- lineWidth: 95,
165
- },
166
- javascript: { parser: { unsafeParameterDecoratorsEnabled: true } },
167
- linter: {
168
- rules: {
169
- style: {
170
- useConsistentMemberAccessibility: {
171
- level: "error",
172
- options: { accessibility: "explicit" },
173
- },
174
- },
175
- },
176
- },
177
- overrides: [
178
- {
179
- includes: ["**/*.json"],
180
- formatter: { indentStyle: "space", indentWidth: 2 },
181
- },
182
- ],
183
- },
184
- null,
185
- 2,
186
- ),
187
- },
188
- ],
189
- });
190
-
191
- for (const apiName of apiNames) {
192
- addApiProject(monoRepo, name, apiName);
193
- }
194
-
195
- return monoRepo;
196
- }
197
-
198
- function createAddWorkspace(
199
- targetDir: string,
200
- projectName: string,
201
- apiNames: readonly string[],
202
- ): MonoRepoScaffold {
203
- if (!isDecohereWorkspace(targetDir)) {
204
- throw new CreateCliError(
205
- `Not a Decohere workspace: ${targetDir}. Scaffold one first with \`npx @decohere/create webapi\`.`,
206
- );
207
- }
208
-
209
- const existing = listExistingApiNames(targetDir);
210
- for (const apiName of apiNames) {
211
- if (existing.includes(apiName)) {
212
- throw new CreateCliError(
213
- `API "${apiName}" already exists at ${webapiProjectDir(apiName)}.`,
214
- );
215
- }
216
- }
217
-
218
- const monoRepo = new MonoRepoScaffold();
219
- monoRepo.targetDir = targetDir;
220
- monoRepo.setName(projectName);
221
- const name = monoRepo.name;
222
-
223
- const pkg = PackageJson.fromFile(join(targetDir, "package.json"));
224
- monoRepo.addModel(pkg);
225
- monoRepo.addModel(
226
- existsSync(join(targetDir, ".env"))
227
- ? EnvFile.fromFile(join(targetDir, ".env"))
228
- : new EnvFile(),
229
- );
230
- monoRepo.addModel(
231
- existsSync(join(targetDir, "config/config.yaml"))
232
- ? ConfigYaml.fromFile(
233
- WELL_KNOWN_FILES.CONFIG_YAML,
234
- "config/config.yaml",
235
- join(targetDir, "config/config.yaml"),
236
- )
237
- : new ConfigYaml(WELL_KNOWN_FILES.CONFIG_YAML, "config/config.yaml", ""),
238
- );
239
- monoRepo.addModel(
240
- existsSync(join(targetDir, "config/config.dev.yaml"))
241
- ? ConfigYaml.fromFile(
242
- WELL_KNOWN_FILES.CONFIG_DEV_YAML,
243
- "config/config.dev.yaml",
244
- join(targetDir, "config/config.dev.yaml"),
245
- )
246
- : new ConfigYaml(WELL_KNOWN_FILES.CONFIG_DEV_YAML, "config/config.dev.yaml", ""),
247
- );
248
-
249
- for (const [offset, apiName] of apiNames.entries()) {
250
- const port = webapiPort(existing.length + offset);
251
- pkg.addScript(`start:${apiName}`, `node ${webapiReleaseEntry(apiName)}`);
252
- pkg.addScript(
253
- `dev:${apiName}`,
254
- `PORT=${port} flux serve --project ${webapiPackageName(name, apiName)}`,
255
- );
256
- addApiProject(monoRepo, name, apiName);
257
- }
258
- monoRepo.addModel(new WebapiProductionDockerfile(apiNames, { namedOnly: true }));
259
-
260
- return monoRepo;
261
- }
262
-
263
- function addApiProject(
264
- monoRepo: MonoRepoScaffold,
265
- workspaceName: string,
266
- apiName: string,
267
- ): void {
268
- const apiProject = new ProjectScaffold(webapiProjectDir(apiName));
269
- apiProject.addModel(new ApiPackageJson(workspaceName, apiName));
270
- apiProject.addModel(new MainSourceFile(`${workspaceName}.${apiName}`));
271
- apiProject.addModel(new ControllerSourceFile());
272
- apiProject.addFile(new SampleConfigModel());
273
- apiProject.addFile(new SampleServiceModel());
274
- monoRepo.addProject(apiProject);
275
- }
@@ -1,35 +0,0 @@
1
- import { readFileSync } from "node:fs";
2
- import { fileURLToPath } from "node:url";
3
- import type { SourceFile, SourceFileProvider } from "../../models/source-file.js";
4
-
5
- const TEMPLATE_FILES = [
6
- "initialize.sh",
7
- "post-create.sh",
8
- "post-start.sh",
9
- "tty-prompt.sh",
10
- "codebase-rag.env.example",
11
- ] as const;
12
-
13
- export function devcontainerTemplatePath(name: string): string {
14
- return fileURLToPath(new URL(`./templates/${name}`, import.meta.url));
15
- }
16
-
17
- export function codebaseRagMcpSourcePath(): string {
18
- return fileURLToPath(new URL("./codebase-rag-mcp.ts", import.meta.url));
19
- }
20
-
21
- /** Host + container scripts for the scaffolded Dev Container. */
22
- export class DevContainerHostScripts implements SourceFileProvider {
23
- public files(): SourceFile[] {
24
- return [
25
- ...TEMPLATE_FILES.map((name) => ({
26
- filePath: `.devcontainer/${name}`,
27
- content: readFileSync(devcontainerTemplatePath(name), "utf8"),
28
- })),
29
- {
30
- filePath: ".devcontainer/codebase-rag-mcp.ts",
31
- content: readFileSync(codebaseRagMcpSourcePath(), "utf8"),
32
- },
33
- ];
34
- }
35
- }