@qpqjs/cli 0.0.0-stage → 0.2.0

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 (549) hide show
  1. package/README.md +92 -2
  2. package/docker/cdk-deployer/Dockerfile +13 -0
  3. package/docker/dev-server/Dockerfile +47 -0
  4. package/lib/commonjs/bin/qpq.d.ts +2 -0
  5. package/lib/commonjs/bin/qpq.js +6 -0
  6. package/lib/commonjs/bin/qpq.js.map +1 -0
  7. package/lib/commonjs/bin/qpqCdkApp.d.ts +1 -0
  8. package/lib/commonjs/bin/qpqCdkApp.js +8 -0
  9. package/lib/commonjs/bin/qpqCdkApp.js.map +1 -0
  10. package/lib/commonjs/cli/commandMenu.d.ts +2 -0
  11. package/lib/commonjs/cli/commandMenu.js +81 -0
  12. package/lib/commonjs/cli/commandMenu.js.map +1 -0
  13. package/lib/commonjs/cli/commandRegistry.d.ts +10 -0
  14. package/lib/commonjs/cli/commandRegistry.js +177 -0
  15. package/lib/commonjs/cli/commandRegistry.js.map +1 -0
  16. package/lib/commonjs/cli/index.d.ts +1 -0
  17. package/lib/commonjs/cli/index.js +18 -0
  18. package/lib/commonjs/cli/index.js.map +1 -0
  19. package/lib/commonjs/cli/runCli.d.ts +1 -0
  20. package/lib/commonjs/cli/runCli.js +86 -0
  21. package/lib/commonjs/cli/runCli.js.map +1 -0
  22. package/lib/commonjs/commands/checkCircular.d.ts +1 -0
  23. package/lib/commonjs/commands/checkCircular.js +70 -0
  24. package/lib/commonjs/commands/checkCircular.js.map +1 -0
  25. package/lib/commonjs/commands/clearResources.d.ts +1 -0
  26. package/lib/commonjs/commands/clearResources.js +36 -0
  27. package/lib/commonjs/commands/clearResources.js.map +1 -0
  28. package/lib/commonjs/commands/go.d.ts +1 -0
  29. package/lib/commonjs/commands/go.js +30 -0
  30. package/lib/commonjs/commands/go.js.map +1 -0
  31. package/lib/commonjs/commands/goDev.d.ts +1 -0
  32. package/lib/commonjs/commands/goDev.js +46 -0
  33. package/lib/commonjs/commands/goDev.js.map +1 -0
  34. package/lib/commonjs/commands/goDevApi.d.ts +1 -0
  35. package/lib/commonjs/commands/goDevApi.js +158 -0
  36. package/lib/commonjs/commands/goDevApi.js.map +1 -0
  37. package/lib/commonjs/commands/goDevWeb.d.ts +4 -0
  38. package/lib/commonjs/commands/goDevWeb.js +144 -0
  39. package/lib/commonjs/commands/goDevWeb.js.map +1 -0
  40. package/lib/commonjs/commands/goDocker.d.ts +1 -0
  41. package/lib/commonjs/commands/goDocker.js +43 -0
  42. package/lib/commonjs/commands/goDocker.js.map +1 -0
  43. package/lib/commonjs/commands/hooks.d.ts +1 -0
  44. package/lib/commonjs/commands/hooks.js +39 -0
  45. package/lib/commonjs/commands/hooks.js.map +1 -0
  46. package/lib/commonjs/commands/migrate.d.ts +1 -0
  47. package/lib/commonjs/commands/migrate.js +70 -0
  48. package/lib/commonjs/commands/migrate.js.map +1 -0
  49. package/lib/commonjs/commands/prep.d.ts +1 -0
  50. package/lib/commonjs/commands/prep.js +28 -0
  51. package/lib/commonjs/commands/prep.js.map +1 -0
  52. package/lib/commonjs/commands/publish.d.ts +4 -0
  53. package/lib/commonjs/commands/publish.js +54 -0
  54. package/lib/commonjs/commands/publish.js.map +1 -0
  55. package/lib/commonjs/commands/scriptBuild.d.ts +1 -0
  56. package/lib/commonjs/commands/scriptBuild.js +46 -0
  57. package/lib/commonjs/commands/scriptBuild.js.map +1 -0
  58. package/lib/commonjs/commands/scriptBuilderLayer.d.ts +1 -0
  59. package/lib/commonjs/commands/scriptBuilderLayer.js +48 -0
  60. package/lib/commonjs/commands/scriptBuilderLayer.js.map +1 -0
  61. package/lib/commonjs/commands/scriptNew.d.ts +1 -0
  62. package/lib/commonjs/commands/scriptNew.js +35 -0
  63. package/lib/commonjs/commands/scriptNew.js.map +1 -0
  64. package/lib/commonjs/commands/setup.d.ts +1 -0
  65. package/lib/commonjs/commands/setup.js +102 -0
  66. package/lib/commonjs/commands/setup.js.map +1 -0
  67. package/lib/commonjs/commands/synth.d.ts +1 -0
  68. package/lib/commonjs/commands/synth.js +89 -0
  69. package/lib/commonjs/commands/synth.js.map +1 -0
  70. package/lib/commonjs/commands/teardown.d.ts +1 -0
  71. package/lib/commonjs/commands/teardown.js +33 -0
  72. package/lib/commonjs/commands/teardown.js.map +1 -0
  73. package/lib/commonjs/index.d.ts +1 -0
  74. package/lib/commonjs/index.js +18 -0
  75. package/lib/commonjs/index.js.map +1 -0
  76. package/lib/commonjs/lib/args.d.ts +3 -0
  77. package/lib/commonjs/lib/args.js +31 -0
  78. package/lib/commonjs/lib/args.js.map +1 -0
  79. package/lib/commonjs/lib/circularImports.d.ts +3 -0
  80. package/lib/commonjs/lib/circularImports.js +79 -0
  81. package/lib/commonjs/lib/circularImports.js.map +1 -0
  82. package/lib/commonjs/lib/clearResourcesPlan.d.ts +15 -0
  83. package/lib/commonjs/lib/clearResourcesPlan.js +79 -0
  84. package/lib/commonjs/lib/clearResourcesPlan.js.map +1 -0
  85. package/lib/commonjs/lib/deployPrompts.d.ts +26 -0
  86. package/lib/commonjs/lib/deployPrompts.js +118 -0
  87. package/lib/commonjs/lib/deployPrompts.js.map +1 -0
  88. package/lib/commonjs/lib/devServerEntry.d.ts +22 -0
  89. package/lib/commonjs/lib/devServerEntry.js +135 -0
  90. package/lib/commonjs/lib/devServerEntry.js.map +1 -0
  91. package/lib/commonjs/lib/devServerPorts.d.ts +13 -0
  92. package/lib/commonjs/lib/devServerPorts.js +36 -0
  93. package/lib/commonjs/lib/devServerPorts.js.map +1 -0
  94. package/lib/commonjs/lib/discovery.d.ts +10 -0
  95. package/lib/commonjs/lib/discovery.js +56 -0
  96. package/lib/commonjs/lib/discovery.js.map +1 -0
  97. package/lib/commonjs/lib/getDefaultHookJobs.d.ts +2 -0
  98. package/lib/commonjs/lib/getDefaultHookJobs.js +11 -0
  99. package/lib/commonjs/lib/getDefaultHookJobs.js.map +1 -0
  100. package/lib/commonjs/lib/getDeployTargetLabel.d.ts +2 -0
  101. package/lib/commonjs/lib/getDeployTargetLabel.js +12 -0
  102. package/lib/commonjs/lib/getDeployTargetLabel.js.map +1 -0
  103. package/lib/commonjs/lib/goDockerMode.d.ts +6 -0
  104. package/lib/commonjs/lib/goDockerMode.js +23 -0
  105. package/lib/commonjs/lib/goDockerMode.js.map +1 -0
  106. package/lib/commonjs/lib/hooks.d.ts +9 -0
  107. package/lib/commonjs/lib/hooks.js +178 -0
  108. package/lib/commonjs/lib/hooks.js.map +1 -0
  109. package/lib/commonjs/lib/keepOtherDevServersFlag.d.ts +1 -0
  110. package/lib/commonjs/lib/keepOtherDevServersFlag.js +11 -0
  111. package/lib/commonjs/lib/keepOtherDevServersFlag.js.map +1 -0
  112. package/lib/commonjs/lib/killChildWithEscalation.d.ts +10 -0
  113. package/lib/commonjs/lib/killChildWithEscalation.js +33 -0
  114. package/lib/commonjs/lib/killChildWithEscalation.js.map +1 -0
  115. package/lib/commonjs/lib/killStaleListeners.d.ts +17 -0
  116. package/lib/commonjs/lib/killStaleListeners.js +220 -0
  117. package/lib/commonjs/lib/killStaleListeners.js.map +1 -0
  118. package/lib/commonjs/lib/packageRoot.d.ts +1 -0
  119. package/lib/commonjs/lib/packageRoot.js +21 -0
  120. package/lib/commonjs/lib/packageRoot.js.map +1 -0
  121. package/lib/commonjs/lib/prompts.d.ts +15 -0
  122. package/lib/commonjs/lib/prompts.js +78 -0
  123. package/lib/commonjs/lib/prompts.js.map +1 -0
  124. package/lib/commonjs/lib/qpqConfigs.d.ts +4 -0
  125. package/lib/commonjs/lib/qpqConfigs.js +27 -0
  126. package/lib/commonjs/lib/qpqConfigs.js.map +1 -0
  127. package/lib/commonjs/lib/resolveAppSelection.d.ts +6 -0
  128. package/lib/commonjs/lib/resolveAppSelection.js +58 -0
  129. package/lib/commonjs/lib/resolveAppSelection.js.map +1 -0
  130. package/lib/commonjs/lib/resolveDeployment.d.ts +14 -0
  131. package/lib/commonjs/lib/resolveDeployment.js +58 -0
  132. package/lib/commonjs/lib/resolveDeployment.js.map +1 -0
  133. package/lib/commonjs/lib/runCommand.d.ts +14 -0
  134. package/lib/commonjs/lib/runCommand.js +103 -0
  135. package/lib/commonjs/lib/runCommand.js.map +1 -0
  136. package/lib/commonjs/lib/runTasks.d.ts +15 -0
  137. package/lib/commonjs/lib/runTasks.js +123 -0
  138. package/lib/commonjs/lib/runTasks.js.map +1 -0
  139. package/lib/commonjs/lib/setupStep.d.ts +16 -0
  140. package/lib/commonjs/lib/setupStep.js +3 -0
  141. package/lib/commonjs/lib/setupStep.js.map +1 -0
  142. package/lib/commonjs/lib/timing.d.ts +2 -0
  143. package/lib/commonjs/lib/timing.js +11 -0
  144. package/lib/commonjs/lib/timing.js.map +1 -0
  145. package/lib/commonjs/lib/typeWatcher.d.ts +2 -0
  146. package/lib/commonjs/lib/typeWatcher.js +59 -0
  147. package/lib/commonjs/lib/typeWatcher.js.map +1 -0
  148. package/lib/commonjs/lib/userScriptBuilderLayer.d.ts +23 -0
  149. package/lib/commonjs/lib/userScriptBuilderLayer.js +74 -0
  150. package/lib/commonjs/lib/userScriptBuilderLayer.js.map +1 -0
  151. package/lib/commonjs/lib/userScriptTemplate.d.ts +6 -0
  152. package/lib/commonjs/lib/userScriptTemplate.js +47 -0
  153. package/lib/commonjs/lib/userScriptTemplate.js.map +1 -0
  154. package/lib/commonjs/lib/views.d.ts +2 -0
  155. package/lib/commonjs/lib/views.js +31 -0
  156. package/lib/commonjs/lib/views.js.map +1 -0
  157. package/lib/commonjs/lib/webAddressingEnv.d.ts +7 -0
  158. package/lib/commonjs/lib/webAddressingEnv.js +16 -0
  159. package/lib/commonjs/lib/webAddressingEnv.js.map +1 -0
  160. package/lib/commonjs/platforms/aws/awsCredentials.d.ts +1 -0
  161. package/lib/commonjs/platforms/aws/awsCredentials.js +28 -0
  162. package/lib/commonjs/platforms/aws/awsCredentials.js.map +1 -0
  163. package/lib/commonjs/platforms/aws/cdkApp.d.ts +3 -0
  164. package/lib/commonjs/platforms/aws/cdkApp.js +31 -0
  165. package/lib/commonjs/platforms/aws/cdkApp.js.map +1 -0
  166. package/lib/commonjs/platforms/aws/clearResources.d.ts +2 -0
  167. package/lib/commonjs/platforms/aws/clearResources.js +167 -0
  168. package/lib/commonjs/platforms/aws/clearResources.js.map +1 -0
  169. package/lib/commonjs/platforms/aws/go.d.ts +2 -0
  170. package/lib/commonjs/platforms/aws/go.js +131 -0
  171. package/lib/commonjs/platforms/aws/go.js.map +1 -0
  172. package/lib/commonjs/platforms/aws/goDocker.d.ts +3 -0
  173. package/lib/commonjs/platforms/aws/goDocker.js +457 -0
  174. package/lib/commonjs/platforms/aws/goDocker.js.map +1 -0
  175. package/lib/commonjs/platforms/aws/goDockerManifest.d.ts +44 -0
  176. package/lib/commonjs/platforms/aws/goDockerManifest.js +38 -0
  177. package/lib/commonjs/platforms/aws/goDockerManifest.js.map +1 -0
  178. package/lib/commonjs/platforms/aws/index.d.ts +2 -0
  179. package/lib/commonjs/platforms/aws/index.js +23 -0
  180. package/lib/commonjs/platforms/aws/index.js.map +1 -0
  181. package/lib/commonjs/platforms/aws/prepareDeployment.d.ts +3 -0
  182. package/lib/commonjs/platforms/aws/prepareDeployment.js +10 -0
  183. package/lib/commonjs/platforms/aws/prepareDeployment.js.map +1 -0
  184. package/lib/commonjs/platforms/aws/publish.d.ts +4 -0
  185. package/lib/commonjs/platforms/aws/publish.js +66 -0
  186. package/lib/commonjs/platforms/aws/publish.js.map +1 -0
  187. package/lib/commonjs/platforms/aws/remote.d.ts +11 -0
  188. package/lib/commonjs/platforms/aws/remote.js +105 -0
  189. package/lib/commonjs/platforms/aws/remote.js.map +1 -0
  190. package/lib/commonjs/platforms/aws/setup/awsSetupContext.d.ts +12 -0
  191. package/lib/commonjs/platforms/aws/setup/awsSetupContext.js +20 -0
  192. package/lib/commonjs/platforms/aws/setup/awsSetupContext.js.map +1 -0
  193. package/lib/commonjs/platforms/aws/setup/awsSetupSteps.d.ts +8 -0
  194. package/lib/commonjs/platforms/aws/setup/awsSetupSteps.js +44 -0
  195. package/lib/commonjs/platforms/aws/setup/awsSetupSteps.js.map +1 -0
  196. package/lib/commonjs/platforms/aws/setup/buildBucketNamesStep.d.ts +4 -0
  197. package/lib/commonjs/platforms/aws/setup/buildBucketNamesStep.js +77 -0
  198. package/lib/commonjs/platforms/aws/setup/buildBucketNamesStep.js.map +1 -0
  199. package/lib/commonjs/platforms/aws/setup/buildCdkBootstrapSteps.d.ts +5 -0
  200. package/lib/commonjs/platforms/aws/setup/buildCdkBootstrapSteps.js +38 -0
  201. package/lib/commonjs/platforms/aws/setup/buildCdkBootstrapSteps.js.map +1 -0
  202. package/lib/commonjs/platforms/aws/setup/buildGithubDeployRoleStep.d.ts +4 -0
  203. package/lib/commonjs/platforms/aws/setup/buildGithubDeployRoleStep.js +55 -0
  204. package/lib/commonjs/platforms/aws/setup/buildGithubDeployRoleStep.js.map +1 -0
  205. package/lib/commonjs/platforms/aws/setup/buildGithubOidcProviderStep.d.ts +4 -0
  206. package/lib/commonjs/platforms/aws/setup/buildGithubOidcProviderStep.js +54 -0
  207. package/lib/commonjs/platforms/aws/setup/buildGithubOidcProviderStep.js.map +1 -0
  208. package/lib/commonjs/platforms/aws/setup/buildHostedZonesStep.d.ts +4 -0
  209. package/lib/commonjs/platforms/aws/setup/buildHostedZonesStep.js +63 -0
  210. package/lib/commonjs/platforms/aws/setup/buildHostedZonesStep.js.map +1 -0
  211. package/lib/commonjs/platforms/aws/setup/buildIamCapabilityStep.d.ts +4 -0
  212. package/lib/commonjs/platforms/aws/setup/buildIamCapabilityStep.js +48 -0
  213. package/lib/commonjs/platforms/aws/setup/buildIamCapabilityStep.js.map +1 -0
  214. package/lib/commonjs/platforms/aws/setup/buildIdentityStep.d.ts +4 -0
  215. package/lib/commonjs/platforms/aws/setup/buildIdentityStep.js +39 -0
  216. package/lib/commonjs/platforms/aws/setup/buildIdentityStep.js.map +1 -0
  217. package/lib/commonjs/platforms/aws/setup/buildStackSteps.d.ts +5 -0
  218. package/lib/commonjs/platforms/aws/setup/buildStackSteps.js +32 -0
  219. package/lib/commonjs/platforms/aws/setup/buildStackSteps.js.map +1 -0
  220. package/lib/commonjs/platforms/aws/setup/describeStackStatus.d.ts +4 -0
  221. package/lib/commonjs/platforms/aws/setup/describeStackStatus.js +32 -0
  222. package/lib/commonjs/platforms/aws/setup/describeStackStatus.js.map +1 -0
  223. package/lib/commonjs/platforms/aws/setup/index.d.ts +1 -0
  224. package/lib/commonjs/platforms/aws/setup/index.js +18 -0
  225. package/lib/commonjs/platforms/aws/setup/index.js.map +1 -0
  226. package/lib/commonjs/platforms/aws/stacks.d.ts +7 -0
  227. package/lib/commonjs/platforms/aws/stacks.js +94 -0
  228. package/lib/commonjs/platforms/aws/stacks.js.map +1 -0
  229. package/lib/commonjs/platforms/aws/teardown.d.ts +2 -0
  230. package/lib/commonjs/platforms/aws/teardown.js +59 -0
  231. package/lib/commonjs/platforms/aws/teardown.js.map +1 -0
  232. package/lib/commonjs/platforms/aws/viewsSync.d.ts +3 -0
  233. package/lib/commonjs/platforms/aws/viewsSync.js +77 -0
  234. package/lib/commonjs/platforms/aws/viewsSync.js.map +1 -0
  235. package/lib/commonjs/platforms/docker/QpqDockerPlatformSettings.d.ts +10 -0
  236. package/lib/commonjs/platforms/docker/QpqDockerPlatformSettings.js +3 -0
  237. package/lib/commonjs/platforms/docker/QpqDockerPlatformSettings.js.map +1 -0
  238. package/lib/commonjs/platforms/docker/getContainerPorts.d.ts +4 -0
  239. package/lib/commonjs/platforms/docker/getContainerPorts.js +12 -0
  240. package/lib/commonjs/platforms/docker/getContainerPorts.js.map +1 -0
  241. package/lib/commonjs/platforms/docker/getDefaultPortMappings.d.ts +3 -0
  242. package/lib/commonjs/platforms/docker/getDefaultPortMappings.js +10 -0
  243. package/lib/commonjs/platforms/docker/getDefaultPortMappings.js.map +1 -0
  244. package/lib/commonjs/platforms/docker/getDockerPlatformSettings.d.ts +14 -0
  245. package/lib/commonjs/platforms/docker/getDockerPlatformSettings.js +39 -0
  246. package/lib/commonjs/platforms/docker/getDockerPlatformSettings.js.map +1 -0
  247. package/lib/commonjs/platforms/docker/getImageName.d.ts +6 -0
  248. package/lib/commonjs/platforms/docker/getImageName.js +10 -0
  249. package/lib/commonjs/platforms/docker/getImageName.js.map +1 -0
  250. package/lib/commonjs/platforms/docker/go.d.ts +2 -0
  251. package/lib/commonjs/platforms/docker/go.js +261 -0
  252. package/lib/commonjs/platforms/docker/go.js.map +1 -0
  253. package/lib/commonjs/platforms/docker/index.d.ts +2 -0
  254. package/lib/commonjs/platforms/docker/index.js +43 -0
  255. package/lib/commonjs/platforms/docker/index.js.map +1 -0
  256. package/lib/commonjs/platforms/docker/parseMounts.d.ts +7 -0
  257. package/lib/commonjs/platforms/docker/parseMounts.js +27 -0
  258. package/lib/commonjs/platforms/docker/parseMounts.js.map +1 -0
  259. package/lib/commonjs/platforms/docker/parsePortMappings.d.ts +8 -0
  260. package/lib/commonjs/platforms/docker/parsePortMappings.js +26 -0
  261. package/lib/commonjs/platforms/docker/parsePortMappings.js.map +1 -0
  262. package/lib/commonjs/platforms/docker/resolvePortMappings.d.ts +8 -0
  263. package/lib/commonjs/platforms/docker/resolvePortMappings.js +23 -0
  264. package/lib/commonjs/platforms/docker/resolvePortMappings.js.map +1 -0
  265. package/lib/commonjs/platforms/docker/writeComposeFile.d.ts +20 -0
  266. package/lib/commonjs/platforms/docker/writeComposeFile.js +44 -0
  267. package/lib/commonjs/platforms/docker/writeComposeFile.js.map +1 -0
  268. package/lib/commonjs/platforms/index.d.ts +3 -0
  269. package/lib/commonjs/platforms/index.js +35 -0
  270. package/lib/commonjs/platforms/index.js.map +1 -0
  271. package/lib/commonjs/platforms/types.d.ts +21 -0
  272. package/lib/commonjs/platforms/types.js +9 -0
  273. package/lib/commonjs/platforms/types.js.map +1 -0
  274. package/lib/esm/bin/qpq.d.ts +2 -0
  275. package/lib/esm/bin/qpq.js +4 -0
  276. package/lib/esm/bin/qpq.js.map +1 -0
  277. package/lib/esm/bin/qpqCdkApp.d.ts +1 -0
  278. package/lib/esm/bin/qpqCdkApp.js +6 -0
  279. package/lib/esm/bin/qpqCdkApp.js.map +1 -0
  280. package/lib/esm/cli/commandMenu.d.ts +2 -0
  281. package/lib/esm/cli/commandMenu.js +67 -0
  282. package/lib/esm/cli/commandMenu.js.map +1 -0
  283. package/lib/esm/cli/commandRegistry.d.ts +10 -0
  284. package/lib/esm/cli/commandRegistry.js +161 -0
  285. package/lib/esm/cli/commandRegistry.js.map +1 -0
  286. package/lib/esm/cli/index.d.ts +1 -0
  287. package/lib/esm/cli/index.js +2 -0
  288. package/lib/esm/cli/index.js.map +1 -0
  289. package/lib/esm/cli/runCli.d.ts +1 -0
  290. package/lib/esm/cli/runCli.js +73 -0
  291. package/lib/esm/cli/runCli.js.map +1 -0
  292. package/lib/esm/commands/checkCircular.d.ts +1 -0
  293. package/lib/esm/commands/checkCircular.js +55 -0
  294. package/lib/esm/commands/checkCircular.js.map +1 -0
  295. package/lib/esm/commands/clearResources.d.ts +1 -0
  296. package/lib/esm/commands/clearResources.js +23 -0
  297. package/lib/esm/commands/clearResources.js.map +1 -0
  298. package/lib/esm/commands/go.d.ts +1 -0
  299. package/lib/esm/commands/go.js +16 -0
  300. package/lib/esm/commands/go.js.map +1 -0
  301. package/lib/esm/commands/goDev.d.ts +1 -0
  302. package/lib/esm/commands/goDev.js +33 -0
  303. package/lib/esm/commands/goDev.js.map +1 -0
  304. package/lib/esm/commands/goDevApi.d.ts +1 -0
  305. package/lib/esm/commands/goDevApi.js +142 -0
  306. package/lib/esm/commands/goDevApi.js.map +1 -0
  307. package/lib/esm/commands/goDevWeb.d.ts +4 -0
  308. package/lib/esm/commands/goDevWeb.js +129 -0
  309. package/lib/esm/commands/goDevWeb.js.map +1 -0
  310. package/lib/esm/commands/goDocker.d.ts +1 -0
  311. package/lib/esm/commands/goDocker.js +29 -0
  312. package/lib/esm/commands/goDocker.js.map +1 -0
  313. package/lib/esm/commands/hooks.d.ts +1 -0
  314. package/lib/esm/commands/hooks.js +26 -0
  315. package/lib/esm/commands/hooks.js.map +1 -0
  316. package/lib/esm/commands/migrate.d.ts +1 -0
  317. package/lib/esm/commands/migrate.js +57 -0
  318. package/lib/esm/commands/migrate.js.map +1 -0
  319. package/lib/esm/commands/prep.d.ts +1 -0
  320. package/lib/esm/commands/prep.js +15 -0
  321. package/lib/esm/commands/prep.js.map +1 -0
  322. package/lib/esm/commands/publish.d.ts +4 -0
  323. package/lib/esm/commands/publish.js +38 -0
  324. package/lib/esm/commands/publish.js.map +1 -0
  325. package/lib/esm/commands/scriptBuild.d.ts +1 -0
  326. package/lib/esm/commands/scriptBuild.js +29 -0
  327. package/lib/esm/commands/scriptBuild.js.map +1 -0
  328. package/lib/esm/commands/scriptBuilderLayer.d.ts +1 -0
  329. package/lib/esm/commands/scriptBuilderLayer.js +34 -0
  330. package/lib/esm/commands/scriptBuilderLayer.js.map +1 -0
  331. package/lib/esm/commands/scriptNew.d.ts +1 -0
  332. package/lib/esm/commands/scriptNew.js +19 -0
  333. package/lib/esm/commands/scriptNew.js.map +1 -0
  334. package/lib/esm/commands/setup.d.ts +1 -0
  335. package/lib/esm/commands/setup.js +88 -0
  336. package/lib/esm/commands/setup.js.map +1 -0
  337. package/lib/esm/commands/synth.d.ts +1 -0
  338. package/lib/esm/commands/synth.js +73 -0
  339. package/lib/esm/commands/synth.js.map +1 -0
  340. package/lib/esm/commands/teardown.d.ts +1 -0
  341. package/lib/esm/commands/teardown.js +20 -0
  342. package/lib/esm/commands/teardown.js.map +1 -0
  343. package/lib/esm/index.d.ts +1 -0
  344. package/lib/esm/index.js +2 -0
  345. package/lib/esm/index.js.map +1 -0
  346. package/lib/esm/lib/args.d.ts +3 -0
  347. package/lib/esm/lib/args.js +25 -0
  348. package/lib/esm/lib/args.js.map +1 -0
  349. package/lib/esm/lib/circularImports.d.ts +3 -0
  350. package/lib/esm/lib/circularImports.js +61 -0
  351. package/lib/esm/lib/circularImports.js.map +1 -0
  352. package/lib/esm/lib/clearResourcesPlan.d.ts +15 -0
  353. package/lib/esm/lib/clearResourcesPlan.js +65 -0
  354. package/lib/esm/lib/clearResourcesPlan.js.map +1 -0
  355. package/lib/esm/lib/deployPrompts.d.ts +26 -0
  356. package/lib/esm/lib/deployPrompts.js +103 -0
  357. package/lib/esm/lib/deployPrompts.js.map +1 -0
  358. package/lib/esm/lib/devServerEntry.d.ts +22 -0
  359. package/lib/esm/lib/devServerEntry.js +127 -0
  360. package/lib/esm/lib/devServerEntry.js.map +1 -0
  361. package/lib/esm/lib/devServerPorts.d.ts +13 -0
  362. package/lib/esm/lib/devServerPorts.js +27 -0
  363. package/lib/esm/lib/devServerPorts.js.map +1 -0
  364. package/lib/esm/lib/discovery.d.ts +10 -0
  365. package/lib/esm/lib/discovery.js +40 -0
  366. package/lib/esm/lib/discovery.js.map +1 -0
  367. package/lib/esm/lib/getDefaultHookJobs.d.ts +2 -0
  368. package/lib/esm/lib/getDefaultHookJobs.js +4 -0
  369. package/lib/esm/lib/getDefaultHookJobs.js.map +1 -0
  370. package/lib/esm/lib/getDeployTargetLabel.d.ts +2 -0
  371. package/lib/esm/lib/getDeployTargetLabel.js +8 -0
  372. package/lib/esm/lib/getDeployTargetLabel.js.map +1 -0
  373. package/lib/esm/lib/goDockerMode.d.ts +6 -0
  374. package/lib/esm/lib/goDockerMode.js +19 -0
  375. package/lib/esm/lib/goDockerMode.js.map +1 -0
  376. package/lib/esm/lib/hooks.d.ts +9 -0
  377. package/lib/esm/lib/hooks.js +154 -0
  378. package/lib/esm/lib/hooks.js.map +1 -0
  379. package/lib/esm/lib/keepOtherDevServersFlag.d.ts +1 -0
  380. package/lib/esm/lib/keepOtherDevServersFlag.js +8 -0
  381. package/lib/esm/lib/keepOtherDevServersFlag.js.map +1 -0
  382. package/lib/esm/lib/killChildWithEscalation.d.ts +10 -0
  383. package/lib/esm/lib/killChildWithEscalation.js +29 -0
  384. package/lib/esm/lib/killChildWithEscalation.js.map +1 -0
  385. package/lib/esm/lib/killStaleListeners.d.ts +17 -0
  386. package/lib/esm/lib/killStaleListeners.js +210 -0
  387. package/lib/esm/lib/killStaleListeners.js.map +1 -0
  388. package/lib/esm/lib/packageRoot.d.ts +1 -0
  389. package/lib/esm/lib/packageRoot.js +14 -0
  390. package/lib/esm/lib/packageRoot.js.map +1 -0
  391. package/lib/esm/lib/prompts.d.ts +15 -0
  392. package/lib/esm/lib/prompts.js +28 -0
  393. package/lib/esm/lib/prompts.js.map +1 -0
  394. package/lib/esm/lib/qpqConfigs.d.ts +4 -0
  395. package/lib/esm/lib/qpqConfigs.js +21 -0
  396. package/lib/esm/lib/qpqConfigs.js.map +1 -0
  397. package/lib/esm/lib/resolveAppSelection.d.ts +6 -0
  398. package/lib/esm/lib/resolveAppSelection.js +45 -0
  399. package/lib/esm/lib/resolveAppSelection.js.map +1 -0
  400. package/lib/esm/lib/resolveDeployment.d.ts +14 -0
  401. package/lib/esm/lib/resolveDeployment.js +45 -0
  402. package/lib/esm/lib/resolveDeployment.js.map +1 -0
  403. package/lib/esm/lib/runCommand.d.ts +14 -0
  404. package/lib/esm/lib/runCommand.js +92 -0
  405. package/lib/esm/lib/runCommand.js.map +1 -0
  406. package/lib/esm/lib/runTasks.d.ts +15 -0
  407. package/lib/esm/lib/runTasks.js +108 -0
  408. package/lib/esm/lib/runTasks.js.map +1 -0
  409. package/lib/esm/lib/setupStep.d.ts +16 -0
  410. package/lib/esm/lib/setupStep.js +2 -0
  411. package/lib/esm/lib/setupStep.js.map +1 -0
  412. package/lib/esm/lib/timing.d.ts +2 -0
  413. package/lib/esm/lib/timing.js +6 -0
  414. package/lib/esm/lib/timing.js.map +1 -0
  415. package/lib/esm/lib/typeWatcher.d.ts +2 -0
  416. package/lib/esm/lib/typeWatcher.js +51 -0
  417. package/lib/esm/lib/typeWatcher.js.map +1 -0
  418. package/lib/esm/lib/userScriptBuilderLayer.d.ts +23 -0
  419. package/lib/esm/lib/userScriptBuilderLayer.js +65 -0
  420. package/lib/esm/lib/userScriptBuilderLayer.js.map +1 -0
  421. package/lib/esm/lib/userScriptTemplate.d.ts +6 -0
  422. package/lib/esm/lib/userScriptTemplate.js +39 -0
  423. package/lib/esm/lib/userScriptTemplate.js.map +1 -0
  424. package/lib/esm/lib/views.d.ts +2 -0
  425. package/lib/esm/lib/views.js +14 -0
  426. package/lib/esm/lib/views.js.map +1 -0
  427. package/lib/esm/lib/webAddressingEnv.d.ts +7 -0
  428. package/lib/esm/lib/webAddressingEnv.js +11 -0
  429. package/lib/esm/lib/webAddressingEnv.js.map +1 -0
  430. package/lib/esm/platforms/aws/awsCredentials.d.ts +1 -0
  431. package/lib/esm/platforms/aws/awsCredentials.js +15 -0
  432. package/lib/esm/platforms/aws/awsCredentials.js.map +1 -0
  433. package/lib/esm/platforms/aws/cdkApp.d.ts +3 -0
  434. package/lib/esm/platforms/aws/cdkApp.js +22 -0
  435. package/lib/esm/platforms/aws/cdkApp.js.map +1 -0
  436. package/lib/esm/platforms/aws/clearResources.d.ts +2 -0
  437. package/lib/esm/platforms/aws/clearResources.js +151 -0
  438. package/lib/esm/platforms/aws/clearResources.js.map +1 -0
  439. package/lib/esm/platforms/aws/go.d.ts +2 -0
  440. package/lib/esm/platforms/aws/go.js +115 -0
  441. package/lib/esm/platforms/aws/go.js.map +1 -0
  442. package/lib/esm/platforms/aws/goDocker.d.ts +3 -0
  443. package/lib/esm/platforms/aws/goDocker.js +441 -0
  444. package/lib/esm/platforms/aws/goDocker.js.map +1 -0
  445. package/lib/esm/platforms/aws/goDockerManifest.d.ts +44 -0
  446. package/lib/esm/platforms/aws/goDockerManifest.js +26 -0
  447. package/lib/esm/platforms/aws/goDockerManifest.js.map +1 -0
  448. package/lib/esm/platforms/aws/index.d.ts +2 -0
  449. package/lib/esm/platforms/aws/index.js +20 -0
  450. package/lib/esm/platforms/aws/index.js.map +1 -0
  451. package/lib/esm/platforms/aws/prepareDeployment.d.ts +3 -0
  452. package/lib/esm/platforms/aws/prepareDeployment.js +6 -0
  453. package/lib/esm/platforms/aws/prepareDeployment.js.map +1 -0
  454. package/lib/esm/platforms/aws/publish.d.ts +4 -0
  455. package/lib/esm/platforms/aws/publish.js +50 -0
  456. package/lib/esm/platforms/aws/publish.js.map +1 -0
  457. package/lib/esm/platforms/aws/remote.d.ts +11 -0
  458. package/lib/esm/platforms/aws/remote.js +89 -0
  459. package/lib/esm/platforms/aws/remote.js.map +1 -0
  460. package/lib/esm/platforms/aws/setup/awsSetupContext.d.ts +12 -0
  461. package/lib/esm/platforms/aws/setup/awsSetupContext.js +16 -0
  462. package/lib/esm/platforms/aws/setup/awsSetupContext.js.map +1 -0
  463. package/lib/esm/platforms/aws/setup/awsSetupSteps.d.ts +8 -0
  464. package/lib/esm/platforms/aws/setup/awsSetupSteps.js +31 -0
  465. package/lib/esm/platforms/aws/setup/awsSetupSteps.js.map +1 -0
  466. package/lib/esm/platforms/aws/setup/buildBucketNamesStep.d.ts +4 -0
  467. package/lib/esm/platforms/aws/setup/buildBucketNamesStep.js +62 -0
  468. package/lib/esm/platforms/aws/setup/buildBucketNamesStep.js.map +1 -0
  469. package/lib/esm/platforms/aws/setup/buildCdkBootstrapSteps.d.ts +5 -0
  470. package/lib/esm/platforms/aws/setup/buildCdkBootstrapSteps.js +24 -0
  471. package/lib/esm/platforms/aws/setup/buildCdkBootstrapSteps.js.map +1 -0
  472. package/lib/esm/platforms/aws/setup/buildGithubDeployRoleStep.d.ts +4 -0
  473. package/lib/esm/platforms/aws/setup/buildGithubDeployRoleStep.js +40 -0
  474. package/lib/esm/platforms/aws/setup/buildGithubDeployRoleStep.js.map +1 -0
  475. package/lib/esm/platforms/aws/setup/buildGithubOidcProviderStep.d.ts +4 -0
  476. package/lib/esm/platforms/aws/setup/buildGithubOidcProviderStep.js +40 -0
  477. package/lib/esm/platforms/aws/setup/buildGithubOidcProviderStep.js.map +1 -0
  478. package/lib/esm/platforms/aws/setup/buildHostedZonesStep.d.ts +4 -0
  479. package/lib/esm/platforms/aws/setup/buildHostedZonesStep.js +49 -0
  480. package/lib/esm/platforms/aws/setup/buildHostedZonesStep.js.map +1 -0
  481. package/lib/esm/platforms/aws/setup/buildIamCapabilityStep.d.ts +4 -0
  482. package/lib/esm/platforms/aws/setup/buildIamCapabilityStep.js +34 -0
  483. package/lib/esm/platforms/aws/setup/buildIamCapabilityStep.js.map +1 -0
  484. package/lib/esm/platforms/aws/setup/buildIdentityStep.d.ts +4 -0
  485. package/lib/esm/platforms/aws/setup/buildIdentityStep.js +26 -0
  486. package/lib/esm/platforms/aws/setup/buildIdentityStep.js.map +1 -0
  487. package/lib/esm/platforms/aws/setup/buildStackSteps.d.ts +5 -0
  488. package/lib/esm/platforms/aws/setup/buildStackSteps.js +17 -0
  489. package/lib/esm/platforms/aws/setup/buildStackSteps.js.map +1 -0
  490. package/lib/esm/platforms/aws/setup/describeStackStatus.d.ts +4 -0
  491. package/lib/esm/platforms/aws/setup/describeStackStatus.js +17 -0
  492. package/lib/esm/platforms/aws/setup/describeStackStatus.js.map +1 -0
  493. package/lib/esm/platforms/aws/setup/index.d.ts +1 -0
  494. package/lib/esm/platforms/aws/setup/index.js +2 -0
  495. package/lib/esm/platforms/aws/setup/index.js.map +1 -0
  496. package/lib/esm/platforms/aws/stacks.d.ts +7 -0
  497. package/lib/esm/platforms/aws/stacks.js +72 -0
  498. package/lib/esm/platforms/aws/stacks.js.map +1 -0
  499. package/lib/esm/platforms/aws/teardown.d.ts +2 -0
  500. package/lib/esm/platforms/aws/teardown.js +46 -0
  501. package/lib/esm/platforms/aws/teardown.js.map +1 -0
  502. package/lib/esm/platforms/aws/viewsSync.d.ts +3 -0
  503. package/lib/esm/platforms/aws/viewsSync.js +60 -0
  504. package/lib/esm/platforms/aws/viewsSync.js.map +1 -0
  505. package/lib/esm/platforms/docker/QpqDockerPlatformSettings.d.ts +10 -0
  506. package/lib/esm/platforms/docker/QpqDockerPlatformSettings.js +2 -0
  507. package/lib/esm/platforms/docker/QpqDockerPlatformSettings.js.map +1 -0
  508. package/lib/esm/platforms/docker/getContainerPorts.d.ts +4 -0
  509. package/lib/esm/platforms/docker/getContainerPorts.js +8 -0
  510. package/lib/esm/platforms/docker/getContainerPorts.js.map +1 -0
  511. package/lib/esm/platforms/docker/getDefaultPortMappings.d.ts +3 -0
  512. package/lib/esm/platforms/docker/getDefaultPortMappings.js +6 -0
  513. package/lib/esm/platforms/docker/getDefaultPortMappings.js.map +1 -0
  514. package/lib/esm/platforms/docker/getDockerPlatformSettings.d.ts +14 -0
  515. package/lib/esm/platforms/docker/getDockerPlatformSettings.js +34 -0
  516. package/lib/esm/platforms/docker/getDockerPlatformSettings.js.map +1 -0
  517. package/lib/esm/platforms/docker/getImageName.d.ts +6 -0
  518. package/lib/esm/platforms/docker/getImageName.js +6 -0
  519. package/lib/esm/platforms/docker/getImageName.js.map +1 -0
  520. package/lib/esm/platforms/docker/go.d.ts +2 -0
  521. package/lib/esm/platforms/docker/go.js +242 -0
  522. package/lib/esm/platforms/docker/go.js.map +1 -0
  523. package/lib/esm/platforms/docker/index.d.ts +2 -0
  524. package/lib/esm/platforms/docker/index.js +31 -0
  525. package/lib/esm/platforms/docker/index.js.map +1 -0
  526. package/lib/esm/platforms/docker/parseMounts.d.ts +7 -0
  527. package/lib/esm/platforms/docker/parseMounts.js +23 -0
  528. package/lib/esm/platforms/docker/parseMounts.js.map +1 -0
  529. package/lib/esm/platforms/docker/parsePortMappings.d.ts +8 -0
  530. package/lib/esm/platforms/docker/parsePortMappings.js +21 -0
  531. package/lib/esm/platforms/docker/parsePortMappings.js.map +1 -0
  532. package/lib/esm/platforms/docker/resolvePortMappings.d.ts +8 -0
  533. package/lib/esm/platforms/docker/resolvePortMappings.js +18 -0
  534. package/lib/esm/platforms/docker/resolvePortMappings.js.map +1 -0
  535. package/lib/esm/platforms/docker/writeComposeFile.d.ts +20 -0
  536. package/lib/esm/platforms/docker/writeComposeFile.js +37 -0
  537. package/lib/esm/platforms/docker/writeComposeFile.js.map +1 -0
  538. package/lib/esm/platforms/index.d.ts +3 -0
  539. package/lib/esm/platforms/index.js +17 -0
  540. package/lib/esm/platforms/index.js.map +1 -0
  541. package/lib/esm/platforms/types.d.ts +21 -0
  542. package/lib/esm/platforms/types.js +6 -0
  543. package/lib/esm/platforms/types.js.map +1 -0
  544. package/package.json +71 -3
  545. package/templates/user-script/README.md +28 -0
  546. package/templates/user-script/gitignore +2 -0
  547. package/templates/user-script/package.json +16 -0
  548. package/templates/user-script/src/main.ts +15 -0
  549. package/templates/user-script/tsconfig.json +12 -0
@@ -0,0 +1,22 @@
1
+ /**
2
+ * What the generated bootstrap does: serve forever, run pending migrations once and exit, or
3
+ * both in turn (the docker image, where nothing else ever deploys and so nothing else would
4
+ * run the migrations).
5
+ */
6
+ export type DevServerEntryMode = 'serve' | 'migrate' | 'migrate-then-serve';
7
+ /** Env vars the docker image sets so the running server knows how the outside world reaches it. */
8
+ export declare const DEV_SERVER_PUBLIC_HOST_ENV = "QPQ_PUBLIC_HOST";
9
+ export declare const DEV_SERVER_PUBLIC_FILE_STORAGE_PORT_ENV = "QPQ_PUBLIC_FILE_STORAGE_PORT";
10
+ /**
11
+ * Writes the dev-server bootstrap for an app and returns its path. Generated per build so it
12
+ * can import the optional app-owned overrides file (apps/<app>/devServer.config.ts) and the
13
+ * `quidproquo-dynamic-loader` virtual module QpqPlugin injects at bundle time. Every mode
14
+ * shares one bundle shape, so a local migration run rehearses exactly the deployed path.
15
+ */
16
+ export declare const writeDevServerEntry: (root: string, appName: string, mode?: DevServerEntryMode) => string;
17
+ /**
18
+ * Writes the dev server's user-script child entry and returns its path. The server forks the
19
+ * bundle this becomes once per script call, with the service name as its argument; the child
20
+ * serves that one call with the service's config and module loader, then exits.
21
+ */
22
+ export declare const writeUserScriptChildEntry: (root: string) => string;
@@ -0,0 +1,135 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.writeUserScriptChildEntry = exports.writeDevServerEntry = exports.DEV_SERVER_PUBLIC_FILE_STORAGE_PORT_ENV = exports.DEV_SERVER_PUBLIC_HOST_ENV = void 0;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const deploy_rspack_1 = require("@qpqjs/deploy-rspack");
10
+ const devServerPorts_1 = require("./devServerPorts");
11
+ /** Env vars the docker image sets so the running server knows how the outside world reaches it. */
12
+ exports.DEV_SERVER_PUBLIC_HOST_ENV = 'QPQ_PUBLIC_HOST';
13
+ exports.DEV_SERVER_PUBLIC_FILE_STORAGE_PORT_ENV = 'QPQ_PUBLIC_FILE_STORAGE_PORT';
14
+ const USER_SCRIPT_CHILD_ENTRY_FILE_NAME = 'user-script-child.entry.ts';
15
+ const ENTRY_FILE_NAMES = {
16
+ serve: 'entry.ts',
17
+ migrate: 'migrate.entry.ts',
18
+ 'migrate-then-serve': 'entry.ts',
19
+ };
20
+ const reportMigrations = `(ran) => {
21
+ const total = Object.values(ran).reduce((sum, keys) => sum + keys.length, 0);
22
+ for (const [service, keys] of Object.entries(ran)) {
23
+ for (const key of keys) {
24
+ console.log(\` [\${service}] \${key}\`);
25
+ }
26
+ }
27
+ console.log(total === 0 ? 'No pending migrations.' : \`Ran \${total} migration(s).\`);
28
+ }`;
29
+ const getRunCall = (mode) => {
30
+ if (mode === 'serve') {
31
+ return 'startDevServer(devServerConfig, devServerConfigOverrides);';
32
+ }
33
+ const afterMigrations = mode === 'migrate' ? 'process.exit(0);' : 'return startDevServer(devServerConfig, devServerConfigOverrides);';
34
+ return `runMigrations(devServerConfig, devServerConfigOverrides)
35
+ .then(${reportMigrations})
36
+ .then(() => {
37
+ ${afterMigrations}
38
+ })
39
+ .catch((error) => {
40
+ console.error('Migration failed:', error);
41
+ // Non-zero so CI, shell chains and a container restart policy actually notice.
42
+ process.exit(1);
43
+ });`;
44
+ };
45
+ /**
46
+ * Writes the dev-server bootstrap for an app and returns its path. Generated per build so it
47
+ * can import the optional app-owned overrides file (apps/<app>/devServer.config.ts) and the
48
+ * `quidproquo-dynamic-loader` virtual module QpqPlugin injects at bundle time. Every mode
49
+ * shares one bundle shape, so a local migration run rehearses exactly the deployed path.
50
+ */
51
+ const writeDevServerEntry = (root, appName, mode = 'serve') => {
52
+ const entryDir = path_1.default.join(root, 'dist', 'qpq', 'dev-server');
53
+ const entryPath = path_1.default.join(entryDir, ENTRY_FILE_NAMES[mode]);
54
+ const overridesPath = (0, devServerPorts_1.getDevServerConfigPath)(appName);
55
+ const overridesImport = fs_1.default.existsSync(overridesPath)
56
+ ? `import devServerConfigOverrides from ${JSON.stringify(overridesPath.replace(/\.ts$/, ''))};`
57
+ : 'const devServerConfigOverrides = {};';
58
+ const imports = mode === 'serve' ? 'startDevServer' : mode === 'migrate' ? 'runMigrations' : 'runMigrations, startDevServer';
59
+ fs_1.default.mkdirSync(entryDir, { recursive: true });
60
+ fs_1.default.writeFileSync(entryPath, `// GENERATED by qpq — do not edit.
61
+ import { ${imports} } from '@qpqjs/dev-server';
62
+ import path from 'path';
63
+ import {
64
+ qpqConfigs,
65
+ qpqDynamicModuleLoaderForService,
66
+ // @ts-ignore - Special build-time virtual module
67
+ } from 'quidproquo-dynamic-loader';
68
+
69
+ ${overridesImport}
70
+
71
+ // Ports are defaults here; the app's devServer.config.ts \`ports\` win when the server resolves its config.
72
+ const devServerConfig = {
73
+ serverDomain: 'localhost',
74
+ serverPort: ${devServerPorts_1.DEFAULT_DEV_SERVER_PORTS.api},
75
+ webSocketPort: ${devServerPorts_1.DEFAULT_DEV_SERVER_PORTS.webSocket},
76
+ // Scoped per app so running the dev server for two apps out of the same
77
+ // repo root doesn't share kvs/file-storage/config state.
78
+ runtimePath: ${JSON.stringify(path_1.default.join('.qpq-runtime', appName))},
79
+ fileStorageConfig: {
80
+ // Secure file urls are absolute, so a container has to be told the address browsers use.
81
+ secureUrlHost: process.env.${exports.DEV_SERVER_PUBLIC_HOST_ENV} || 'localhost',
82
+ secureUrlPort: ${devServerPorts_1.DEFAULT_DEV_SERVER_PORTS.fileStorage},
83
+ secureUrlPublicPort: Number(process.env.${exports.DEV_SERVER_PUBLIC_FILE_STORAGE_PORT_ENV}) || undefined,
84
+ // No fixed secret: the server mints a random one per process, so a secure url token
85
+ // (which names a filesystem path) cannot be forged by anyone who has read this file.
86
+ },
87
+ qpqConfigs,
88
+ dynamicModuleLoader: qpqDynamicModuleLoaderForService,
89
+ // The user-script child bundle is built beside this one (see writeUserScriptChildEntry).
90
+ userScriptChildModulePath: path.join(path.dirname(process.argv[1]), ${JSON.stringify(`${deploy_rspack_1.USER_SCRIPT_CHILD_BUNDLE_NAME}.js`)}),
91
+ // QPQ_WEB_ROOT (set in the docker platform image) turns on static web serving.
92
+ webRoot: process.env.QPQ_WEB_ROOT,
93
+ logServiceName: 'admin',
94
+ delay: { default: 0 },
95
+ };
96
+
97
+ ${getRunCall(mode)}
98
+ `);
99
+ return entryPath;
100
+ };
101
+ exports.writeDevServerEntry = writeDevServerEntry;
102
+ /**
103
+ * Writes the dev server's user-script child entry and returns its path. The server forks the
104
+ * bundle this becomes once per script call, with the service name as its argument; the child
105
+ * serves that one call with the service's config and module loader, then exits.
106
+ */
107
+ const writeUserScriptChildEntry = (root) => {
108
+ const entryDir = path_1.default.join(root, 'dist', 'qpq', 'dev-server');
109
+ const entryPath = path_1.default.join(entryDir, USER_SCRIPT_CHILD_ENTRY_FILE_NAME);
110
+ fs_1.default.mkdirSync(entryDir, { recursive: true });
111
+ fs_1.default.writeFileSync(entryPath, `// GENERATED by qpq — do not edit.
112
+ import { qpqCoreUtils } from '@qpqjs/core';
113
+ import { runUserScriptChildMain } from '@qpqjs/actionprocessor-node';
114
+ import {
115
+ qpqConfigs,
116
+ qpqDynamicModuleLoaderForService,
117
+ // @ts-ignore - Special build-time virtual module
118
+ } from 'quidproquo-dynamic-loader';
119
+
120
+ export const main = (): void => {
121
+ const serviceName = process.argv[2];
122
+ const qpqConfig = qpqConfigs.find((config) => qpqCoreUtils.getApplicationModuleName(config) === serviceName);
123
+ if (!qpqConfig) {
124
+ throw new Error(\`User script child: no service named [\${serviceName}]\`);
125
+ }
126
+
127
+ runUserScriptChildMain(qpqConfig, (runtime) => qpqDynamicModuleLoaderForService(serviceName, runtime));
128
+ };
129
+
130
+ main();
131
+ `);
132
+ return entryPath;
133
+ };
134
+ exports.writeUserScriptChildEntry = writeUserScriptChildEntry;
135
+ //# sourceMappingURL=devServerEntry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"devServerEntry.js","sourceRoot":"","sources":["../../../src/lib/devServerEntry.ts"],"names":[],"mappings":"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","sourcesContent":["import fs from 'fs';\nimport path from 'path';\n\nimport { USER_SCRIPT_CHILD_BUNDLE_NAME } from '@qpqjs/deploy-rspack';\n\nimport { DEFAULT_DEV_SERVER_PORTS, getDevServerConfigPath } from './devServerPorts';\n\n/**\n * What the generated bootstrap does: serve forever, run pending migrations once and exit, or\n * both in turn (the docker image, where nothing else ever deploys and so nothing else would\n * run the migrations).\n */\nexport type DevServerEntryMode = 'serve' | 'migrate' | 'migrate-then-serve';\n\n/** Env vars the docker image sets so the running server knows how the outside world reaches it. */\nexport const DEV_SERVER_PUBLIC_HOST_ENV = 'QPQ_PUBLIC_HOST';\nexport const DEV_SERVER_PUBLIC_FILE_STORAGE_PORT_ENV = 'QPQ_PUBLIC_FILE_STORAGE_PORT';\n\nconst USER_SCRIPT_CHILD_ENTRY_FILE_NAME = 'user-script-child.entry.ts';\n\nconst ENTRY_FILE_NAMES: Record<DevServerEntryMode, string> = {\n serve: 'entry.ts',\n migrate: 'migrate.entry.ts',\n 'migrate-then-serve': 'entry.ts',\n};\n\nconst reportMigrations = `(ran) => {\n const total = Object.values(ran).reduce((sum, keys) => sum + keys.length, 0);\n for (const [service, keys] of Object.entries(ran)) {\n for (const key of keys) {\n console.log(\\` [\\${service}] \\${key}\\`);\n }\n }\n console.log(total === 0 ? 'No pending migrations.' : \\`Ran \\${total} migration(s).\\`);\n }`;\n\nconst getRunCall = (mode: DevServerEntryMode): string => {\n if (mode === 'serve') {\n return 'startDevServer(devServerConfig, devServerConfigOverrides);';\n }\n\n const afterMigrations = mode === 'migrate' ? 'process.exit(0);' : 'return startDevServer(devServerConfig, devServerConfigOverrides);';\n\n return `runMigrations(devServerConfig, devServerConfigOverrides)\n .then(${reportMigrations})\n .then(() => {\n ${afterMigrations}\n })\n .catch((error) => {\n console.error('Migration failed:', error);\n // Non-zero so CI, shell chains and a container restart policy actually notice.\n process.exit(1);\n });`;\n};\n\n/**\n * Writes the dev-server bootstrap for an app and returns its path. Generated per build so it\n * can import the optional app-owned overrides file (apps/<app>/devServer.config.ts) and the\n * `quidproquo-dynamic-loader` virtual module QpqPlugin injects at bundle time. Every mode\n * shares one bundle shape, so a local migration run rehearses exactly the deployed path.\n */\nexport const writeDevServerEntry = (root: string, appName: string, mode: DevServerEntryMode = 'serve'): string => {\n const entryDir = path.join(root, 'dist', 'qpq', 'dev-server');\n const entryPath = path.join(entryDir, ENTRY_FILE_NAMES[mode]);\n\n const overridesPath = getDevServerConfigPath(appName);\n const overridesImport = fs.existsSync(overridesPath)\n ? `import devServerConfigOverrides from ${JSON.stringify(overridesPath.replace(/\\.ts$/, ''))};`\n : 'const devServerConfigOverrides = {};';\n\n const imports = mode === 'serve' ? 'startDevServer' : mode === 'migrate' ? 'runMigrations' : 'runMigrations, startDevServer';\n\n fs.mkdirSync(entryDir, { recursive: true });\n fs.writeFileSync(\n entryPath,\n `// GENERATED by qpq — do not edit.\nimport { ${imports} } from '@qpqjs/dev-server';\nimport path from 'path';\nimport {\n qpqConfigs,\n qpqDynamicModuleLoaderForService,\n // @ts-ignore - Special build-time virtual module\n} from 'quidproquo-dynamic-loader';\n\n${overridesImport}\n\n// Ports are defaults here; the app's devServer.config.ts \\`ports\\` win when the server resolves its config.\nconst devServerConfig = {\n serverDomain: 'localhost',\n serverPort: ${DEFAULT_DEV_SERVER_PORTS.api},\n webSocketPort: ${DEFAULT_DEV_SERVER_PORTS.webSocket},\n // Scoped per app so running the dev server for two apps out of the same\n // repo root doesn't share kvs/file-storage/config state.\n runtimePath: ${JSON.stringify(path.join('.qpq-runtime', appName))},\n fileStorageConfig: {\n // Secure file urls are absolute, so a container has to be told the address browsers use.\n secureUrlHost: process.env.${DEV_SERVER_PUBLIC_HOST_ENV} || 'localhost',\n secureUrlPort: ${DEFAULT_DEV_SERVER_PORTS.fileStorage},\n secureUrlPublicPort: Number(process.env.${DEV_SERVER_PUBLIC_FILE_STORAGE_PORT_ENV}) || undefined,\n // No fixed secret: the server mints a random one per process, so a secure url token\n // (which names a filesystem path) cannot be forged by anyone who has read this file.\n },\n qpqConfigs,\n dynamicModuleLoader: qpqDynamicModuleLoaderForService,\n // The user-script child bundle is built beside this one (see writeUserScriptChildEntry).\n userScriptChildModulePath: path.join(path.dirname(process.argv[1]), ${JSON.stringify(`${USER_SCRIPT_CHILD_BUNDLE_NAME}.js`)}),\n // QPQ_WEB_ROOT (set in the docker platform image) turns on static web serving.\n webRoot: process.env.QPQ_WEB_ROOT,\n logServiceName: 'admin',\n delay: { default: 0 },\n};\n\n${getRunCall(mode)}\n`,\n );\n\n return entryPath;\n};\n\n/**\n * Writes the dev server's user-script child entry and returns its path. The server forks the\n * bundle this becomes once per script call, with the service name as its argument; the child\n * serves that one call with the service's config and module loader, then exits.\n */\nexport const writeUserScriptChildEntry = (root: string): string => {\n const entryDir = path.join(root, 'dist', 'qpq', 'dev-server');\n const entryPath = path.join(entryDir, USER_SCRIPT_CHILD_ENTRY_FILE_NAME);\n\n fs.mkdirSync(entryDir, { recursive: true });\n fs.writeFileSync(\n entryPath,\n `// GENERATED by qpq — do not edit.\nimport { qpqCoreUtils } from '@qpqjs/core';\nimport { runUserScriptChildMain } from '@qpqjs/actionprocessor-node';\nimport {\n qpqConfigs,\n qpqDynamicModuleLoaderForService,\n // @ts-ignore - Special build-time virtual module\n} from 'quidproquo-dynamic-loader';\n\nexport const main = (): void => {\n const serviceName = process.argv[2];\n const qpqConfig = qpqConfigs.find((config) => qpqCoreUtils.getApplicationModuleName(config) === serviceName);\n if (!qpqConfig) {\n throw new Error(\\`User script child: no service named [\\${serviceName}]\\`);\n }\n\n runUserScriptChildMain(qpqConfig, (runtime) => qpqDynamicModuleLoaderForService(serviceName, runtime));\n};\n\nmain();\n`,\n );\n\n return entryPath;\n};\n"]}
@@ -0,0 +1,13 @@
1
+ import { DevServerPorts } from '@qpqjs/dev-server';
2
+ /** Every dev server listener, with the app's overrides applied. */
3
+ export type ResolvedDevServerPorts = Required<DevServerPorts>;
4
+ /** The ports a dev server listens on when the app sets none: api + static web, websockets, file storage secure urls. */
5
+ export declare const DEFAULT_DEV_SERVER_PORTS: ResolvedDevServerPorts;
6
+ /** Path of the app's optional dev server settings module (`apps/<app>/devServer.config.ts`). */
7
+ export declare const getDevServerConfigPath: (appName: string) => string;
8
+ /**
9
+ * The app's dev server ports: `ports` from apps/<app>/devServer.config.ts over the defaults. The
10
+ * same numbers the running server resolves, so builds that bake or expose ports agree with it.
11
+ * Requiring the TS module relies on the caller running with TS require hooks, as every command does.
12
+ */
13
+ export declare const readDevServerPorts: (appName: string) => ResolvedDevServerPorts;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.readDevServerPorts = exports.getDevServerConfigPath = exports.DEFAULT_DEV_SERVER_PORTS = void 0;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const discovery_1 = require("./discovery");
10
+ /** The ports a dev server listens on when the app sets none: api + static web, websockets, file storage secure urls. */
11
+ exports.DEFAULT_DEV_SERVER_PORTS = {
12
+ api: 8080,
13
+ webSocket: 8888,
14
+ fileStorage: 3001,
15
+ };
16
+ /** Path of the app's optional dev server settings module (`apps/<app>/devServer.config.ts`). */
17
+ const getDevServerConfigPath = (appName) => path_1.default.join((0, discovery_1.getAppDirectory)(appName), 'devServer.config.ts');
18
+ exports.getDevServerConfigPath = getDevServerConfigPath;
19
+ /**
20
+ * The app's dev server ports: `ports` from apps/<app>/devServer.config.ts over the defaults. The
21
+ * same numbers the running server resolves, so builds that bake or expose ports agree with it.
22
+ * Requiring the TS module relies on the caller running with TS require hooks, as every command does.
23
+ */
24
+ const readDevServerPorts = (appName) => {
25
+ var _a;
26
+ const configPath = (0, exports.getDevServerConfigPath)(appName);
27
+ if (!fs_1.default.existsSync(configPath)) {
28
+ return exports.DEFAULT_DEV_SERVER_PORTS;
29
+ }
30
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
31
+ const loaded = require(configPath.replace(/\.ts$/, ''));
32
+ const overrides = ((_a = loaded.default) !== null && _a !== void 0 ? _a : loaded);
33
+ return Object.assign(Object.assign({}, exports.DEFAULT_DEV_SERVER_PORTS), overrides.ports);
34
+ };
35
+ exports.readDevServerPorts = readDevServerPorts;
36
+ //# sourceMappingURL=devServerPorts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"devServerPorts.js","sourceRoot":"","sources":["../../../src/lib/devServerPorts.ts"],"names":[],"mappings":";;;;;;AAEA,4CAAoB;AACpB,gDAAwB;AAExB,2CAA8C;AAK9C,wHAAwH;AAC3G,QAAA,wBAAwB,GAA2B;IAC9D,GAAG,EAAE,IAAI;IACT,SAAS,EAAE,IAAI;IACf,WAAW,EAAE,IAAI;CAClB,CAAC;AAEF,gGAAgG;AACzF,MAAM,sBAAsB,GAAG,CAAC,OAAe,EAAU,EAAE,CAAC,cAAI,CAAC,IAAI,CAAC,IAAA,2BAAe,EAAC,OAAO,CAAC,EAAE,qBAAqB,CAAC,CAAC;AAAjH,QAAA,sBAAsB,0BAA2F;AAE9H;;;;GAIG;AACI,MAAM,kBAAkB,GAAG,CAAC,OAAe,EAA0B,EAAE;;IAC5E,MAAM,UAAU,GAAG,IAAA,8BAAsB,EAAC,OAAO,CAAC,CAAC;IACnD,IAAI,CAAC,YAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC/B,OAAO,gCAAwB,CAAC;IAClC,CAAC;IAED,iEAAiE;IACjE,MAAM,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;IACxD,MAAM,SAAS,GAAG,CAAC,MAAA,MAAM,CAAC,OAAO,mCAAI,MAAM,CAA6B,CAAC;IAEzE,uCAAY,gCAAwB,GAAK,SAAS,CAAC,KAAK,EAAG;AAC7D,CAAC,CAAC;AAXW,QAAA,kBAAkB,sBAW7B","sourcesContent":["import { DevServerConfigOverrides, DevServerPorts } from '@qpqjs/dev-server';\n\nimport fs from 'fs';\nimport path from 'path';\n\nimport { getAppDirectory } from './discovery';\n\n/** Every dev server listener, with the app's overrides applied. */\nexport type ResolvedDevServerPorts = Required<DevServerPorts>;\n\n/** The ports a dev server listens on when the app sets none: api + static web, websockets, file storage secure urls. */\nexport const DEFAULT_DEV_SERVER_PORTS: ResolvedDevServerPorts = {\n api: 8080,\n webSocket: 8888,\n fileStorage: 3001,\n};\n\n/** Path of the app's optional dev server settings module (`apps/<app>/devServer.config.ts`). */\nexport const getDevServerConfigPath = (appName: string): string => path.join(getAppDirectory(appName), 'devServer.config.ts');\n\n/**\n * The app's dev server ports: `ports` from apps/<app>/devServer.config.ts over the defaults. The\n * same numbers the running server resolves, so builds that bake or expose ports agree with it.\n * Requiring the TS module relies on the caller running with TS require hooks, as every command does.\n */\nexport const readDevServerPorts = (appName: string): ResolvedDevServerPorts => {\n const configPath = getDevServerConfigPath(appName);\n if (!fs.existsSync(configPath)) {\n return DEFAULT_DEV_SERVER_PORTS;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const loaded = require(configPath.replace(/\\.ts$/, ''));\n const overrides = (loaded.default ?? loaded) as DevServerConfigOverrides;\n\n return { ...DEFAULT_DEV_SERVER_PORTS, ...overrides.ports };\n};\n"]}
@@ -0,0 +1,10 @@
1
+ export declare const getRoot: () => string;
2
+ export declare const getAppsDirectory: () => string;
3
+ export declare const getAppDirectory: (appName: string) => string;
4
+ export declare const getServiceDirectory: (appName: string, service: string) => string;
5
+ export declare const getAvailableApps: () => string[];
6
+ export declare const getAllServiceNames: (appName: string) => string[];
7
+ export declare const serviceHasSubdir: (appName: string, service: string, subdir: string) => boolean;
8
+ export declare const getServiceNamesWithSubdir: (appName: string, subdir: string) => string[];
9
+ export declare const getServiceNames: (appName: string) => string[];
10
+ export declare const getServiceNamesWithViews: (appName: string) => string[];
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getServiceNamesWithViews = exports.getServiceNames = exports.getServiceNamesWithSubdir = exports.serviceHasSubdir = exports.getAllServiceNames = exports.getAvailableApps = exports.getServiceDirectory = exports.getAppDirectory = exports.getAppsDirectory = exports.getRoot = void 0;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
9
+ // The consumer repo root — qpq always runs from the workspace root (npm
10
+ // scripts set cwd there).
11
+ const getRoot = () => process.cwd();
12
+ exports.getRoot = getRoot;
13
+ const getAppsDirectory = () => path_1.default.join((0, exports.getRoot)(), 'apps');
14
+ exports.getAppsDirectory = getAppsDirectory;
15
+ const getAppDirectory = (appName) => path_1.default.join((0, exports.getAppsDirectory)(), appName);
16
+ exports.getAppDirectory = getAppDirectory;
17
+ const getServiceDirectory = (appName, service) => path_1.default.join((0, exports.getAppDirectory)(appName), 'services', service);
18
+ exports.getServiceDirectory = getServiceDirectory;
19
+ // Apps are the directories under apps/ that contain a services/ directory.
20
+ const getAvailableApps = () => {
21
+ const appsPath = (0, exports.getAppsDirectory)();
22
+ if (!fs_1.default.existsSync(appsPath)) {
23
+ return [];
24
+ }
25
+ return fs_1.default.readdirSync(appsPath).filter((name) => {
26
+ const servicesPath = path_1.default.join((0, exports.getAppDirectory)(name), 'services');
27
+ return fs_1.default.statSync((0, exports.getAppDirectory)(name)).isDirectory() && fs_1.default.existsSync(servicesPath) && fs_1.default.statSync(servicesPath).isDirectory();
28
+ });
29
+ };
30
+ exports.getAvailableApps = getAvailableApps;
31
+ // Every service directory under an app's services/ folder (no subdir filter).
32
+ const getAllServiceNames = (appName) => {
33
+ const directoryPath = path_1.default.join((0, exports.getAppDirectory)(appName), 'services');
34
+ if (!fs_1.default.existsSync(directoryPath)) {
35
+ return [];
36
+ }
37
+ return fs_1.default.readdirSync(directoryPath).filter((name) => fs_1.default.statSync((0, exports.getServiceDirectory)(appName, name)).isDirectory());
38
+ };
39
+ exports.getAllServiceNames = getAllServiceNames;
40
+ // True when a service contains the given child directory (e.g. 'service' for a
41
+ // backend, 'views' for a frontend).
42
+ const serviceHasSubdir = (appName, service, subdir) => {
43
+ const subdirPath = path_1.default.join((0, exports.getServiceDirectory)(appName, service), subdir);
44
+ return fs_1.default.existsSync(subdirPath) && fs_1.default.statSync(subdirPath).isDirectory();
45
+ };
46
+ exports.serviceHasSubdir = serviceHasSubdir;
47
+ // Services that contain a given child directory.
48
+ const getServiceNamesWithSubdir = (appName, subdir) => (0, exports.getAllServiceNames)(appName).filter((service) => (0, exports.serviceHasSubdir)(appName, service, subdir));
49
+ exports.getServiceNamesWithSubdir = getServiceNamesWithSubdir;
50
+ // Backend services — those with a service/ subdir.
51
+ const getServiceNames = (appName) => (0, exports.getServiceNamesWithSubdir)(appName, 'service');
52
+ exports.getServiceNames = getServiceNames;
53
+ // Backend services that also ship a frontend (views/ subdir).
54
+ const getServiceNamesWithViews = (appName) => (0, exports.getServiceNames)(appName).filter((service) => (0, exports.serviceHasSubdir)(appName, service, 'views'));
55
+ exports.getServiceNamesWithViews = getServiceNamesWithViews;
56
+ //# sourceMappingURL=discovery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discovery.js","sourceRoot":"","sources":["../../../src/lib/discovery.ts"],"names":[],"mappings":"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","sourcesContent":["import fs from 'fs';\nimport path from 'path';\n\n// The consumer repo root — qpq always runs from the workspace root (npm\n// scripts set cwd there).\nexport const getRoot = (): string => process.cwd();\n\nexport const getAppsDirectory = (): string => path.join(getRoot(), 'apps');\nexport const getAppDirectory = (appName: string): string => path.join(getAppsDirectory(), appName);\nexport const getServiceDirectory = (appName: string, service: string): string => path.join(getAppDirectory(appName), 'services', service);\n\n// Apps are the directories under apps/ that contain a services/ directory.\nexport const getAvailableApps = (): string[] => {\n const appsPath = getAppsDirectory();\n\n if (!fs.existsSync(appsPath)) {\n return [];\n }\n\n return fs.readdirSync(appsPath).filter((name) => {\n const servicesPath = path.join(getAppDirectory(name), 'services');\n return fs.statSync(getAppDirectory(name)).isDirectory() && fs.existsSync(servicesPath) && fs.statSync(servicesPath).isDirectory();\n });\n};\n\n// Every service directory under an app's services/ folder (no subdir filter).\nexport const getAllServiceNames = (appName: string): string[] => {\n const directoryPath = path.join(getAppDirectory(appName), 'services');\n\n if (!fs.existsSync(directoryPath)) {\n return [];\n }\n\n return fs.readdirSync(directoryPath).filter((name) => fs.statSync(getServiceDirectory(appName, name)).isDirectory());\n};\n\n// True when a service contains the given child directory (e.g. 'service' for a\n// backend, 'views' for a frontend).\nexport const serviceHasSubdir = (appName: string, service: string, subdir: string): boolean => {\n const subdirPath = path.join(getServiceDirectory(appName, service), subdir);\n return fs.existsSync(subdirPath) && fs.statSync(subdirPath).isDirectory();\n};\n\n// Services that contain a given child directory.\nexport const getServiceNamesWithSubdir = (appName: string, subdir: string): string[] =>\n getAllServiceNames(appName).filter((service) => serviceHasSubdir(appName, service, subdir));\n\n// Backend services — those with a service/ subdir.\nexport const getServiceNames = (appName: string): string[] => getServiceNamesWithSubdir(appName, 'service');\n\n// Backend services that also ship a frontend (views/ subdir).\nexport const getServiceNamesWithViews = (appName: string): string[] =>\n getServiceNames(appName).filter((service) => serviceHasSubdir(appName, service, 'views'));\n"]}
@@ -0,0 +1,2 @@
1
+ /** How many package scripts a hook run starts at once: a core left for the rest of the machine, capped so a wide dependency level doesn't stack up too many npm processes. */
2
+ export declare const getDefaultHookJobs: () => number;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getDefaultHookJobs = void 0;
7
+ const os_1 = __importDefault(require("os"));
8
+ /** How many package scripts a hook run starts at once: a core left for the rest of the machine, capped so a wide dependency level doesn't stack up too many npm processes. */
9
+ const getDefaultHookJobs = () => Math.max(1, Math.min(8, os_1.default.availableParallelism() - 1));
10
+ exports.getDefaultHookJobs = getDefaultHookJobs;
11
+ //# sourceMappingURL=getDefaultHookJobs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getDefaultHookJobs.js","sourceRoot":"","sources":["../../../src/lib/getDefaultHookJobs.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AAEpB,8KAA8K;AACvK,MAAM,kBAAkB,GAAG,GAAW,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,YAAE,CAAC,oBAAoB,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;AAA3F,QAAA,kBAAkB,sBAAyE","sourcesContent":["import os from 'os';\n\n/** How many package scripts a hook run starts at once: a core left for the rest of the machine, capped so a wide dependency level doesn't stack up too many npm processes. */\nexport const getDefaultHookJobs = (): number => Math.max(1, Math.min(8, os.availableParallelism() - 1));\n"]}
@@ -0,0 +1,2 @@
1
+ /** The resolved deployment as a human label for confirmations, e.g. `production (example-production)`. */
2
+ export declare const getDeployTargetLabel: () => string;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getDeployTargetLabel = void 0;
4
+ const core_1 = require("@qpqjs/core");
5
+ /** The resolved deployment as a human label for confirmations, e.g. `production (example-production)`. */
6
+ const getDeployTargetLabel = () => {
7
+ const env = process.env;
8
+ const identity = [env[core_1.QpqDeployEnvVar.applicationName], env[core_1.QpqDeployEnvVar.environment], env[core_1.QpqDeployEnvVar.featureName]].filter(Boolean).join('-');
9
+ return `${env[core_1.QpqDeployEnvVar.deployName]} (${identity})`;
10
+ };
11
+ exports.getDeployTargetLabel = getDeployTargetLabel;
12
+ //# sourceMappingURL=getDeployTargetLabel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getDeployTargetLabel.js","sourceRoot":"","sources":["../../../src/lib/getDeployTargetLabel.ts"],"names":[],"mappings":";;;AAAA,sCAA8C;AAE9C,0GAA0G;AACnG,MAAM,oBAAoB,GAAG,GAAW,EAAE;IAC/C,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IACxB,MAAM,QAAQ,GAAG,CAAC,GAAG,CAAC,sBAAe,CAAC,eAAe,CAAC,EAAE,GAAG,CAAC,sBAAe,CAAC,WAAW,CAAC,EAAE,GAAG,CAAC,sBAAe,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACtJ,OAAO,GAAG,GAAG,CAAC,sBAAe,CAAC,UAAU,CAAC,KAAK,QAAQ,GAAG,CAAC;AAC5D,CAAC,CAAC;AAJW,QAAA,oBAAoB,wBAI/B","sourcesContent":["import { QpqDeployEnvVar } from '@qpqjs/core';\n\n/** The resolved deployment as a human label for confirmations, e.g. `production (example-production)`. */\nexport const getDeployTargetLabel = (): string => {\n const env = process.env;\n const identity = [env[QpqDeployEnvVar.applicationName], env[QpqDeployEnvVar.environment], env[QpqDeployEnvVar.featureName]].filter(Boolean).join('-');\n return `${env[QpqDeployEnvVar.deployName]} (${identity})`;\n};\n"]}
@@ -0,0 +1,6 @@
1
+ /** Which half of `qpq go:docker` a run performs: both, the build and save, or the deploy from a saved build. */
2
+ export type GoDockerMode = 'full' | 'build-only' | 'from-build';
3
+ export declare const BUILD_ONLY_FLAG = "--build-only";
4
+ export declare const FROM_BUILD_FLAG = "--from-build";
5
+ /** Reads the mode off the command's argv. Throws when both flags are given, since one run cannot be both halves. */
6
+ export declare const resolveGoDockerMode: (argv: string[]) => GoDockerMode;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveGoDockerMode = exports.FROM_BUILD_FLAG = exports.BUILD_ONLY_FLAG = void 0;
4
+ const args_1 = require("./args");
5
+ exports.BUILD_ONLY_FLAG = '--build-only';
6
+ exports.FROM_BUILD_FLAG = '--from-build';
7
+ /** Reads the mode off the command's argv. Throws when both flags are given, since one run cannot be both halves. */
8
+ const resolveGoDockerMode = (argv) => {
9
+ const buildOnly = (0, args_1.hasArgFlag)(argv, exports.BUILD_ONLY_FLAG);
10
+ const fromBuild = (0, args_1.hasArgFlag)(argv, exports.FROM_BUILD_FLAG);
11
+ if (buildOnly && fromBuild) {
12
+ throw new Error(`${exports.BUILD_ONLY_FLAG} and ${exports.FROM_BUILD_FLAG} are exclusive: build on one run, deploy on another`);
13
+ }
14
+ if (buildOnly) {
15
+ return 'build-only';
16
+ }
17
+ if (fromBuild) {
18
+ return 'from-build';
19
+ }
20
+ return 'full';
21
+ };
22
+ exports.resolveGoDockerMode = resolveGoDockerMode;
23
+ //# sourceMappingURL=goDockerMode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"goDockerMode.js","sourceRoot":"","sources":["../../../src/lib/goDockerMode.ts"],"names":[],"mappings":";;;AAAA,iCAAoC;AAKvB,QAAA,eAAe,GAAG,cAAc,CAAC;AACjC,QAAA,eAAe,GAAG,cAAc,CAAC;AAE9C,oHAAoH;AAC7G,MAAM,mBAAmB,GAAG,CAAC,IAAc,EAAgB,EAAE;IAClE,MAAM,SAAS,GAAG,IAAA,iBAAU,EAAC,IAAI,EAAE,uBAAe,CAAC,CAAC;IACpD,MAAM,SAAS,GAAG,IAAA,iBAAU,EAAC,IAAI,EAAE,uBAAe,CAAC,CAAC;IAEpD,IAAI,SAAS,IAAI,SAAS,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,GAAG,uBAAe,QAAQ,uBAAe,qDAAqD,CAAC,CAAC;IAClH,CAAC;IACD,IAAI,SAAS,EAAE,CAAC;QACd,OAAO,YAAY,CAAC;IACtB,CAAC;IACD,IAAI,SAAS,EAAE,CAAC;QACd,OAAO,YAAY,CAAC;IACtB,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAdW,QAAA,mBAAmB,uBAc9B","sourcesContent":["import { hasArgFlag } from './args';\n\n/** Which half of `qpq go:docker` a run performs: both, the build and save, or the deploy from a saved build. */\nexport type GoDockerMode = 'full' | 'build-only' | 'from-build';\n\nexport const BUILD_ONLY_FLAG = '--build-only';\nexport const FROM_BUILD_FLAG = '--from-build';\n\n/** Reads the mode off the command's argv. Throws when both flags are given, since one run cannot be both halves. */\nexport const resolveGoDockerMode = (argv: string[]): GoDockerMode => {\n const buildOnly = hasArgFlag(argv, BUILD_ONLY_FLAG);\n const fromBuild = hasArgFlag(argv, FROM_BUILD_FLAG);\n\n if (buildOnly && fromBuild) {\n throw new Error(`${BUILD_ONLY_FLAG} and ${FROM_BUILD_FLAG} are exclusive: build on one run, deploy on another`);\n }\n if (buildOnly) {\n return 'build-only';\n }\n if (fromBuild) {\n return 'from-build';\n }\n return 'full';\n};\n"]}
@@ -0,0 +1,9 @@
1
+ import { TaskFailure } from './runTasks';
2
+ export declare const runAppHook: (appName: string, hook: string) => Promise<boolean>;
3
+ /** Runs a hook in every app and workspace package that defines it. Returns the failures; callers decide fatality. */
4
+ export declare const runHookForAllPackages: (hook: string, jobs: number) => Promise<TaskFailure[]>;
5
+ /**
6
+ * Runs a hook in one app's packages, the shared packages outside apps/, and anything those depend on.
7
+ * Other apps' packages are skipped. Returns the failures; callers decide fatality.
8
+ */
9
+ export declare const runHookForAppPackages: (hook: string, appName: string, jobs: number) => Promise<TaskFailure[]>;
@@ -0,0 +1,178 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.runHookForAppPackages = exports.runHookForAllPackages = exports.runAppHook = void 0;
16
+ const fs_1 = __importDefault(require("fs"));
17
+ const path_1 = __importDefault(require("path"));
18
+ const discovery_1 = require("./discovery");
19
+ const runCommand_1 = require("./runCommand");
20
+ const runTasks_1 = require("./runTasks");
21
+ // App lifecycle hooks: apps/<app>/package.json scripts named `qpq:<hook>`
22
+ // (e.g. qpq:postinstall, qpq:prebuild). The CLI invokes them when present;
23
+ // apps without the hook are skipped silently.
24
+ const runAppHook = (appName, hook) => __awaiter(void 0, void 0, void 0, function* () {
25
+ var _a;
26
+ const packageJsonPath = path_1.default.join((0, discovery_1.getAppDirectory)(appName), 'package.json');
27
+ if (!fs_1.default.existsSync(packageJsonPath)) {
28
+ return false;
29
+ }
30
+ const packageJson = JSON.parse(fs_1.default.readFileSync(packageJsonPath, 'utf-8'));
31
+ const scriptName = `qpq:${hook}`;
32
+ if (!((_a = packageJson.scripts) === null || _a === void 0 ? void 0 : _a[scriptName])) {
33
+ return false;
34
+ }
35
+ console.log(`Running ${scriptName} for [${appName}]`);
36
+ yield (0, runCommand_1.runCommand)('npm', ['run', scriptName], { cwd: (0, discovery_1.getAppDirectory)(appName) });
37
+ return true;
38
+ });
39
+ exports.runAppHook = runAppHook;
40
+ const isDirectory = (candidate) => fs_1.default.existsSync(candidate) && fs_1.default.statSync(candidate).isDirectory();
41
+ const listSubdirectories = (dir) => {
42
+ if (!isDirectory(dir)) {
43
+ return [];
44
+ }
45
+ return fs_1.default
46
+ .readdirSync(dir)
47
+ .map((name) => path_1.default.join(dir, name))
48
+ .filter(isDirectory);
49
+ };
50
+ // Expand one `workspaces` glob. Only literal segments and bare `*` are
51
+ // supported, which covers the patterns qpq repos use (e.g.
52
+ // "apps/*/services/*/models"); anything fancier ("**", braces) matches nothing.
53
+ const expandWorkspacePattern = (root, pattern) => {
54
+ let dirs = [root];
55
+ for (const segment of pattern.split('/')) {
56
+ if (segment === '*') {
57
+ dirs = dirs.flatMap(listSubdirectories);
58
+ }
59
+ else {
60
+ dirs = dirs.map((dir) => path_1.default.join(dir, segment)).filter(isDirectory);
61
+ }
62
+ }
63
+ return dirs;
64
+ };
65
+ const readPackageJson = (dir) => {
66
+ const packageJsonPath = path_1.default.join(dir, 'package.json');
67
+ if (!fs_1.default.existsSync(packageJsonPath)) {
68
+ return undefined;
69
+ }
70
+ return JSON.parse(fs_1.default.readFileSync(packageJsonPath, 'utf-8'));
71
+ };
72
+ // Every directory that can carry hooks: app dirs plus all workspace packages,
73
+ // deduped (an app dir could itself be a workspace).
74
+ const getHookPackages = () => {
75
+ var _a, _b;
76
+ const root = (0, discovery_1.getRoot)();
77
+ const rootPkg = readPackageJson(root);
78
+ const appDirs = (0, discovery_1.getAvailableApps)().map((appName) => ({ dir: (0, discovery_1.getAppDirectory)(appName), fallbackLabel: appName }));
79
+ const workspaceDirs = ((_a = rootPkg === null || rootPkg === void 0 ? void 0 : rootPkg.workspaces) !== null && _a !== void 0 ? _a : [])
80
+ .flatMap((pattern) => expandWorkspacePattern(root, pattern))
81
+ .map((dir) => ({ dir, fallbackLabel: path_1.default.relative(root, dir) }));
82
+ const packages = [];
83
+ const seen = new Set();
84
+ for (const { dir, fallbackLabel } of [...appDirs, ...workspaceDirs]) {
85
+ const resolved = path_1.default.resolve(dir);
86
+ if (seen.has(resolved)) {
87
+ continue;
88
+ }
89
+ seen.add(resolved);
90
+ const pkg = readPackageJson(dir);
91
+ if (pkg) {
92
+ packages.push({ dir, label: (_b = pkg.name) !== null && _b !== void 0 ? _b : fallbackLabel, pkg });
93
+ }
94
+ }
95
+ return packages;
96
+ };
97
+ // The script a hook resolves to in one package: `qpq:<hook>` when defined,
98
+ // otherwise the plain `<hook>` script. Empty-string scripts count as absent.
99
+ const resolveHookScript = (pkg, hook) => {
100
+ var _a, _b;
101
+ if ((_a = pkg.scripts) === null || _a === void 0 ? void 0 : _a[`qpq:${hook}`]) {
102
+ return `qpq:${hook}`;
103
+ }
104
+ if ((_b = pkg.scripts) === null || _b === void 0 ? void 0 : _b[hook]) {
105
+ return hook;
106
+ }
107
+ return undefined;
108
+ };
109
+ const getDeclaredDependencyNames = (pkg) => Object.keys(Object.assign(Object.assign(Object.assign({}, pkg.dependencies), pkg.devDependencies), pkg.peerDependencies));
110
+ // True for a package inside apps/<some other app>/. Packages outside apps/
111
+ // are shared, so they never count as another app's.
112
+ const isOtherAppPackage = (dir, appName) => {
113
+ const relative = path_1.default.relative((0, discovery_1.getAppsDirectory)(), path_1.default.resolve(dir));
114
+ if (relative === '' || relative.startsWith('..') || path_1.default.isAbsolute(relative)) {
115
+ return false;
116
+ }
117
+ return relative.split(path_1.default.sep)[0] !== appName;
118
+ };
119
+ // The app's own packages and the shared ones, plus every package they depend
120
+ // on wherever it lives, so a cross-app dependency still gets built.
121
+ const getAppHookPackages = (appName) => {
122
+ const allPackages = getHookPackages();
123
+ const byName = new Map();
124
+ for (const hookPackage of allPackages) {
125
+ if (hookPackage.pkg.name) {
126
+ byName.set(hookPackage.pkg.name, hookPackage);
127
+ }
128
+ }
129
+ const selected = new Set(allPackages.filter((hookPackage) => !isOtherAppPackage(hookPackage.dir, appName)));
130
+ const pending = [...selected];
131
+ for (let current = pending.pop(); current; current = pending.pop()) {
132
+ for (const depName of getDeclaredDependencyNames(current.pkg)) {
133
+ const dep = byName.get(depName);
134
+ if (dep && !selected.has(dep)) {
135
+ selected.add(dep);
136
+ pending.push(dep);
137
+ }
138
+ }
139
+ }
140
+ return allPackages.filter((hookPackage) => selected.has(hookPackage));
141
+ };
142
+ // Run the hook's script in each of `candidates` that defines it (qpq:<hook>
143
+ // preferred over a plain <hook> script), in dependency order (declared deps
144
+ // resolved by package name), with up to `jobs` running concurrently. Packages
145
+ // whose dependencies aren't part of this run don't wait on them.
146
+ const runHookForPackages = (candidates, hook, jobs) => __awaiter(void 0, void 0, void 0, function* () {
147
+ const hookPackages = candidates
148
+ .map((candidate) => (Object.assign(Object.assign({}, candidate), { scriptName: resolveHookScript(candidate.pkg, hook) })))
149
+ .filter((candidate) => candidate.scriptName !== undefined);
150
+ if (hookPackages.length === 0) {
151
+ console.log(`No app or workspace package defines a "qpq:${hook}" or "${hook}" script, nothing to run.`);
152
+ return [];
153
+ }
154
+ // Dependency edges only count between packages that are part of this run:
155
+ // a dep that doesn't define the hook has nothing to wait for.
156
+ const runSetNames = new Set(hookPackages.map((hookPackage) => hookPackage.pkg.name).filter(Boolean));
157
+ const tasks = hookPackages.map((hookPackage) => {
158
+ var _a;
159
+ return ({
160
+ id: (_a = hookPackage.pkg.name) !== null && _a !== void 0 ? _a : hookPackage.dir,
161
+ label: hookPackage.label,
162
+ deps: getDeclaredDependencyNames(hookPackage.pkg).filter((name) => runSetNames.has(name) && name !== hookPackage.pkg.name),
163
+ run: () => (0, runCommand_1.runCommandPrefixed)(hookPackage.label, 'npm', ['run', hookPackage.scriptName], { cwd: hookPackage.dir, color: (0, runCommand_1.nextPrefixColor)() }),
164
+ });
165
+ });
166
+ console.log(`Running ${hook} hooks in ${tasks.length} package(s) (${jobs} jobs, dependency ordered)`);
167
+ return (0, runTasks_1.runDependencyTasks)(tasks, jobs);
168
+ });
169
+ /** Runs a hook in every app and workspace package that defines it. Returns the failures; callers decide fatality. */
170
+ const runHookForAllPackages = (hook, jobs) => runHookForPackages(getHookPackages(), hook, jobs);
171
+ exports.runHookForAllPackages = runHookForAllPackages;
172
+ /**
173
+ * Runs a hook in one app's packages, the shared packages outside apps/, and anything those depend on.
174
+ * Other apps' packages are skipped. Returns the failures; callers decide fatality.
175
+ */
176
+ const runHookForAppPackages = (hook, appName, jobs) => runHookForPackages(getAppHookPackages(appName), hook, jobs);
177
+ exports.runHookForAppPackages = runHookForAppPackages;
178
+ //# sourceMappingURL=hooks.js.map