quidproquo-cli 0.1.16 → 0.1.17

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.
package/README.md CHANGED
@@ -1,3 +1,70 @@
1
- # quidproquo-dev-server
1
+ # quidproquo-cli
2
2
 
3
- Not prod ready
3
+ The `qpq` command line tool: build, dev, and deploy orchestration for [quidproquo](https://github.com/qpqjs/quidproquo) apps.
4
+
5
+ An app scaffolded with `create-qpq-app` already depends on this and aliases the common commands in its npm scripts, so `npm run dev` and `npm run deploy` are the usual way in. Everything else you call as `qpq` directly.
6
+
7
+ ```bash
8
+ npm install --save-dev quidproquo-cli
9
+ npx qpq
10
+ ```
11
+
12
+ Running `qpq` with no command opens an interactive menu. Every command also takes `--app`, `--env`, and `--platform`.
13
+
14
+ ## Commands
15
+
16
+ **Local development**
17
+
18
+ | Command | Does |
19
+ | --- | --- |
20
+ | `qpq go:dev` | Runs the full local stack, api and web, in one process |
21
+ | `qpq go:dev:api` | Just the api dev server, with hot reload |
22
+ | `qpq go:dev:web` | Just the views microfrontend dev servers |
23
+ | `qpq migrate [app]` | Runs pending migrations against the local dev store once, then exits |
24
+
25
+ **Deploying**
26
+
27
+ | Command | Does |
28
+ | --- | --- |
29
+ | `qpq go [svc] [stack]` | Deploys services. Interactive unless you pass the positional args |
30
+ | `qpq go:docker` | The same, but deploys in parallel via docker |
31
+ | `qpq synth [service]` | Synthesises the configs to `dist/apps/<app>/infrastructure` without deploying |
32
+ | `qpq teardown` | Destroys the web, api, and inf stacks for selected services |
33
+ | `qpq clear-resources` | Empties selected buckets and tables. Data only, stacks are untouched |
34
+
35
+ For `go`, `svc` is `all`, a comma-separated list, or one of `account`, `domain`, `bootstrap`. `stack` is `all`, `inf`, `api`, `web`, or `views`. A full `all all` or `all api` deploy also publishes federated backends.
36
+
37
+ **Federated remotes**
38
+
39
+ | Command | Does |
40
+ | --- | --- |
41
+ | `qpq publish` | Build, upload, and deploy federated remotes |
42
+ | `qpq publish:build` | Build them locally |
43
+ | `qpq publish:upload` | Upload the built version directories. Nothing goes live |
44
+ | `qpq publish:deploy` | Flip the manifests to the uploaded versions |
45
+
46
+ Splitting upload from deploy is what makes a rollback a manifest change rather than a redeploy.
47
+
48
+ **Workspace**
49
+
50
+ | Command | Does |
51
+ | --- | --- |
52
+ | `qpq prep` | Regenerates `apps/<app>/tsconfig.federated.json` |
53
+ | `qpq check:circular` | Scans workspace sources for circular imports. `--warn` to report without failing |
54
+ | `qpq hooks <name>` | Runs `qpq:<name>` in every app and package that defines it, dependency ordered and in parallel |
55
+
56
+ ## Platforms
57
+
58
+ The target platform comes from your app's `deploy.config.json`, so the same commands work whichever one an environment uses. AWS and docker are supported today.
59
+
60
+ ## Status
61
+
62
+ Pre-1.0. The whole `quidproquo-*` family releases in lockstep, so versions that share a number were built and tested together. Expect APIs to move between releases, and pin your versions.
63
+
64
+ ## Documentation
65
+
66
+ [docs.quidproquojs.com](https://docs.quidproquojs.com)
67
+
68
+ ## License
69
+
70
+ MIT. See [LICENSE](https://github.com/qpqjs/quidproquo/blob/main/LICENSE).
@@ -1,5 +1,5 @@
1
1
  # Runtime image for `qpq go` on the docker platform: the QPQ dev server
2
- # (a full local platform emulation — JSON-file KVS, file storage, queues,
2
+ # (a full local platform emulation — sqlite KVS, file storage, queues,
3
3
  # websockets) hosting every service of the app, plus the pre-built views.
4
4
  #
5
5
  # The server bundle externalizes bare packages (native modules must load from
@@ -25,7 +25,7 @@ exports.dockerGo = void 0;
25
25
  // and the locally-built quidproquo packages as a vendor overlay.
26
26
  // 4. docker build, then print the run command.
27
27
  //
28
- // Not production-grade (single process, JSON-file KVS, in-memory queues) —
28
+ // Not production-grade (single process, sqlite KVS, in-memory queues) —
29
29
  // it's the whole product on one box with one command.
30
30
  const quidproquo_deploy_rspack_1 = require("quidproquo-deploy-rspack");
31
31
  const fs_1 = __importDefault(require("fs"));
@@ -1 +1 @@
1
- {"version":3,"file":"go.js","sourceRoot":"","sources":["../../../../src/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U,EAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC;IAElE,IAAA,mBAAU,EAAC,WAAW,CAAC,CAAC;IAExB,OAAO,CAAC,GAAG,CAAC;;;;aAID,OAAO;MACd,QAAQ;;;;CAIb,CAAC,CAAC;AACH,CAAC,CAAA,CAAC;AAjFW,QAAA,QAAQ,YAiFnB","sourcesContent":["// Docker platform deploy (`qpq go` with platform 'docker') — proof-of-concept\n// self-hosting: bakes the QPQ dev server (a full local platform emulation)\n// plus every service of the app and its pre-built views into one docker image.\n//\n// 1. Build workspace packages, then the dev-server bundle (all services).\n// 2. Build every views microfrontend with a same-origin module-federation\n// remote base (/views/<svc>), mirroring the AWS website/views layout.\n// 3. Assemble an image context under dist/qpq/docker-image/<app>/ — server\n// bundle, web root, a workspaces-stripped package.json for runtime deps,\n// and the locally-built quidproquo packages as a vendor overlay.\n// 4. docker build, then print the run command.\n//\n// Not production-grade (single process, JSON-file KVS, in-memory queues) —\n// it's the whole product on one box with one command.\nimport { getAppServiceQpqConfigs, getDevServerRspackConfig } from 'quidproquo-deploy-rspack';\n\nimport fs from 'fs';\nimport path from 'path';\n\nimport { DeployPlan } from '../../lib/deployPrompts';\nimport { writeDevServerEntry } from '../../lib/devServerEntry';\nimport { getRoot, getServiceNamesWithViews } from '../../lib/discovery';\nimport { runAppHook } from '../../lib/hooks';\nimport { getOwnPackageRoot } from '../../lib/packageRoot';\nimport { runRspack } from '../../lib/rspackRun';\nimport { runCommand } from '../../lib/runCommand';\nimport { logTimeEnd, logTimeStart } from '../../lib/timing';\nimport { bundleViews, getViewsDistDir } from '../../lib/views';\n\nconst getImageContextDir = (root: string, appName: string): string => path.join(root, 'dist', 'qpq', 'docker-image', appName);\n\n// The consumer root package.json, stripped to what the image's npm install\n// needs: runtime dependencies (+ overrides). Workspaces/scripts/devDeps are\n// host-only concerns — the workspace packages themselves are bundled into the\n// server bundle from source.\n//\n// quidproquo deps declared as file: refs (a consumer living beside the qpq\n// monorepo) point outside the image context, where npm install would leave\n// dangling symlinks — rewrite them to the vendored copies inside the context.\nconst writeImagePackageJson = (root: string, contextDir: string): void => {\n const rootPackageJson = JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8'));\n\n const dependencies: Record<string, string> = { ...(rootPackageJson.dependencies ?? {}) };\n for (const [name, version] of Object.entries(dependencies)) {\n if (name.startsWith('quidproquo') && version.startsWith('file:')) {\n dependencies[name] = `file:./vendor/${name}`;\n }\n }\n\n const imagePackageJson = {\n name: `${rootPackageJson.name}-qpq-docker`,\n version: rootPackageJson.version ?? '0.0.0',\n private: true,\n dependencies,\n overrides: rootPackageJson.overrides,\n };\n\n fs.writeFileSync(path.join(contextDir, 'package.json'), JSON.stringify(imagePackageJson, null, 2) + '\\n');\n};\n\n// Copy the locally-built quidproquo packages (which may be npm-linked\n// checkouts newer than the registry) into vendor/ so the image runs the same\n// qpq code the bundle was built against. Follows the node_modules symlinks;\n// lib/config only — no node_modules, no src.\nconst vendorQuidproquoPackages = (root: string, contextDir: string): number => {\n const nodeModules = path.join(root, 'node_modules');\n const vendorDir = path.join(contextDir, 'vendor');\n let vendored = 0;\n\n for (const name of fs.readdirSync(nodeModules)) {\n if (!name.startsWith('quidproquo')) continue;\n\n const packageDir = fs.realpathSync(path.join(nodeModules, name));\n const targetDir = path.join(vendorDir, name);\n fs.mkdirSync(targetDir, { recursive: true });\n\n fs.copyFileSync(path.join(packageDir, 'package.json'), path.join(targetDir, 'package.json'));\n for (const sub of ['lib', 'config']) {\n const subDir = path.join(packageDir, sub);\n if (fs.existsSync(subDir)) {\n fs.cpSync(subDir, path.join(targetDir, sub), { recursive: true, dereference: true });\n }\n }\n vendored += 1;\n }\n\n return vendored;\n};\n\nexport const dockerGo = async (appName: string, plan: DeployPlan): Promise<void> => {\n if (plan.kind === 'cancelled') {\n return;\n }\n\n if (plan.kind === 'account' || plan.kind === 'bootstrap') {\n console.log(`Nothing to do — the docker platform has no ${plan.kind} stacks.`);\n return;\n }\n\n const root = getRoot();\n const imageTag = `qpq-${appName}:${process.env.ENVIRONMENT}`;\n\n // The dev server hosts every service of the app, so per-service/stack\n // selections don't apply — the image is always the whole app.\n console.log(`\\n\\nBuilding docker image [${imageTag}] — the whole app deploys as one image\\n\\n`);\n\n logTimeStart('totalTime');\n\n await runAppHook(appName, 'predeploy');\n\n // Workspace packages resolve through their built dist/ (package.json main),\n // so bundles would ship stale code unless every lib is tsc'd first.\n console.log('Building workspace packages');\n await runCommand('npm', ['run', 'build', '--workspaces', '--if-present']);\n\n // ---- Server bundle: the dev server + every service, one main.js ----\n console.log('Bundling server (dev server + all services)');\n const qpqConfigs = getAppServiceQpqConfigs(root, appName);\n const entry = writeDevServerEntry(root, appName);\n await runRspack(getDevServerRspackConfig({ root, entry, qpqConfigs }));\n\n // ---- Views: production builds with same-origin federation remotes ----\n process.env.QPQ_VIEWS_REMOTE_BASE = '/views';\n const viewServices = getServiceNamesWithViews(appName);\n for (const serviceName of viewServices) {\n console.log(`Bundling views: [${serviceName}]`);\n await bundleViews(appName, serviceName);\n }\n delete process.env.QPQ_VIEWS_REMOTE_BASE;\n\n // ---- Assemble the image context ----\n console.log('Assembling image context');\n const contextDir = getImageContextDir(root, appName);\n fs.rmSync(contextDir, { recursive: true, force: true });\n fs.mkdirSync(contextDir, { recursive: true });\n\n fs.copyFileSync(path.join(getOwnPackageRoot(), 'docker', 'dev-server', 'Dockerfile'), path.join(contextDir, 'Dockerfile'));\n writeImagePackageJson(root, contextDir);\n\n const vendored = vendorQuidproquoPackages(root, contextDir);\n console.log(`Vendored ${vendored} quidproquo packages`);\n\n fs.cpSync(path.join(root, 'dist', 'qpq', 'dev-server'), path.join(contextDir, 'server'), { recursive: true });\n\n // Web root mirrors the AWS buckets: shell at website/, every views build\n // (shell included) under views/<svc>/.\n for (const serviceName of viewServices) {\n const viewsDist = getViewsDistDir(appName, serviceName);\n fs.cpSync(viewsDist, path.join(contextDir, 'web', 'views', serviceName), { recursive: true });\n if (serviceName === 'shell') {\n fs.cpSync(viewsDist, path.join(contextDir, 'web', 'website'), { recursive: true });\n }\n }\n\n // ---- Build the image ----\n console.log('Building docker image');\n await runCommand('docker', ['build', '-t', imageTag, contextDir]);\n\n logTimeEnd('totalTime');\n\n console.log(`\nDone. Run it with:\n\n docker run --rm -p 80:8080 -p 8080:8080 -p 8888:8888 -p 3001:3001 \\\\\n -v qpq-${appName}-data:/app/.qpq-runtime \\\\\n ${imageTag}\n\nThen open http://localhost\n(80 serves the shell; 8080 stays mapped because the app's url resolvers call localhost:8080 for apis)\n`);\n};\n"]}
1
+ {"version":3,"file":"go.js","sourceRoot":"","sources":["../../../../src/platforms/docker/go.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,8EAA8E;AAC9E,2EAA2E;AAC3E,+EAA+E;AAC/E,EAAE;AACF,4EAA4E;AAC5E,4EAA4E;AAC5E,2EAA2E;AAC3E,6EAA6E;AAC7E,8EAA8E;AAC9E,sEAAsE;AACtE,iDAAiD;AACjD,EAAE;AACF,wEAAwE;AACxE,sDAAsD;AACtD,uEAA6F;AAE7F,4CAAoB;AACpB,gDAAwB;AAGxB,6DAA+D;AAC/D,mDAAwE;AACxE,2CAA6C;AAC7C,uDAA0D;AAC1D,mDAAgD;AAChD,qDAAkD;AAClD,6CAA4D;AAC5D,2CAA+D;AAE/D,MAAM,kBAAkB,GAAG,CAAC,IAAY,EAAE,OAAe,EAAU,EAAE,CAAC,cAAI,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,EAAE,OAAO,CAAC,CAAC;AAE9H,2EAA2E;AAC3E,4EAA4E;AAC5E,8EAA8E;AAC9E,6BAA6B;AAC7B,EAAE;AACF,2EAA2E;AAC3E,2EAA2E;AAC3E,8EAA8E;AAC9E,MAAM,qBAAqB,GAAG,CAAC,IAAY,EAAE,UAAkB,EAAQ,EAAE;;IACvE,MAAM,eAAe,GAAG,IAAI,CAAC,K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AE,cAAI,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAC9F,IAAI,WAAW,KAAK,OAAO,EAAE,CAAC;YAC5B,YAAE,CAAC,MAAM,CAAC,SAAS,EAAE,cAAI,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACrF,CAAC;IACH,CAAC;IAED,4BAA4B;IAC5B,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;IACrC,MAAM,IAAA,uBAAU,EAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC;IAElE,IAAA,mBAAU,EAAC,WAAW,CAAC,CAAC;IAExB,OAAO,CAAC,GAAG,CAAC;;;;aAID,OAAO;MACd,QAAQ;;;;CAIb,CAAC,CAAC;AACH,CAAC,CAAA,CAAC;AAjFW,QAAA,QAAQ,YAiFnB","sourcesContent":["// Docker platform deploy (`qpq go` with platform 'docker') — proof-of-concept\n// self-hosting: bakes the QPQ dev server (a full local platform emulation)\n// plus every service of the app and its pre-built views into one docker image.\n//\n// 1. Build workspace packages, then the dev-server bundle (all services).\n// 2. Build every views microfrontend with a same-origin module-federation\n// remote base (/views/<svc>), mirroring the AWS website/views layout.\n// 3. Assemble an image context under dist/qpq/docker-image/<app>/ — server\n// bundle, web root, a workspaces-stripped package.json for runtime deps,\n// and the locally-built quidproquo packages as a vendor overlay.\n// 4. docker build, then print the run command.\n//\n// Not production-grade (single process, sqlite KVS, in-memory queues) —\n// it's the whole product on one box with one command.\nimport { getAppServiceQpqConfigs, getDevServerRspackConfig } from 'quidproquo-deploy-rspack';\n\nimport fs from 'fs';\nimport path from 'path';\n\nimport { DeployPlan } from '../../lib/deployPrompts';\nimport { writeDevServerEntry } from '../../lib/devServerEntry';\nimport { getRoot, getServiceNamesWithViews } from '../../lib/discovery';\nimport { runAppHook } from '../../lib/hooks';\nimport { getOwnPackageRoot } from '../../lib/packageRoot';\nimport { runRspack } from '../../lib/rspackRun';\nimport { runCommand } from '../../lib/runCommand';\nimport { logTimeEnd, logTimeStart } from '../../lib/timing';\nimport { bundleViews, getViewsDistDir } from '../../lib/views';\n\nconst getImageContextDir = (root: string, appName: string): string => path.join(root, 'dist', 'qpq', 'docker-image', appName);\n\n// The consumer root package.json, stripped to what the image's npm install\n// needs: runtime dependencies (+ overrides). Workspaces/scripts/devDeps are\n// host-only concerns — the workspace packages themselves are bundled into the\n// server bundle from source.\n//\n// quidproquo deps declared as file: refs (a consumer living beside the qpq\n// monorepo) point outside the image context, where npm install would leave\n// dangling symlinks — rewrite them to the vendored copies inside the context.\nconst writeImagePackageJson = (root: string, contextDir: string): void => {\n const rootPackageJson = JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8'));\n\n const dependencies: Record<string, string> = { ...(rootPackageJson.dependencies ?? {}) };\n for (const [name, version] of Object.entries(dependencies)) {\n if (name.startsWith('quidproquo') && version.startsWith('file:')) {\n dependencies[name] = `file:./vendor/${name}`;\n }\n }\n\n const imagePackageJson = {\n name: `${rootPackageJson.name}-qpq-docker`,\n version: rootPackageJson.version ?? '0.0.0',\n private: true,\n dependencies,\n overrides: rootPackageJson.overrides,\n };\n\n fs.writeFileSync(path.join(contextDir, 'package.json'), JSON.stringify(imagePackageJson, null, 2) + '\\n');\n};\n\n// Copy the locally-built quidproquo packages (which may be npm-linked\n// checkouts newer than the registry) into vendor/ so the image runs the same\n// qpq code the bundle was built against. Follows the node_modules symlinks;\n// lib/config only — no node_modules, no src.\nconst vendorQuidproquoPackages = (root: string, contextDir: string): number => {\n const nodeModules = path.join(root, 'node_modules');\n const vendorDir = path.join(contextDir, 'vendor');\n let vendored = 0;\n\n for (const name of fs.readdirSync(nodeModules)) {\n if (!name.startsWith('quidproquo')) continue;\n\n const packageDir = fs.realpathSync(path.join(nodeModules, name));\n const targetDir = path.join(vendorDir, name);\n fs.mkdirSync(targetDir, { recursive: true });\n\n fs.copyFileSync(path.join(packageDir, 'package.json'), path.join(targetDir, 'package.json'));\n for (const sub of ['lib', 'config']) {\n const subDir = path.join(packageDir, sub);\n if (fs.existsSync(subDir)) {\n fs.cpSync(subDir, path.join(targetDir, sub), { recursive: true, dereference: true });\n }\n }\n vendored += 1;\n }\n\n return vendored;\n};\n\nexport const dockerGo = async (appName: string, plan: DeployPlan): Promise<void> => {\n if (plan.kind === 'cancelled') {\n return;\n }\n\n if (plan.kind === 'account' || plan.kind === 'bootstrap') {\n console.log(`Nothing to do — the docker platform has no ${plan.kind} stacks.`);\n return;\n }\n\n const root = getRoot();\n const imageTag = `qpq-${appName}:${process.env.ENVIRONMENT}`;\n\n // The dev server hosts every service of the app, so per-service/stack\n // selections don't apply — the image is always the whole app.\n console.log(`\\n\\nBuilding docker image [${imageTag}] — the whole app deploys as one image\\n\\n`);\n\n logTimeStart('totalTime');\n\n await runAppHook(appName, 'predeploy');\n\n // Workspace packages resolve through their built dist/ (package.json main),\n // so bundles would ship stale code unless every lib is tsc'd first.\n console.log('Building workspace packages');\n await runCommand('npm', ['run', 'build', '--workspaces', '--if-present']);\n\n // ---- Server bundle: the dev server + every service, one main.js ----\n console.log('Bundling server (dev server + all services)');\n const qpqConfigs = getAppServiceQpqConfigs(root, appName);\n const entry = writeDevServerEntry(root, appName);\n await runRspack(getDevServerRspackConfig({ root, entry, qpqConfigs }));\n\n // ---- Views: production builds with same-origin federation remotes ----\n process.env.QPQ_VIEWS_REMOTE_BASE = '/views';\n const viewServices = getServiceNamesWithViews(appName);\n for (const serviceName of viewServices) {\n console.log(`Bundling views: [${serviceName}]`);\n await bundleViews(appName, serviceName);\n }\n delete process.env.QPQ_VIEWS_REMOTE_BASE;\n\n // ---- Assemble the image context ----\n console.log('Assembling image context');\n const contextDir = getImageContextDir(root, appName);\n fs.rmSync(contextDir, { recursive: true, force: true });\n fs.mkdirSync(contextDir, { recursive: true });\n\n fs.copyFileSync(path.join(getOwnPackageRoot(), 'docker', 'dev-server', 'Dockerfile'), path.join(contextDir, 'Dockerfile'));\n writeImagePackageJson(root, contextDir);\n\n const vendored = vendorQuidproquoPackages(root, contextDir);\n console.log(`Vendored ${vendored} quidproquo packages`);\n\n fs.cpSync(path.join(root, 'dist', 'qpq', 'dev-server'), path.join(contextDir, 'server'), { recursive: true });\n\n // Web root mirrors the AWS buckets: shell at website/, every views build\n // (shell included) under views/<svc>/.\n for (const serviceName of viewServices) {\n const viewsDist = getViewsDistDir(appName, serviceName);\n fs.cpSync(viewsDist, path.join(contextDir, 'web', 'views', serviceName), { recursive: true });\n if (serviceName === 'shell') {\n fs.cpSync(viewsDist, path.join(contextDir, 'web', 'website'), { recursive: true });\n }\n }\n\n // ---- Build the image ----\n console.log('Building docker image');\n await runCommand('docker', ['build', '-t', imageTag, contextDir]);\n\n logTimeEnd('totalTime');\n\n console.log(`\nDone. Run it with:\n\n docker run --rm -p 80:8080 -p 8080:8080 -p 8888:8888 -p 3001:3001 \\\\\n -v qpq-${appName}-data:/app/.qpq-runtime \\\\\n ${imageTag}\n\nThen open http://localhost\n(80 serves the shell; 8080 stays mapped because the app's url resolvers call localhost:8080 for apis)\n`);\n};\n"]}
@@ -10,7 +10,7 @@
10
10
  // and the locally-built quidproquo packages as a vendor overlay.
11
11
  // 4. docker build, then print the run command.
12
12
  //
13
- // Not production-grade (single process, JSON-file KVS, in-memory queues) —
13
+ // Not production-grade (single process, sqlite KVS, in-memory queues) —
14
14
  // it's the whole product on one box with one command.
15
15
  import { getAppServiceQpqConfigs, getDevServerRspackConfig } from 'quidproquo-deploy-rspack';
16
16
  import fs from 'fs';
@@ -1 +1 @@
1
- {"version":3,"file":"go.js","sourceRoot":"","sources":["../../../../src/platforms/docker/go.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,2EAA2E;AAC3E,+EAA+E;AAC/E,EAAE;AACF,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E,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACrF,CAAC;IACH,CAAC;IAED,4BAA4B;IAC5B,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;IACrC,MAAM,UAAU,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC;IAElE,UAAU,CAAC,WAAW,CAAC,CAAC;IAExB,OAAO,CAAC,GAAG,CAAC;;;;aAID,OAAO;MACd,QAAQ;;;;CAIb,CAAC,CAAC;AACH,CAAC,CAAC","sourcesContent":["// Docker platform deploy (`qpq go` with platform 'docker') — proof-of-concept\n// self-hosting: bakes the QPQ dev server (a full local platform emulation)\n// plus every service of the app and its pre-built views into one docker image.\n//\n// 1. Build workspace packages, then the dev-server bundle (all services).\n// 2. Build every views microfrontend with a same-origin module-federation\n// remote base (/views/<svc>), mirroring the AWS website/views layout.\n// 3. Assemble an image context under dist/qpq/docker-image/<app>/ — server\n// bundle, web root, a workspaces-stripped package.json for runtime deps,\n// and the locally-built quidproquo packages as a vendor overlay.\n// 4. docker build, then print the run command.\n//\n// Not production-grade (single process, JSON-file KVS, in-memory queues) —\n// it's the whole product on one box with one command.\nimport { getAppServiceQpqConfigs, getDevServerRspackConfig } from 'quidproquo-deploy-rspack';\n\nimport fs from 'fs';\nimport path from 'path';\n\nimport { DeployPlan } from '../../lib/deployPrompts';\nimport { writeDevServerEntry } from '../../lib/devServerEntry';\nimport { getRoot, getServiceNamesWithViews } from '../../lib/discovery';\nimport { runAppHook } from '../../lib/hooks';\nimport { getOwnPackageRoot } from '../../lib/packageRoot';\nimport { runRspack } from '../../lib/rspackRun';\nimport { runCommand } from '../../lib/runCommand';\nimport { logTimeEnd, logTimeStart } from '../../lib/timing';\nimport { bundleViews, getViewsDistDir } from '../../lib/views';\n\nconst getImageContextDir = (root: string, appName: string): string => path.join(root, 'dist', 'qpq', 'docker-image', appName);\n\n// The consumer root package.json, stripped to what the image's npm install\n// needs: runtime dependencies (+ overrides). Workspaces/scripts/devDeps are\n// host-only concerns — the workspace packages themselves are bundled into the\n// server bundle from source.\n//\n// quidproquo deps declared as file: refs (a consumer living beside the qpq\n// monorepo) point outside the image context, where npm install would leave\n// dangling symlinks — rewrite them to the vendored copies inside the context.\nconst writeImagePackageJson = (root: string, contextDir: string): void => {\n const rootPackageJson = JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8'));\n\n const dependencies: Record<string, string> = { ...(rootPackageJson.dependencies ?? {}) };\n for (const [name, version] of Object.entries(dependencies)) {\n if (name.startsWith('quidproquo') && version.startsWith('file:')) {\n dependencies[name] = `file:./vendor/${name}`;\n }\n }\n\n const imagePackageJson = {\n name: `${rootPackageJson.name}-qpq-docker`,\n version: rootPackageJson.version ?? '0.0.0',\n private: true,\n dependencies,\n overrides: rootPackageJson.overrides,\n };\n\n fs.writeFileSync(path.join(contextDir, 'package.json'), JSON.stringify(imagePackageJson, null, 2) + '\\n');\n};\n\n// Copy the locally-built quidproquo packages (which may be npm-linked\n// checkouts newer than the registry) into vendor/ so the image runs the same\n// qpq code the bundle was built against. Follows the node_modules symlinks;\n// lib/config only — no node_modules, no src.\nconst vendorQuidproquoPackages = (root: string, contextDir: string): number => {\n const nodeModules = path.join(root, 'node_modules');\n const vendorDir = path.join(contextDir, 'vendor');\n let vendored = 0;\n\n for (const name of fs.readdirSync(nodeModules)) {\n if (!name.startsWith('quidproquo')) continue;\n\n const packageDir = fs.realpathSync(path.join(nodeModules, name));\n const targetDir = path.join(vendorDir, name);\n fs.mkdirSync(targetDir, { recursive: true });\n\n fs.copyFileSync(path.join(packageDir, 'package.json'), path.join(targetDir, 'package.json'));\n for (const sub of ['lib', 'config']) {\n const subDir = path.join(packageDir, sub);\n if (fs.existsSync(subDir)) {\n fs.cpSync(subDir, path.join(targetDir, sub), { recursive: true, dereference: true });\n }\n }\n vendored += 1;\n }\n\n return vendored;\n};\n\nexport const dockerGo = async (appName: string, plan: DeployPlan): Promise<void> => {\n if (plan.kind === 'cancelled') {\n return;\n }\n\n if (plan.kind === 'account' || plan.kind === 'bootstrap') {\n console.log(`Nothing to do — the docker platform has no ${plan.kind} stacks.`);\n return;\n }\n\n const root = getRoot();\n const imageTag = `qpq-${appName}:${process.env.ENVIRONMENT}`;\n\n // The dev server hosts every service of the app, so per-service/stack\n // selections don't apply — the image is always the whole app.\n console.log(`\\n\\nBuilding docker image [${imageTag}] — the whole app deploys as one image\\n\\n`);\n\n logTimeStart('totalTime');\n\n await runAppHook(appName, 'predeploy');\n\n // Workspace packages resolve through their built dist/ (package.json main),\n // so bundles would ship stale code unless every lib is tsc'd first.\n console.log('Building workspace packages');\n await runCommand('npm', ['run', 'build', '--workspaces', '--if-present']);\n\n // ---- Server bundle: the dev server + every service, one main.js ----\n console.log('Bundling server (dev server + all services)');\n const qpqConfigs = getAppServiceQpqConfigs(root, appName);\n const entry = writeDevServerEntry(root, appName);\n await runRspack(getDevServerRspackConfig({ root, entry, qpqConfigs }));\n\n // ---- Views: production builds with same-origin federation remotes ----\n process.env.QPQ_VIEWS_REMOTE_BASE = '/views';\n const viewServices = getServiceNamesWithViews(appName);\n for (const serviceName of viewServices) {\n console.log(`Bundling views: [${serviceName}]`);\n await bundleViews(appName, serviceName);\n }\n delete process.env.QPQ_VIEWS_REMOTE_BASE;\n\n // ---- Assemble the image context ----\n console.log('Assembling image context');\n const contextDir = getImageContextDir(root, appName);\n fs.rmSync(contextDir, { recursive: true, force: true });\n fs.mkdirSync(contextDir, { recursive: true });\n\n fs.copyFileSync(path.join(getOwnPackageRoot(), 'docker', 'dev-server', 'Dockerfile'), path.join(contextDir, 'Dockerfile'));\n writeImagePackageJson(root, contextDir);\n\n const vendored = vendorQuidproquoPackages(root, contextDir);\n console.log(`Vendored ${vendored} quidproquo packages`);\n\n fs.cpSync(path.join(root, 'dist', 'qpq', 'dev-server'), path.join(contextDir, 'server'), { recursive: true });\n\n // Web root mirrors the AWS buckets: shell at website/, every views build\n // (shell included) under views/<svc>/.\n for (const serviceName of viewServices) {\n const viewsDist = getViewsDistDir(appName, serviceName);\n fs.cpSync(viewsDist, path.join(contextDir, 'web', 'views', serviceName), { recursive: true });\n if (serviceName === 'shell') {\n fs.cpSync(viewsDist, path.join(contextDir, 'web', 'website'), { recursive: true });\n }\n }\n\n // ---- Build the image ----\n console.log('Building docker image');\n await runCommand('docker', ['build', '-t', imageTag, contextDir]);\n\n logTimeEnd('totalTime');\n\n console.log(`\nDone. Run it with:\n\n docker run --rm -p 80:8080 -p 8080:8080 -p 8888:8888 -p 3001:3001 \\\\\n -v qpq-${appName}-data:/app/.qpq-runtime \\\\\n ${imageTag}\n\nThen open http://localhost\n(80 serves the shell; 8080 stays mapped because the app's url resolvers call localhost:8080 for apis)\n`);\n};\n"]}
1
+ {"version":3,"file":"go.js","sourceRoot":"","sources":["../../../../src/platforms/docker/go.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,2EAA2E;AAC3E,+EAA+E;AAC/E,EAAE;AACF,4EAA4E;AAC5E,4EAA4E;AAC5E,2EAA2E;AAC3E,6EAA6E;AAC7E,8EAA8E;AAC9E,sEAAsE;AACtE,iDAAiD;AACjD,EAAE;AACF,wEAAwE;AACxE,sDAAsD;AACtD,OAAO,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AAE7F,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;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of-concept\n// self-hosting: bakes the QPQ dev server (a full local platform emulation)\n// plus every service of the app and its pre-built views into one docker image.\n//\n// 1. Build workspace packages, then the dev-server bundle (all services).\n// 2. Build every views microfrontend with a same-origin module-federation\n// remote base (/views/<svc>), mirroring the AWS website/views layout.\n// 3. Assemble an image context under dist/qpq/docker-image/<app>/ — server\n// bundle, web root, a workspaces-stripped package.json for runtime deps,\n// and the locally-built quidproquo packages as a vendor overlay.\n// 4. docker build, then print the run command.\n//\n// Not production-grade (single process, sqlite KVS, in-memory queues) —\n// it's the whole product on one box with one command.\nimport { getAppServiceQpqConfigs, getDevServerRspackConfig } from 'quidproquo-deploy-rspack';\n\nimport fs from 'fs';\nimport path from 'path';\n\nimport { DeployPlan } from '../../lib/deployPrompts';\nimport { writeDevServerEntry } from '../../lib/devServerEntry';\nimport { getRoot, getServiceNamesWithViews } from '../../lib/discovery';\nimport { runAppHook } from '../../lib/hooks';\nimport { getOwnPackageRoot } from '../../lib/packageRoot';\nimport { runRspack } from '../../lib/rspackRun';\nimport { runCommand } from '../../lib/runCommand';\nimport { logTimeEnd, logTimeStart } from '../../lib/timing';\nimport { bundleViews, getViewsDistDir } from '../../lib/views';\n\nconst getImageContextDir = (root: string, appName: string): string => path.join(root, 'dist', 'qpq', 'docker-image', appName);\n\n// The consumer root package.json, stripped to what the image's npm install\n// needs: runtime dependencies (+ overrides). Workspaces/scripts/devDeps are\n// host-only concerns — the workspace packages themselves are bundled into the\n// server bundle from source.\n//\n// quidproquo deps declared as file: refs (a consumer living beside the qpq\n// monorepo) point outside the image context, where npm install would leave\n// dangling symlinks — rewrite them to the vendored copies inside the context.\nconst writeImagePackageJson = (root: string, contextDir: string): void => {\n const rootPackageJson = JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8'));\n\n const dependencies: Record<string, string> = { ...(rootPackageJson.dependencies ?? {}) };\n for (const [name, version] of Object.entries(dependencies)) {\n if (name.startsWith('quidproquo') && version.startsWith('file:')) {\n dependencies[name] = `file:./vendor/${name}`;\n }\n }\n\n const imagePackageJson = {\n name: `${rootPackageJson.name}-qpq-docker`,\n version: rootPackageJson.version ?? '0.0.0',\n private: true,\n dependencies,\n overrides: rootPackageJson.overrides,\n };\n\n fs.writeFileSync(path.join(contextDir, 'package.json'), JSON.stringify(imagePackageJson, null, 2) + '\\n');\n};\n\n// Copy the locally-built quidproquo packages (which may be npm-linked\n// checkouts newer than the registry) into vendor/ so the image runs the same\n// qpq code the bundle was built against. Follows the node_modules symlinks;\n// lib/config only — no node_modules, no src.\nconst vendorQuidproquoPackages = (root: string, contextDir: string): number => {\n const nodeModules = path.join(root, 'node_modules');\n const vendorDir = path.join(contextDir, 'vendor');\n let vendored = 0;\n\n for (const name of fs.readdirSync(nodeModules)) {\n if (!name.startsWith('quidproquo')) continue;\n\n const packageDir = fs.realpathSync(path.join(nodeModules, name));\n const targetDir = path.join(vendorDir, name);\n fs.mkdirSync(targetDir, { recursive: true });\n\n fs.copyFileSync(path.join(packageDir, 'package.json'), path.join(targetDir, 'package.json'));\n for (const sub of ['lib', 'config']) {\n const subDir = path.join(packageDir, sub);\n if (fs.existsSync(subDir)) {\n fs.cpSync(subDir, path.join(targetDir, sub), { recursive: true, dereference: true });\n }\n }\n vendored += 1;\n }\n\n return vendored;\n};\n\nexport const dockerGo = async (appName: string, plan: DeployPlan): Promise<void> => {\n if (plan.kind === 'cancelled') {\n return;\n }\n\n if (plan.kind === 'account' || plan.kind === 'bootstrap') {\n console.log(`Nothing to do — the docker platform has no ${plan.kind} stacks.`);\n return;\n }\n\n const root = getRoot();\n const imageTag = `qpq-${appName}:${process.env.ENVIRONMENT}`;\n\n // The dev server hosts every service of the app, so per-service/stack\n // selections don't apply — the image is always the whole app.\n console.log(`\\n\\nBuilding docker image [${imageTag}] — the whole app deploys as one image\\n\\n`);\n\n logTimeStart('totalTime');\n\n await runAppHook(appName, 'predeploy');\n\n // Workspace packages resolve through their built dist/ (package.json main),\n // so bundles would ship stale code unless every lib is tsc'd first.\n console.log('Building workspace packages');\n await runCommand('npm', ['run', 'build', '--workspaces', '--if-present']);\n\n // ---- Server bundle: the dev server + every service, one main.js ----\n console.log('Bundling server (dev server + all services)');\n const qpqConfigs = getAppServiceQpqConfigs(root, appName);\n const entry = writeDevServerEntry(root, appName);\n await runRspack(getDevServerRspackConfig({ root, entry, qpqConfigs }));\n\n // ---- Views: production builds with same-origin federation remotes ----\n process.env.QPQ_VIEWS_REMOTE_BASE = '/views';\n const viewServices = getServiceNamesWithViews(appName);\n for (const serviceName of viewServices) {\n console.log(`Bundling views: [${serviceName}]`);\n await bundleViews(appName, serviceName);\n }\n delete process.env.QPQ_VIEWS_REMOTE_BASE;\n\n // ---- Assemble the image context ----\n console.log('Assembling image context');\n const contextDir = getImageContextDir(root, appName);\n fs.rmSync(contextDir, { recursive: true, force: true });\n fs.mkdirSync(contextDir, { recursive: true });\n\n fs.copyFileSync(path.join(getOwnPackageRoot(), 'docker', 'dev-server', 'Dockerfile'), path.join(contextDir, 'Dockerfile'));\n writeImagePackageJson(root, contextDir);\n\n const vendored = vendorQuidproquoPackages(root, contextDir);\n console.log(`Vendored ${vendored} quidproquo packages`);\n\n fs.cpSync(path.join(root, 'dist', 'qpq', 'dev-server'), path.join(contextDir, 'server'), { recursive: true });\n\n // Web root mirrors the AWS buckets: shell at website/, every views build\n // (shell included) under views/<svc>/.\n for (const serviceName of viewServices) {\n const viewsDist = getViewsDistDir(appName, serviceName);\n fs.cpSync(viewsDist, path.join(contextDir, 'web', 'views', serviceName), { recursive: true });\n if (serviceName === 'shell') {\n fs.cpSync(viewsDist, path.join(contextDir, 'web', 'website'), { recursive: true });\n }\n }\n\n // ---- Build the image ----\n console.log('Building docker image');\n await runCommand('docker', ['build', '-t', imageTag, contextDir]);\n\n logTimeEnd('totalTime');\n\n console.log(`\nDone. Run it with:\n\n docker run --rm -p 80:8080 -p 8080:8080 -p 8888:8888 -p 3001:3001 \\\\\n -v qpq-${appName}-data:/app/.qpq-runtime \\\\\n ${imageTag}\n\nThen open http://localhost\n(80 serves the shell; 8080 stays mapped because the app's url resolvers call localhost:8080 for apis)\n`);\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quidproquo-cli",
3
- "version": "0.1.16",
3
+ "version": "0.1.17",
4
4
  "description": "The qpq CLI — build, dev and deploy orchestration for QPQ apps",
5
5
  "main": "./lib/commonjs/index.js",
6
6
  "module": "./lib/esm/index.js",
@@ -10,6 +10,9 @@
10
10
  "lib/**/*",
11
11
  "docker/**/*"
12
12
  ],
13
+ "publishConfig": {
14
+ "access": "public"
15
+ },
13
16
  "scripts": {
14
17
  "test": "echo \"Error: no test specified\" && exit 1",
15
18
  "clean": "npx rimraf lib && npx rimraf node_modules",
@@ -24,15 +27,15 @@
24
27
  },
25
28
  "repository": {
26
29
  "type": "git",
27
- "url": "git+https://github.com/joe-coady/quidproquo.git"
30
+ "url": "git+https://github.com/qpqjs/quidproquo.git"
28
31
  },
29
32
  "keywords": [],
30
33
  "author": "",
31
34
  "license": "MIT",
32
35
  "bugs": {
33
- "url": "https://github.com/joe-coady/quidproquo/issues"
36
+ "url": "https://github.com/qpqjs/quidproquo/issues"
34
37
  },
35
- "homepage": "https://github.com/joe-coady/quidproquo#readme",
38
+ "homepage": "https://github.com/qpqjs/quidproquo#readme",
36
39
  "dependencies": {
37
40
  "@aws-sdk/client-dynamodb": "^3.1093.0",
38
41
  "@aws-sdk/client-s3": "^3.1093.0",
@@ -41,21 +44,21 @@
41
44
  "@rspack/dev-server": "^2.1.0",
42
45
  "aws-cdk": "^2.1132.1",
43
46
  "madge": "^8.0.0",
44
- "quidproquo": "0.1.16",
45
- "quidproquo-actionprocessor-awslambda": "0.1.16",
46
- "quidproquo-config-aws": "0.1.16",
47
- "quidproquo-core": "0.1.16",
48
- "quidproquo-deploy-awscdk": "0.1.16",
49
- "quidproquo-deploy-rspack": "0.1.16",
50
- "quidproquo-dev-server": "0.1.16",
51
- "quidproquo-webserver": "0.1.16",
47
+ "quidproquo": "0.1.17",
48
+ "quidproquo-actionprocessor-awslambda": "0.1.17",
49
+ "quidproquo-config-aws": "0.1.17",
50
+ "quidproquo-core": "0.1.17",
51
+ "quidproquo-deploy-awscdk": "0.1.17",
52
+ "quidproquo-deploy-rspack": "0.1.17",
53
+ "quidproquo-dev-server": "0.1.17",
54
+ "quidproquo-webserver": "0.1.17",
52
55
  "ts-node": "^10.9.1",
53
56
  "typescript": "^5.8.2"
54
57
  },
55
58
  "devDependencies": {
56
59
  "@rspack/core": "^2.1.2",
57
60
  "@types/node": "^22.13.13",
58
- "quidproquo-tsconfig": "0.1.16"
61
+ "quidproquo-tsconfig": "0.1.17"
59
62
  },
60
63
  "bin": {
61
64
  "qpq": "./lib/commonjs/bin/qpq.js"