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

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 +157 -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 +275 -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 +142 -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 +255 -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
@@ -0,0 +1,132 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: Object.getOwnPropertyDescriptor(all, name).get
9
+ });
10
+ }
11
+ _export(exports, {
12
+ get MonoRepoScaffold () {
13
+ return MonoRepoScaffold;
14
+ },
15
+ get ProjectScaffold () {
16
+ return ProjectScaffold;
17
+ },
18
+ get WorkspaceScaffold () {
19
+ return WorkspaceScaffold;
20
+ }
21
+ });
22
+ const _promises = require("node:fs/promises");
23
+ const _nodepath = require("node:path");
24
+ class ProjectScaffold {
25
+ dir;
26
+ _models = new Map();
27
+ _files = [];
28
+ constructor(dir){
29
+ this.dir = dir;
30
+ }
31
+ addModel(model) {
32
+ this._models.set(model.key, model);
33
+ return model;
34
+ }
35
+ addFile(provider) {
36
+ this._files.push(...provider.files());
37
+ return this;
38
+ }
39
+ getModel(key) {
40
+ return this._models.get(key);
41
+ }
42
+ getModels(ctor) {
43
+ return [
44
+ ...this._models.values()
45
+ ].filter((m)=>m instanceof ctor);
46
+ }
47
+ /** Returns all files with `dir/` prepended to each path. */ files() {
48
+ const all = [
49
+ ...this._files,
50
+ ...[
51
+ ...this._models.values()
52
+ ].flatMap((m)=>m.files())
53
+ ];
54
+ return all.map((f)=>({
55
+ filePath: `${this.dir}/${f.filePath}`,
56
+ content: f.content
57
+ }));
58
+ }
59
+ }
60
+ class WorkspaceScaffold {
61
+ files = [];
62
+ targetDir = process.cwd();
63
+ _name;
64
+ /** Project name — host directory basename, not the in-container mount path. */ get name() {
65
+ return this._name ?? (0, _nodepath.basename)(this.targetDir);
66
+ }
67
+ setName(name) {
68
+ this._name = name;
69
+ return this;
70
+ }
71
+ /** Add an ad-hoc file provider whose output is included at render time. */ addFile(provider) {
72
+ this.files.push(...provider.files());
73
+ return this;
74
+ }
75
+ }
76
+ class MonoRepoScaffold extends WorkspaceScaffold {
77
+ _models = new Map();
78
+ _projects = [];
79
+ /** Register a named project. */ addProject(project) {
80
+ this._projects.push(project);
81
+ return project;
82
+ }
83
+ /** Retrieve a previously-registered project by its directory path. */ getProject(dir) {
84
+ return this._projects.find((p)=>p.dir === dir);
85
+ }
86
+ /** All registered projects, in registration order. */ getProjects() {
87
+ return this._projects;
88
+ }
89
+ /** Register a named model at workspace level. */ addModel(model) {
90
+ this._models.set(model.key, model);
91
+ return model;
92
+ }
93
+ /**
94
+ * Retrieve a model by key. Searches workspace models first, then all
95
+ * registered projects in order.
96
+ */ getModel(key) {
97
+ const m = this._models.get(key);
98
+ if (m !== undefined) return m;
99
+ for (const project of this._projects){
100
+ const pm = project.getModel(key);
101
+ if (pm !== undefined) return pm;
102
+ }
103
+ return undefined;
104
+ }
105
+ /**
106
+ * Retrieve all models of a given type. Searches workspace models and all
107
+ * projects, so features can discover controllers across multiple projects.
108
+ */ getModels(ctor) {
109
+ return [
110
+ ...[
111
+ ...this._models.values()
112
+ ].filter((m)=>m instanceof ctor),
113
+ ...this._projects.flatMap((p)=>p.getModels(ctor))
114
+ ];
115
+ }
116
+ /** Render all models and projects into files, then write everything to disk. */ async scaffold() {
117
+ const allFiles = [
118
+ ...this.files,
119
+ ...[
120
+ ...this._models.values()
121
+ ].flatMap((m)=>m.files()),
122
+ ...this._projects.flatMap((p)=>p.files())
123
+ ];
124
+ await Promise.all(allFiles.map(async (file)=>{
125
+ const fullPath = (0, _nodepath.join)(this.targetDir, file.filePath);
126
+ await (0, _promises.mkdir)((0, _nodepath.dirname)(fullPath), {
127
+ recursive: true
128
+ });
129
+ await (0, _promises.writeFile)(fullPath, file.content);
130
+ }));
131
+ }
132
+ }
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "TsConfig", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return TsConfig;
9
+ }
10
+ });
11
+ const _const = require("./const.js");
12
+ class TsConfig {
13
+ key = _const.WELL_KNOWN_FILES.TSCONFIG;
14
+ files() {
15
+ return [
16
+ {
17
+ filePath: "tsconfig.json",
18
+ content: JSON.stringify({
19
+ compilerOptions: {
20
+ target: "ES2022",
21
+ module: "NodeNext",
22
+ moduleResolution: "NodeNext",
23
+ strict: true,
24
+ skipLibCheck: true,
25
+ experimentalDecorators: true,
26
+ emitDecoratorMetadata: true
27
+ }
28
+ }, null, 2)
29
+ }
30
+ ];
31
+ }
32
+ }
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "VitestConfig", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return VitestConfig;
9
+ }
10
+ });
11
+ const _const = require("./const.js");
12
+ class VitestConfig {
13
+ key = _const.WELL_KNOWN_FILES.VITEST_CONFIG;
14
+ files() {
15
+ return [
16
+ {
17
+ filePath: "vitest.config.ts",
18
+ content: [
19
+ 'import { forgeBuild } from "@decohere/forge/vitest";',
20
+ 'import { defineConfig } from "vitest/config";',
21
+ "",
22
+ "export default defineConfig({",
23
+ '\tplugins: [forgeBuild({ logLevel: "silent" })],',
24
+ "\ttest: {",
25
+ '\t\tinclude: ["projects/**/*.{test,spec}.?(c|m)[jt]s?(x)"],',
26
+ "\t},",
27
+ "});",
28
+ ""
29
+ ].join("\n")
30
+ }
31
+ ];
32
+ }
33
+ }
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "VSCodeSettings", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return VSCodeSettings;
9
+ }
10
+ });
11
+ const _const = require("./const.js");
12
+ class VSCodeSettings {
13
+ title;
14
+ key = _const.WELL_KNOWN_FILES.VSCODE_SETTINGS;
15
+ constructor(title){
16
+ this.title = title;
17
+ }
18
+ files() {
19
+ return [
20
+ {
21
+ filePath: ".vscode/settings.json",
22
+ content: JSON.stringify({
23
+ "window.title": `${this.title}\${separator}\${activeEditorShort}`,
24
+ "window.titleSeparator": " | "
25
+ }, null, 2)
26
+ }
27
+ ];
28
+ }
29
+ }
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: Object.getOwnPropertyDescriptor(all, name).get
9
+ });
10
+ }
11
+ _export(exports, {
12
+ get createProgram () {
13
+ return createProgram;
14
+ },
15
+ get runCli () {
16
+ return runCli;
17
+ }
18
+ });
19
+ const _commander = require("commander");
20
+ const _apiname = require("./webapi/api-name.js");
21
+ const _auth0commands = require("./webapi/auth0-commands.js");
22
+ const _clioptions = require("./webapi/cli-options.js");
23
+ function createProgram() {
24
+ const program = new _commander.Command();
25
+ program.exitOverride();
26
+ program.name("decohere").description("Decohere CLI").option("-d <directory>", "Target directory (default: current directory)", ".");
27
+ const create = program.command("create").description("Create a new Decohere workspace");
28
+ (0, _clioptions.addWebapiFeatureOptions)(create.command("webapi").argument("[directory]", "Target directory (default: -d or current directory)").option("--name <slug>", "API name under projects/ (repeatable; default: api)", _clioptions.collectName, [])).action(async (directory, _opts, cmd)=>{
29
+ await (0, _clioptions.runScaffoldApi)((0, _clioptions.toApiOptions)(directory, cmd.optsWithGlobals()));
30
+ });
31
+ (0, _clioptions.addWebapiFeatureOptions)(program.command("add").description("Add to an existing Decohere workspace").command("api").argument("<name>", "API name under projects/")).action(async (name, _opts, cmd)=>{
32
+ await (0, _clioptions.runScaffoldApi)((0, _clioptions.toApiOptions)(undefined, cmd.optsWithGlobals(), {
33
+ names: [
34
+ name
35
+ ],
36
+ add: true
37
+ }));
38
+ });
39
+ const auth0 = program.command("auth0").description("Log in to Auth0 and update a scaffolded client");
40
+ auth0.command("login").description("Authenticate the Auth0 CLI (device URL; tokens persist on the host)").action(()=>{
41
+ (0, _auth0commands.runAuth0Login)();
42
+ });
43
+ auth0.command("configure").description("Update Auth0 API permissions and Postman SPA from @Authorize in this workspace").action((_opts, cmd)=>{
44
+ const d = cmd.optsWithGlobals().d;
45
+ (0, _auth0commands.runAuth0Configure)(typeof d === "string" ? d : ".");
46
+ });
47
+ return program;
48
+ }
49
+ async function runCli(argv = process.argv) {
50
+ try {
51
+ await createProgram().parseAsync(argv);
52
+ } catch (err) {
53
+ if (err instanceof _commander.CommanderError) {
54
+ return err.exitCode;
55
+ }
56
+ if (err instanceof _apiname.CreateCliError) {
57
+ console.error(`\n ${err.message}\n`);
58
+ return 1;
59
+ }
60
+ console.error(err);
61
+ return 1;
62
+ }
63
+ return typeof process.exitCode === "number" ? process.exitCode : 0;
64
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Resolve scaffold destination: positional `webapi my-app` wins over `-d`.
3
+ * `npm create … webapi -d my-app` drops `-d` (npm loglevel) and forwards `my-app`.
4
+ */ "use strict";
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ Object.defineProperty(exports, "resolveTargetDir", {
9
+ enumerable: true,
10
+ get: function() {
11
+ return resolveTargetDir;
12
+ }
13
+ });
14
+ function resolveTargetDir(positional, flag) {
15
+ const dir = positional?.trim() || flag?.trim() || ".";
16
+ return dir;
17
+ }
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "ScaffoldService", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return ScaffoldService;
9
+ }
10
+ });
11
+ async function scaffold(workspace, cliOptions, features) {
12
+ const options = await getAllOptions(workspace, cliOptions, features);
13
+ // Features mutate workspace models first, then workspace renders to disk.
14
+ await scaffoldFeatures(workspace, options, features);
15
+ await scaffoldWorkspace(workspace, options);
16
+ // Post-write phase: install deps, print final messages, etc.
17
+ await finalizeFeatures(workspace, options, features);
18
+ }
19
+ async function scaffoldWorkspace(workspace, _options) {
20
+ await workspace.scaffold();
21
+ }
22
+ /**
23
+ * Iterate features in order, calling `getOptions` on each.
24
+ * Each feature receives the running merged options so later features can
25
+ * branch on decisions made by earlier ones (e.g. database choice affects auth).
26
+ * Results are shallow-merged, so features only need to return what they own.
27
+ */ async function getAllOptions(workspace, cliOptions, features) {
28
+ let options = {
29
+ ...cliOptions
30
+ };
31
+ for (const feature of features){
32
+ const featureOptions = await feature.getOptions(workspace, options);
33
+ options = {
34
+ ...options,
35
+ ...featureOptions
36
+ };
37
+ }
38
+ return options;
39
+ }
40
+ /**
41
+ * Iterate features in order, calling `scaffold` with the fully-resolved options.
42
+ * All option-gathering is complete before any scaffolding begins.
43
+ */ async function scaffoldFeatures(workspace, options, features) {
44
+ for (const feature of features){
45
+ await feature.scaffold(workspace, options);
46
+ }
47
+ }
48
+ /**
49
+ * Iterate features in order, calling `finalize` on each (if defined).
50
+ * All files are on disk by this point.
51
+ */ async function finalizeFeatures(workspace, options, features) {
52
+ for (const feature of features){
53
+ if (feature.finalize) {
54
+ await feature.finalize(workspace, options);
55
+ }
56
+ }
57
+ }
58
+ const ScaffoldService = {
59
+ scaffold
60
+ };
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: Object.getOwnPropertyDescriptor(all, name).get
9
+ });
10
+ }
11
+ _export(exports, {
12
+ get CREATE_IMAGE_REPOSITORY () {
13
+ return CREATE_IMAGE_REPOSITORY;
14
+ },
15
+ get CREATE_VERSION () {
16
+ return CREATE_VERSION;
17
+ },
18
+ get DEVCONTAINER_IMAGE_REPOSITORY () {
19
+ return DEVCONTAINER_IMAGE_REPOSITORY;
20
+ }
21
+ });
22
+ const _nodemodule = require("node:module");
23
+ const _nodepath = require("node:path");
24
+ const _nodeurl = require("node:url");
25
+ const _require = (0, _nodemodule.createRequire)(require("url").pathToFileURL(__filename).toString());
26
+ const DEFAULT_CREATE_VERSION = "0.0.1-dev";
27
+ const DEFAULT_CREATE_IMAGE_REPOSITORY = "ghcr.io/typesmiths/decohere/create";
28
+ const DEFAULT_DEVCONTAINER_IMAGE_REPOSITORY = "ghcr.io/typesmiths/decohere/devcontainer";
29
+ function resolveCreateMetadata() {
30
+ let dir = (0, _nodepath.dirname)((0, _nodeurl.fileURLToPath)(require("url").pathToFileURL(__filename).toString()));
31
+ for(let i = 0; i < 5; i++){
32
+ try {
33
+ const pkg = _require((0, _nodepath.join)(dir, "package.json"));
34
+ if (pkg.name === "@decohere/scaffold") {
35
+ return {
36
+ version: pkg.version ?? DEFAULT_CREATE_VERSION,
37
+ imageRepository: pkg.decohere?.dockerImageRepository ?? DEFAULT_CREATE_IMAGE_REPOSITORY,
38
+ devcontainerImageRepository: pkg.decohere?.devcontainerImageRepository ?? DEFAULT_DEVCONTAINER_IMAGE_REPOSITORY
39
+ };
40
+ }
41
+ } catch {}
42
+ const parent = (0, _nodepath.dirname)(dir);
43
+ if (parent === dir) break;
44
+ dir = parent;
45
+ }
46
+ return {
47
+ version: DEFAULT_CREATE_VERSION,
48
+ imageRepository: DEFAULT_CREATE_IMAGE_REPOSITORY,
49
+ devcontainerImageRepository: DEFAULT_DEVCONTAINER_IMAGE_REPOSITORY
50
+ };
51
+ }
52
+ const createMetadata = resolveCreateMetadata();
53
+ const CREATE_VERSION = createMetadata.version;
54
+ const CREATE_IMAGE_REPOSITORY = createMetadata.imageRepository;
55
+ const DEVCONTAINER_IMAGE_REPOSITORY = createMetadata.devcontainerImageRepository;
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: Object.getOwnPropertyDescriptor(all, name).get
9
+ });
10
+ }
11
+ _export(exports, {
12
+ get API_NAME_PATTERN () {
13
+ return API_NAME_PATTERN;
14
+ },
15
+ get CreateCliError () {
16
+ return CreateCliError;
17
+ },
18
+ get apiEnvPrefix () {
19
+ return apiEnvPrefix;
20
+ },
21
+ get apiNameFromProjectDir () {
22
+ return apiNameFromProjectDir;
23
+ },
24
+ get assertValidApiName () {
25
+ return assertValidApiName;
26
+ },
27
+ get isDecohereWorkspace () {
28
+ return isDecohereWorkspace;
29
+ },
30
+ get listExistingApiNames () {
31
+ return listExistingApiNames;
32
+ },
33
+ get parseApiNames () {
34
+ return parseApiNames;
35
+ }
36
+ });
37
+ const _nodefs = require("node:fs");
38
+ const _nodepath = require("node:path");
39
+ const _const = require("./const.js");
40
+ const API_NAME_PATTERN = /^[a-z][a-z0-9-]*$/;
41
+ class CreateCliError extends Error {
42
+ constructor(message){
43
+ super(message);
44
+ this.name = "CreateCliError";
45
+ }
46
+ }
47
+ function assertValidApiName(name) {
48
+ if (!API_NAME_PATTERN.test(name)) {
49
+ throw new CreateCliError(`Invalid API name "${name}". Use a lowercase slug starting with a letter, then letters, digits, or hyphens (e.g. billing).`);
50
+ }
51
+ }
52
+ function parseApiNames(raw) {
53
+ const names = raw != null && raw.length > 0 ? [
54
+ ...raw
55
+ ] : [
56
+ _const.DEFAULT_WEBAPI_NAME
57
+ ];
58
+ const seen = new Set();
59
+ for (const name of names){
60
+ assertValidApiName(name);
61
+ if (seen.has(name)) {
62
+ throw new CreateCliError(`Duplicate API name "${name}".`);
63
+ }
64
+ seen.add(name);
65
+ }
66
+ return names;
67
+ }
68
+ function isDecohereWorkspace(dir) {
69
+ try {
70
+ const pkg = JSON.parse((0, _nodefs.readFileSync)((0, _nodepath.join)(dir, "package.json"), "utf8"));
71
+ const build = pkg.scripts?.build;
72
+ return typeof build === "string" && build.includes("forge");
73
+ } catch {
74
+ return false;
75
+ }
76
+ }
77
+ function listExistingApiNames(dir) {
78
+ const projectsDir = (0, _nodepath.join)(dir, "projects");
79
+ try {
80
+ return (0, _nodefs.readdirSync)(projectsDir, {
81
+ withFileTypes: true
82
+ }).filter((entry)=>entry.isDirectory() && (0, _nodefs.existsSync)((0, _nodepath.join)(projectsDir, entry.name, "package.json"))).map((entry)=>entry.name).sort();
83
+ } catch {
84
+ return [];
85
+ }
86
+ }
87
+ function apiEnvPrefix(apiName) {
88
+ return apiName.replace(/-/g, "_").toUpperCase();
89
+ }
90
+ function apiNameFromProjectDir(dir) {
91
+ const slash = dir.lastIndexOf("/");
92
+ return slash >= 0 ? dir.slice(slash + 1) : dir;
93
+ }