quidproquo-cli 0.1.7 → 0.1.9

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 (130) hide show
  1. package/docker/dev-server/Dockerfile +7 -9
  2. package/lib/commonjs/cli/commandMenu.d.ts +2 -0
  3. package/lib/commonjs/cli/commandMenu.js +81 -0
  4. package/lib/commonjs/cli/commandMenu.js.map +1 -0
  5. package/lib/commonjs/cli/commandRegistry.d.ts +10 -0
  6. package/lib/commonjs/cli/commandRegistry.js +131 -0
  7. package/lib/commonjs/cli/commandRegistry.js.map +1 -0
  8. package/lib/commonjs/cli/runCli.js +49 -51
  9. package/lib/commonjs/cli/runCli.js.map +1 -1
  10. package/lib/commonjs/commands/clearResources.d.ts +1 -0
  11. package/lib/commonjs/commands/clearResources.js +36 -0
  12. package/lib/commonjs/commands/clearResources.js.map +1 -0
  13. package/lib/commonjs/commands/go.js +3 -1
  14. package/lib/commonjs/commands/go.js.map +1 -1
  15. package/lib/commonjs/commands/goDev.js +11 -2
  16. package/lib/commonjs/commands/goDev.js.map +1 -1
  17. package/lib/commonjs/commands/goDevApi.js +6 -39
  18. package/lib/commonjs/commands/goDevApi.js.map +1 -1
  19. package/lib/commonjs/commands/goDevWeb.js +2 -0
  20. package/lib/commonjs/commands/goDevWeb.js.map +1 -1
  21. package/lib/commonjs/commands/goDocker.js +3 -1
  22. package/lib/commonjs/commands/goDocker.js.map +1 -1
  23. package/lib/commonjs/commands/hooks.js +23 -5
  24. package/lib/commonjs/commands/hooks.js.map +1 -1
  25. package/lib/commonjs/lib/clearResourcesPlan.d.ts +15 -0
  26. package/lib/commonjs/lib/clearResourcesPlan.js +80 -0
  27. package/lib/commonjs/lib/clearResourcesPlan.js.map +1 -0
  28. package/lib/commonjs/lib/deployPrompts.d.ts +1 -0
  29. package/lib/commonjs/lib/deployPrompts.js +40 -2
  30. package/lib/commonjs/lib/deployPrompts.js.map +1 -1
  31. package/lib/commonjs/lib/devServerEntry.js +3 -0
  32. package/lib/commonjs/lib/devServerEntry.js.map +1 -1
  33. package/lib/commonjs/lib/hooks.d.ts +2 -1
  34. package/lib/commonjs/lib/hooks.js +100 -5
  35. package/lib/commonjs/lib/hooks.js.map +1 -1
  36. package/lib/commonjs/lib/killStaleListeners.d.ts +3 -0
  37. package/lib/commonjs/lib/killStaleListeners.js +170 -0
  38. package/lib/commonjs/lib/killStaleListeners.js.map +1 -0
  39. package/lib/commonjs/lib/prompts.d.ts +10 -0
  40. package/lib/commonjs/lib/prompts.js +15 -1
  41. package/lib/commonjs/lib/prompts.js.map +1 -1
  42. package/lib/commonjs/lib/qpqConfigs.d.ts +1 -0
  43. package/lib/commonjs/lib/qpqConfigs.js +9 -1
  44. package/lib/commonjs/lib/qpqConfigs.js.map +1 -1
  45. package/lib/commonjs/lib/runTasks.d.ts +5 -0
  46. package/lib/commonjs/lib/runTasks.js +82 -1
  47. package/lib/commonjs/lib/runTasks.js.map +1 -1
  48. package/lib/commonjs/lib/typeWatcher.d.ts +2 -0
  49. package/lib/commonjs/lib/typeWatcher.js +59 -0
  50. package/lib/commonjs/lib/typeWatcher.js.map +1 -0
  51. package/lib/commonjs/platforms/aws/cdkApp.js +5 -1
  52. package/lib/commonjs/platforms/aws/cdkApp.js.map +1 -1
  53. package/lib/commonjs/platforms/aws/clearResources.d.ts +2 -0
  54. package/lib/commonjs/platforms/aws/clearResources.js +167 -0
  55. package/lib/commonjs/platforms/aws/clearResources.js.map +1 -0
  56. package/lib/commonjs/platforms/aws/go.js +15 -1
  57. package/lib/commonjs/platforms/aws/go.js.map +1 -1
  58. package/lib/commonjs/platforms/aws/goDocker.js +76 -8
  59. package/lib/commonjs/platforms/aws/goDocker.js.map +1 -1
  60. package/lib/commonjs/platforms/aws/index.js +2 -0
  61. package/lib/commonjs/platforms/aws/index.js.map +1 -1
  62. package/lib/commonjs/platforms/docker/go.js +2 -2
  63. package/lib/commonjs/platforms/docker/go.js.map +1 -1
  64. package/lib/commonjs/platforms/types.d.ts +2 -0
  65. package/lib/commonjs/platforms/types.js.map +1 -1
  66. package/lib/esm/cli/commandMenu.d.ts +2 -0
  67. package/lib/esm/cli/commandMenu.js +67 -0
  68. package/lib/esm/cli/commandMenu.js.map +1 -0
  69. package/lib/esm/cli/commandRegistry.d.ts +10 -0
  70. package/lib/esm/cli/commandRegistry.js +115 -0
  71. package/lib/esm/cli/commandRegistry.js.map +1 -0
  72. package/lib/esm/cli/runCli.js +49 -51
  73. package/lib/esm/cli/runCli.js.map +1 -1
  74. package/lib/esm/commands/clearResources.d.ts +1 -0
  75. package/lib/esm/commands/clearResources.js +23 -0
  76. package/lib/esm/commands/clearResources.js.map +1 -0
  77. package/lib/esm/commands/go.js +3 -2
  78. package/lib/esm/commands/go.js.map +1 -1
  79. package/lib/esm/commands/goDev.js +11 -2
  80. package/lib/esm/commands/goDev.js.map +1 -1
  81. package/lib/esm/commands/goDevApi.js +7 -40
  82. package/lib/esm/commands/goDevApi.js.map +1 -1
  83. package/lib/esm/commands/goDevWeb.js +2 -0
  84. package/lib/esm/commands/goDevWeb.js.map +1 -1
  85. package/lib/esm/commands/goDocker.js +3 -2
  86. package/lib/esm/commands/goDocker.js.map +1 -1
  87. package/lib/esm/commands/hooks.js +21 -6
  88. package/lib/esm/commands/hooks.js.map +1 -1
  89. package/lib/esm/lib/clearResourcesPlan.d.ts +15 -0
  90. package/lib/esm/lib/clearResourcesPlan.js +66 -0
  91. package/lib/esm/lib/clearResourcesPlan.js.map +1 -0
  92. package/lib/esm/lib/deployPrompts.d.ts +1 -0
  93. package/lib/esm/lib/deployPrompts.js +38 -1
  94. package/lib/esm/lib/deployPrompts.js.map +1 -1
  95. package/lib/esm/lib/devServerEntry.js +3 -0
  96. package/lib/esm/lib/devServerEntry.js.map +1 -1
  97. package/lib/esm/lib/hooks.d.ts +2 -1
  98. package/lib/esm/lib/hooks.js +97 -5
  99. package/lib/esm/lib/hooks.js.map +1 -1
  100. package/lib/esm/lib/killStaleListeners.d.ts +3 -0
  101. package/lib/esm/lib/killStaleListeners.js +161 -0
  102. package/lib/esm/lib/killStaleListeners.js.map +1 -0
  103. package/lib/esm/lib/prompts.d.ts +10 -0
  104. package/lib/esm/lib/prompts.js +12 -0
  105. package/lib/esm/lib/prompts.js.map +1 -1
  106. package/lib/esm/lib/qpqConfigs.d.ts +1 -0
  107. package/lib/esm/lib/qpqConfigs.js +7 -0
  108. package/lib/esm/lib/qpqConfigs.js.map +1 -1
  109. package/lib/esm/lib/runTasks.d.ts +5 -0
  110. package/lib/esm/lib/runTasks.js +80 -0
  111. package/lib/esm/lib/runTasks.js.map +1 -1
  112. package/lib/esm/lib/typeWatcher.d.ts +2 -0
  113. package/lib/esm/lib/typeWatcher.js +51 -0
  114. package/lib/esm/lib/typeWatcher.js.map +1 -0
  115. package/lib/esm/platforms/aws/cdkApp.js +5 -1
  116. package/lib/esm/platforms/aws/cdkApp.js.map +1 -1
  117. package/lib/esm/platforms/aws/clearResources.d.ts +2 -0
  118. package/lib/esm/platforms/aws/clearResources.js +151 -0
  119. package/lib/esm/platforms/aws/clearResources.js.map +1 -0
  120. package/lib/esm/platforms/aws/go.js +16 -2
  121. package/lib/esm/platforms/aws/go.js.map +1 -1
  122. package/lib/esm/platforms/aws/goDocker.js +77 -9
  123. package/lib/esm/platforms/aws/goDocker.js.map +1 -1
  124. package/lib/esm/platforms/aws/index.js +2 -0
  125. package/lib/esm/platforms/aws/index.js.map +1 -1
  126. package/lib/esm/platforms/docker/go.js +2 -2
  127. package/lib/esm/platforms/docker/go.js.map +1 -1
  128. package/lib/esm/platforms/types.d.ts +2 -0
  129. package/lib/esm/platforms/types.js.map +1 -1
  130. package/package.json +12 -10
@@ -0,0 +1,59 @@
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.startTypeWatcher = void 0;
7
+ // Keeps workspace packages' declaration output (dist/*.d.ts) fresh while
8
+ // `qpq go:dev` runs. The rspack dev builds bundle workspace source directly,
9
+ // so this watcher only feeds the editor and validate-ts, which resolve
10
+ // cross-package types through each package's built declarations.
11
+ //
12
+ // One `tsc -b --watch` over every workspace package that ships types; routine
13
+ // watch chatter is dropped so only real compile errors reach the shared
14
+ // terminal. Opt out with `--no-types`.
15
+ const quidproquo_deploy_rspack_1 = require("quidproquo-deploy-rspack");
16
+ const child_process_1 = require("child_process");
17
+ const fs_1 = __importDefault(require("fs"));
18
+ const path_1 = __importDefault(require("path"));
19
+ // Routine tsc watch status lines; everything else is worth showing.
20
+ const routineTscPatterns = [/Starting compilation in watch mode/, /File change detected/, /Found 0 errors/];
21
+ const isRoutineTscLine = (line) => routineTscPatterns.some((pattern) => pattern.test(line));
22
+ // Forwards non-routine tsc output line by line under a [types] prefix.
23
+ const forwardTscOutput = (chunk) => {
24
+ for (const line of chunk.toString().split('\n')) {
25
+ if (line.trim().length === 0 || isRoutineTscLine(line)) {
26
+ continue;
27
+ }
28
+ console.log(`[types] ${line}`);
29
+ }
30
+ };
31
+ // A workspace package wants declaration watching when it has a tsconfig and
32
+ // publishes types from its build output. Packages bundled by rspack (views,
33
+ // service handlers) don't ship types and are skipped.
34
+ const isTypedWorkspacePackage = (dir) => {
35
+ if (!fs_1.default.existsSync(path_1.default.join(dir, 'tsconfig.json'))) {
36
+ return false;
37
+ }
38
+ const packageJson = JSON.parse(fs_1.default.readFileSync(path_1.default.join(dir, 'package.json'), 'utf-8'));
39
+ return !!(packageJson.types || packageJson.typings);
40
+ };
41
+ const startTypeWatcher = (root) => {
42
+ var _a, _b;
43
+ const projectDirs = (0, quidproquo_deploy_rspack_1.getWorkspacePackageDirs)(root).filter(isTypedWorkspacePackage);
44
+ if (projectDirs.length === 0) {
45
+ return null;
46
+ }
47
+ const relativeDirs = projectDirs.map((dir) => path_1.default.relative(root, dir));
48
+ const child = (0, child_process_1.spawn)('npx', ['tsc', '-b', ...relativeDirs, '--watch', '--preserveWatchOutput', '--pretty'], {
49
+ cwd: root,
50
+ stdio: ['ignore', 'pipe', 'pipe'],
51
+ shell: process.platform === 'win32',
52
+ });
53
+ (_a = child.stdout) === null || _a === void 0 ? void 0 : _a.on('data', forwardTscOutput);
54
+ (_b = child.stderr) === null || _b === void 0 ? void 0 : _b.on('data', forwardTscOutput);
55
+ console.log(`Type watcher: tsc -b --watch over ${relativeDirs.length} workspace packages (disable with --no-types).`);
56
+ return child;
57
+ };
58
+ exports.startTypeWatcher = startTypeWatcher;
59
+ //# sourceMappingURL=typeWatcher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typeWatcher.js","sourceRoot":"","sources":["../../../src/lib/typeWatcher.ts"],"names":[],"mappings":";;;;;;AAAA,yEAAyE;AACzE,6EAA6E;AAC7E,uEAAuE;AACvE,iEAAiE;AACjE,EAAE;AACF,8EAA8E;AAC9E,wEAAwE;AACxE,uCAAuC;AACvC,uEAAmE;AAEnE,iDAAoD;AACpD,4CAAoB;AACpB,gDAAwB;AAExB,oEAAoE;AACpE,MAAM,kBAAkB,GAAG,CAAC,oCAAoC,EAAE,sBAAsB,EAAE,gBAAgB,CAAC,CAAC;AAE5G,MAAM,gBAAgB,GAAG,CAAC,IAAY,EAAW,EAAE,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AAE7G,uEAAuE;AACvE,MAAM,gBAAgB,GAAG,CAAC,KAAa,EAAQ,EAAE;IAC/C,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QAChD,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,IAAI,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC;YACvD,SAAS;QACX,CAAC;QACD,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,EAAE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,MAAM,0CAAE,EAAE,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IAC3C,MAAA,KAAK,CAAC,MAAM,0CAAE,EAAE,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IAE3C,OAAO,CAAC,GAAG,CAAC,qCAAqC,YAAY,CAAC,MAAM,gDAAgD,CAAC,CAAC;IAEtH,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAnBW,QAAA,gBAAgB,oBAmB3B","sourcesContent":["// Keeps workspace packages' declaration output (dist/*.d.ts) fresh while\n// `qpq go:dev` runs. The rspack dev builds bundle workspace source directly,\n// so this watcher only feeds the editor and validate-ts, which resolve\n// cross-package types through each package's built declarations.\n//\n// One `tsc -b --watch` over every workspace package that ships types; routine\n// watch chatter is dropped so only real compile errors reach the shared\n// terminal. Opt out with `--no-types`.\nimport { getWorkspacePackageDirs } from 'quidproquo-deploy-rspack';\n\nimport { ChildProcess, spawn } from 'child_process';\nimport fs from 'fs';\nimport path from 'path';\n\n// Routine tsc watch status lines; everything else is worth showing.\nconst routineTscPatterns = [/Starting compilation in watch mode/, /File change detected/, /Found 0 errors/];\n\nconst isRoutineTscLine = (line: string): boolean => routineTscPatterns.some((pattern) => pattern.test(line));\n\n// Forwards non-routine tsc output line by line under a [types] prefix.\nconst forwardTscOutput = (chunk: Buffer): void => {\n for (const line of chunk.toString().split('\\n')) {\n if (line.trim().length === 0 || isRoutineTscLine(line)) {\n continue;\n }\n console.log(`[types] ${line}`);\n }\n};\n\n// A workspace package wants declaration watching when it has a tsconfig and\n// publishes types from its build output. Packages bundled by rspack (views,\n// service handlers) don't ship types and are skipped.\nconst isTypedWorkspacePackage = (dir: string): boolean => {\n if (!fs.existsSync(path.join(dir, 'tsconfig.json'))) {\n return false;\n }\n\n const packageJson = JSON.parse(fs.readFileSync(path.join(dir, 'package.json'), 'utf-8'));\n return !!(packageJson.types || packageJson.typings);\n};\n\nexport const startTypeWatcher = (root: string): ChildProcess | null => {\n const projectDirs = getWorkspacePackageDirs(root).filter(isTypedWorkspacePackage);\n if (projectDirs.length === 0) {\n return null;\n }\n\n const relativeDirs = projectDirs.map((dir) => path.relative(root, dir));\n const child = spawn('npx', ['tsc', '-b', ...relativeDirs, '--watch', '--preserveWatchOutput', '--pretty'], {\n cwd: root,\n stdio: ['ignore', 'pipe', 'pipe'],\n shell: process.platform === 'win32',\n });\n\n child.stdout?.on('data', forwardTscOutput);\n child.stderr?.on('data', forwardTscOutput);\n\n console.log(`Type watcher: tsc -b --watch over ${relativeDirs.length} workspace packages (disable with --no-types).`);\n\n return child;\n};\n"]}
@@ -9,8 +9,12 @@ const packageRoot_1 = require("../../lib/packageRoot");
9
9
  // The CDK app command (`cdk ... --app "<this>"`): quidproquo-deploy-awscdk's
10
10
  // generic workspace app under ts-node hooks, with DEPLOY_* in the env.
11
11
  const getCdkAppCommand = () => {
12
+ // Resolve ts-node from this package, not the workspace cwd — under npm link
13
+ // the CLI's dependencies are never hoisted into the workspace's node_modules,
14
+ // so a bare `-r ts-node/...` preload fails there.
15
+ const tsNodeRegister = require.resolve('ts-node/register/transpile-only');
12
16
  const cdkAppScript = path_1.default.join((0, packageRoot_1.getOwnPackageRoot)(), 'lib', 'commonjs', 'bin', 'qpqCdkApp.js');
13
- return `node -r ts-node/register/transpile-only "${cdkAppScript}"`;
17
+ return `node -r "${tsNodeRegister}" "${cdkAppScript}"`;
14
18
  };
15
19
  exports.getCdkAppCommand = getCdkAppCommand;
16
20
  // The docker build context for the go:docker deployer image.
@@ -1 +1 @@
1
- {"version":3,"file":"cdkApp.js","sourceRoot":"","sources":["../../../../src/platforms/aws/cdkApp.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AAExB,uDAA0D;AAE1D,6EAA6E;AAC7E,uEAAuE;AAChE,MAAM,gBAAgB,GAAG,GAAW,EAAE;IAC3C,MAAM,YAAY,GAAG,cAAI,CAAC,IAAI,CAAC,IAAA,+BAAiB,GAAE,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC;IAC9F,OAAO,4CAA4C,YAAY,GAAG,CAAC;AACrE,CAAC,CAAC;AAHW,QAAA,gBAAgB,oBAG3B;AAEF,6DAA6D;AACtD,MAAM,YAAY,GAAG,GAAW,EAAE,CAAC,cAAI,CAAC,IAAI,CAAC,IAAA,+BAAiB,GAAE,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC;AAAtF,QAAA,YAAY,gBAA0E","sourcesContent":["import path from 'path';\n\nimport { getOwnPackageRoot } from '../../lib/packageRoot';\n\n// The CDK app command (`cdk ... --app \"<this>\"`): quidproquo-deploy-awscdk's\n// generic workspace app under ts-node hooks, with DEPLOY_* in the env.\nexport const getCdkAppCommand = (): string => {\n const cdkAppScript = path.join(getOwnPackageRoot(), 'lib', 'commonjs', 'bin', 'qpqCdkApp.js');\n return `node -r ts-node/register/transpile-only \"${cdkAppScript}\"`;\n};\n\n// The docker build context for the go:docker deployer image.\nexport const getDockerDir = (): string => path.join(getOwnPackageRoot(), 'docker', 'cdk-deployer');\n"]}
1
+ {"version":3,"file":"cdkApp.js","sourceRoot":"","sources":["../../../../src/platforms/aws/cdkApp.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AAExB,uDAA0D;AAE1D,6EAA6E;AAC7E,uEAAuE;AAChE,MAAM,gBAAgB,GAAG,GAAW,EAAE;IAC3C,4EAA4E;IAC5E,8EAA8E;IAC9E,kDAAkD;IAClD,MAAM,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,iCAAiC,CAAC,CAAC;IAC1E,MAAM,YAAY,GAAG,cAAI,CAAC,IAAI,CAAC,IAAA,+BAAiB,GAAE,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC;IAC9F,OAAO,YAAY,cAAc,MAAM,YAAY,GAAG,CAAC;AACzD,CAAC,CAAC;AAPW,QAAA,gBAAgB,oBAO3B;AAEF,6DAA6D;AACtD,MAAM,YAAY,GAAG,GAAW,EAAE,CAAC,cAAI,CAAC,IAAI,CAAC,IAAA,+BAAiB,GAAE,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC;AAAtF,QAAA,YAAY,gBAA0E","sourcesContent":["import path from 'path';\n\nimport { getOwnPackageRoot } from '../../lib/packageRoot';\n\n// The CDK app command (`cdk ... --app \"<this>\"`): quidproquo-deploy-awscdk's\n// generic workspace app under ts-node hooks, with DEPLOY_* in the env.\nexport const getCdkAppCommand = (): string => {\n // Resolve ts-node from this package, not the workspace cwd — under npm link\n // the CLI's dependencies are never hoisted into the workspace's node_modules,\n // so a bare `-r ts-node/...` preload fails there.\n const tsNodeRegister = require.resolve('ts-node/register/transpile-only');\n const cdkAppScript = path.join(getOwnPackageRoot(), 'lib', 'commonjs', 'bin', 'qpqCdkApp.js');\n return `node -r \"${tsNodeRegister}\" \"${cdkAppScript}\"`;\n};\n\n// The docker build context for the go:docker deployer image.\nexport const getDockerDir = (): string => path.join(getOwnPackageRoot(), 'docker', 'cdk-deployer');\n"]}
@@ -0,0 +1,2 @@
1
+ import { ClearResourcesPlan } from '../../lib/clearResourcesPlan';
2
+ export declare const awsClearResources: (appName: string, plan: ClearResourcesPlan) => Promise<void>;
@@ -0,0 +1,167 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.awsClearResources = void 0;
13
+ // AWS implementation of `qpq clear-resources`: empty (never delete) the
14
+ // selected data resources. Storage drives are S3 buckets - emptied including
15
+ // every object version and delete marker, so versioned buckets come out clean
16
+ // too. Key value stores are DynamoDB tables - truncated by scanning keys only
17
+ // and batch-deleting. The stacks and the resources themselves are untouched,
18
+ // so this is the "reset my data" counterpart to `qpq teardown`.
19
+ //
20
+ // Runtime names are resolved from each service's live qpq config with the
21
+ // same naming utils the deployed runtime uses, so what gets emptied is
22
+ // exactly what the app reads and writes.
23
+ const quidproquo_actionprocessor_awslambda_1 = require("quidproquo-actionprocessor-awslambda");
24
+ const quidproquo_config_aws_1 = require("quidproquo-config-aws");
25
+ const quidproquo_core_1 = require("quidproquo-core");
26
+ const client_dynamodb_1 = require("@aws-sdk/client-dynamodb");
27
+ const client_s3_1 = require("@aws-sdk/client-s3");
28
+ const qpqConfigs_1 = require("../../lib/qpqConfigs");
29
+ const awsCredentials_1 = require("./awsCredentials");
30
+ // Same resolution as the runtime's resolveStorageDriveBucketName (not exported
31
+ // from the actionprocessor package root): honour the cross-module owner and
32
+ // its resourceNameOverride.
33
+ const resolveBucketName = (drive, qpqConfig) => {
34
+ var _a, _b;
35
+ const storageDriveConfig = quidproquo_core_1.qpqCoreUtils.getStorageDriveByName(drive, qpqConfig);
36
+ if (!storageDriveConfig) {
37
+ throw new Error(`Could not find storage drive config for [${drive}]`);
38
+ }
39
+ return quidproquo_actionprocessor_awslambda_1.awsNamingUtils.getConfigRuntimeResourceNameFromConfigWithServiceOverride(((_a = storageDriveConfig.owner) === null || _a === void 0 ? void 0 : _a.resourceNameOverride) || drive, qpqConfig, (_b = storageDriveConfig.owner) === null || _b === void 0 ? void 0 : _b.module);
40
+ };
41
+ // Log a progress heartbeat roughly every this-many removals, so a large
42
+ // resource visibly ticks along instead of looking hung.
43
+ const PROGRESS_EVERY = 2000;
44
+ // Empty a bucket including all versions + delete markers. Returns the number
45
+ // of objects/versions removed.
46
+ const emptyBucket = (bucketName, region) => __awaiter(void 0, void 0, void 0, function* () {
47
+ var _a, _b;
48
+ const s3 = new client_s3_1.S3Client({ region });
49
+ let removed = 0;
50
+ let lastReported = 0;
51
+ let keyMarker;
52
+ let versionIdMarker;
53
+ do {
54
+ const page = yield s3.send(new client_s3_1.ListObjectVersionsCommand({ Bucket: bucketName, KeyMarker: keyMarker, VersionIdMarker: versionIdMarker }));
55
+ const objects = [...((_a = page.Versions) !== null && _a !== void 0 ? _a : []), ...((_b = page.DeleteMarkers) !== null && _b !== void 0 ? _b : [])].map((v) => ({
56
+ Key: v.Key,
57
+ VersionId: v.VersionId,
58
+ }));
59
+ if (objects.length > 0) {
60
+ yield s3.send(new client_s3_1.DeleteObjectsCommand({ Bucket: bucketName, Delete: { Objects: objects, Quiet: true } }));
61
+ removed += objects.length;
62
+ }
63
+ if (removed - lastReported >= PROGRESS_EVERY) {
64
+ console.log(` ... ${removed} objects/versions so far`);
65
+ lastReported = removed;
66
+ }
67
+ keyMarker = page.IsTruncated ? page.NextKeyMarker : undefined;
68
+ versionIdMarker = page.IsTruncated ? page.NextVersionIdMarker : undefined;
69
+ } while (keyMarker || versionIdMarker);
70
+ return removed;
71
+ });
72
+ // Truncate a table: scan key attributes only, batch-delete 25 at a time,
73
+ // retrying unprocessed items. Returns the number of items removed.
74
+ const truncateTable = (tableName, region) => __awaiter(void 0, void 0, void 0, function* () {
75
+ var _a, _b, _c, _d, _e;
76
+ const dynamo = new client_dynamodb_1.DynamoDBClient({ region });
77
+ const described = yield dynamo.send(new client_dynamodb_1.DescribeTableCommand({ TableName: tableName }));
78
+ const keyAttributes = ((_b = (_a = described.Table) === null || _a === void 0 ? void 0 : _a.KeySchema) !== null && _b !== void 0 ? _b : []).map((k) => k.AttributeName);
79
+ // Alias every key attribute - a raw name could collide with a reserved word.
80
+ const projection = keyAttributes.map((_, i) => `#k${i}`).join(', ');
81
+ const attributeNames = Object.fromEntries(keyAttributes.map((attribute, i) => [`#k${i}`, attribute]));
82
+ let removed = 0;
83
+ let lastReported = 0;
84
+ let exclusiveStartKey;
85
+ do {
86
+ const page = yield dynamo.send(new client_dynamodb_1.ScanCommand({
87
+ TableName: tableName,
88
+ ProjectionExpression: projection,
89
+ ExpressionAttributeNames: attributeNames,
90
+ ExclusiveStartKey: exclusiveStartKey,
91
+ }));
92
+ const items = (_c = page.Items) !== null && _c !== void 0 ? _c : [];
93
+ for (let i = 0; i < items.length; i += 25) {
94
+ let requests = items.slice(i, i + 25).map((item) => ({ DeleteRequest: { Key: item } }));
95
+ while (requests.length > 0) {
96
+ const result = yield dynamo.send(new client_dynamodb_1.BatchWriteItemCommand({ RequestItems: { [tableName]: requests } }));
97
+ removed += requests.length;
98
+ const unprocessed = (_e = (_d = result.UnprocessedItems) === null || _d === void 0 ? void 0 : _d[tableName]) !== null && _e !== void 0 ? _e : [];
99
+ removed -= unprocessed.length;
100
+ requests = unprocessed;
101
+ if (requests.length > 0) {
102
+ // Throttled - back off briefly before retrying the leftovers.
103
+ yield new Promise((resolve) => setTimeout(resolve, 250));
104
+ }
105
+ }
106
+ }
107
+ if (removed - lastReported >= PROGRESS_EVERY) {
108
+ console.log(` ... ${removed} items so far`);
109
+ lastReported = removed;
110
+ }
111
+ exclusiveStartKey = page.LastEvaluatedKey;
112
+ } while (exclusiveStartKey);
113
+ return removed;
114
+ });
115
+ const clearResource = (appName, resource) => __awaiter(void 0, void 0, void 0, function* () {
116
+ const qpqConfig = (0, qpqConfigs_1.loadServiceQpqConfig)(appName, resource.service);
117
+ const region = quidproquo_config_aws_1.qpqConfigAwsUtils.getApplicationModuleDeployRegion(qpqConfig);
118
+ if (resource.kind === 'storageDrive') {
119
+ const bucketName = resolveBucketName(resource.resourceName, qpqConfig);
120
+ console.log(` emptying s3://${bucketName} ...`);
121
+ try {
122
+ const removed = yield emptyBucket(bucketName, region);
123
+ console.log(` emptied s3://${bucketName} (${removed} objects/versions)`);
124
+ }
125
+ catch (error) {
126
+ if (error instanceof client_s3_1.NoSuchBucket) {
127
+ console.log(` skipped s3://${bucketName} (bucket does not exist - not deployed?)`);
128
+ return;
129
+ }
130
+ throw error;
131
+ }
132
+ return;
133
+ }
134
+ // 'kvs' matches the resourceType every runtime KVS action processor passes,
135
+ // giving the deployed '-qpqkvs' table name suffix.
136
+ const tableName = quidproquo_actionprocessor_awslambda_1.awsNamingUtils.getKvsDynamoTableNameFromConfig(resource.resourceName, qpqConfig, 'kvs');
137
+ console.log(` truncating ${tableName} ...`);
138
+ try {
139
+ const removed = yield truncateTable(tableName, region);
140
+ console.log(` truncated ${tableName} (${removed} items)`);
141
+ }
142
+ catch (error) {
143
+ if (error instanceof client_dynamodb_1.ResourceNotFoundException) {
144
+ console.log(` skipped ${tableName} (table does not exist - not deployed?)`);
145
+ return;
146
+ }
147
+ throw error;
148
+ }
149
+ });
150
+ const awsClearResources = (appName, plan) => __awaiter(void 0, void 0, void 0, function* () {
151
+ if (plan.kind === 'cancelled') {
152
+ return;
153
+ }
154
+ if ((yield (0, awsCredentials_1.isAwsCredentialsValid)()) === false) {
155
+ console.log('Credentials are expired or invalid.');
156
+ return;
157
+ }
158
+ console.log('\nEmptying resources:');
159
+ // Sequential on purpose: predictable output, and no burst of parallel scans
160
+ // against provisioned-throughput tables.
161
+ for (const resource of plan.resources) {
162
+ yield clearResource(appName, resource);
163
+ }
164
+ console.log('Done.');
165
+ });
166
+ exports.awsClearResources = awsClearResources;
167
+ //# sourceMappingURL=clearResources.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clearResources.js","sourceRoot":"","sources":["../../../../src/platforms/aws/clearResources.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wEAAwE;AACxE,6EAA6E;AAC7E,8EAA8E;AAC9E,8EAA8E;AAC9E,6EAA6E;AAC7E,gEAAgE;AAChE,EAAE;AACF,0EAA0E;AAC1E,uEAAuE;AACvE,yCAAyC;AACzC,+FAAsE;AACtE,iEAA0D;AAC1D,qDAA0D;AAE1D,8DAOkC;AAClC,kDAA+H;AAG/H,qDAA4D;AAC5D,qDAAyD;AAEzD,+EAA+E;AAC/E,4EAA4E;AAC5E,4BAA4B;AAC5B,MAAM,i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CAAqC,CAAC,CAAC;QACnD,OAAO;IACT,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;IAErC,4EAA4E;IAC5E,yCAAyC;IACzC,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;QACtC,MAAM,aAAa,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACzC,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;AACvB,CAAC,CAAA,CAAC;AAnBW,QAAA,iBAAiB,qBAmB5B","sourcesContent":["// AWS implementation of `qpq clear-resources`: empty (never delete) the\n// selected data resources. Storage drives are S3 buckets - emptied including\n// every object version and delete marker, so versioned buckets come out clean\n// too. Key value stores are DynamoDB tables - truncated by scanning keys only\n// and batch-deleting. The stacks and the resources themselves are untouched,\n// so this is the \"reset my data\" counterpart to `qpq teardown`.\n//\n// Runtime names are resolved from each service's live qpq config with the\n// same naming utils the deployed runtime uses, so what gets emptied is\n// exactly what the app reads and writes.\nimport { awsNamingUtils } from 'quidproquo-actionprocessor-awslambda';\nimport { qpqConfigAwsUtils } from 'quidproquo-config-aws';\nimport { QPQConfig, qpqCoreUtils } from 'quidproquo-core';\n\nimport {\n BatchWriteItemCommand,\n DescribeTableCommand,\n DynamoDBClient,\n ResourceNotFoundException,\n ScanCommand,\n WriteRequest,\n} from '@aws-sdk/client-dynamodb';\nimport { DeleteObjectsCommand, ListObjectVersionsCommand, NoSuchBucket, ObjectIdentifier, S3Client } from '@aws-sdk/client-s3';\n\nimport { ClearableResource, ClearResourcesPlan } from '../../lib/clearResourcesPlan';\nimport { loadServiceQpqConfig } from '../../lib/qpqConfigs';\nimport { isAwsCredentialsValid } from './awsCredentials';\n\n// Same resolution as the runtime's resolveStorageDriveBucketName (not exported\n// from the actionprocessor package root): honour the cross-module owner and\n// its resourceNameOverride.\nconst resolveBucketName = (drive: string, qpqConfig: QPQConfig): string => {\n const storageDriveConfig = qpqCoreUtils.getStorageDriveByName(drive, qpqConfig);\n\n if (!storageDriveConfig) {\n throw new Error(`Could not find storage drive config for [${drive}]`);\n }\n\n return awsNamingUtils.getConfigRuntimeResourceNameFromConfigWithServiceOverride(\n storageDriveConfig.owner?.resourceNameOverride || drive,\n qpqConfig,\n storageDriveConfig.owner?.module,\n );\n};\n\n// Log a progress heartbeat roughly every this-many removals, so a large\n// resource visibly ticks along instead of looking hung.\nconst PROGRESS_EVERY = 2000;\n\n// Empty a bucket including all versions + delete markers. Returns the number\n// of objects/versions removed.\nconst emptyBucket = async (bucketName: string, region: string): Promise<number> => {\n const s3 = new S3Client({ region });\n let removed = 0;\n let lastReported = 0;\n let keyMarker: string | undefined;\n let versionIdMarker: string | undefined;\n\n do {\n const page = await s3.send(new ListObjectVersionsCommand({ Bucket: bucketName, KeyMarker: keyMarker, VersionIdMarker: versionIdMarker }));\n\n const objects: ObjectIdentifier[] = [...(page.Versions ?? []), ...(page.DeleteMarkers ?? [])].map((v) => ({\n Key: v.Key!,\n VersionId: v.VersionId,\n }));\n\n if (objects.length > 0) {\n await s3.send(new DeleteObjectsCommand({ Bucket: bucketName, Delete: { Objects: objects, Quiet: true } }));\n removed += objects.length;\n }\n\n if (removed - lastReported >= PROGRESS_EVERY) {\n console.log(` ... ${removed} objects/versions so far`);\n lastReported = removed;\n }\n\n keyMarker = page.IsTruncated ? page.NextKeyMarker : undefined;\n versionIdMarker = page.IsTruncated ? page.NextVersionIdMarker : undefined;\n } while (keyMarker || versionIdMarker);\n\n return removed;\n};\n\n// Truncate a table: scan key attributes only, batch-delete 25 at a time,\n// retrying unprocessed items. Returns the number of items removed.\nconst truncateTable = async (tableName: string, region: string): Promise<number> => {\n const dynamo = new DynamoDBClient({ region });\n\n const described = await dynamo.send(new DescribeTableCommand({ TableName: tableName }));\n const keyAttributes = (described.Table?.KeySchema ?? []).map((k) => k.AttributeName!);\n\n // Alias every key attribute - a raw name could collide with a reserved word.\n const projection = keyAttributes.map((_, i) => `#k${i}`).join(', ');\n const attributeNames = Object.fromEntries(keyAttributes.map((attribute, i) => [`#k${i}`, attribute]));\n\n let removed = 0;\n let lastReported = 0;\n let exclusiveStartKey: Record<string, any> | undefined;\n\n do {\n const page = await dynamo.send(\n new ScanCommand({\n TableName: tableName,\n ProjectionExpression: projection,\n ExpressionAttributeNames: attributeNames,\n ExclusiveStartKey: exclusiveStartKey,\n }),\n );\n\n const items = page.Items ?? [];\n\n for (let i = 0; i < items.length; i += 25) {\n let requests: WriteRequest[] = items.slice(i, i + 25).map((item) => ({ DeleteRequest: { Key: item } }));\n\n while (requests.length > 0) {\n const result = await dynamo.send(new BatchWriteItemCommand({ RequestItems: { [tableName]: requests } }));\n removed += requests.length;\n\n const unprocessed = result.UnprocessedItems?.[tableName] ?? [];\n removed -= unprocessed.length;\n requests = unprocessed;\n\n if (requests.length > 0) {\n // Throttled - back off briefly before retrying the leftovers.\n await new Promise((resolve) => setTimeout(resolve, 250));\n }\n }\n }\n\n if (removed - lastReported >= PROGRESS_EVERY) {\n console.log(` ... ${removed} items so far`);\n lastReported = removed;\n }\n\n exclusiveStartKey = page.LastEvaluatedKey;\n } while (exclusiveStartKey);\n\n return removed;\n};\n\nconst clearResource = async (appName: string, resource: ClearableResource): Promise<void> => {\n const qpqConfig = loadServiceQpqConfig(appName, resource.service);\n const region = qpqConfigAwsUtils.getApplicationModuleDeployRegion(qpqConfig);\n\n if (resource.kind === 'storageDrive') {\n const bucketName = resolveBucketName(resource.resourceName, qpqConfig);\n console.log(` emptying s3://${bucketName} ...`);\n try {\n const removed = await emptyBucket(bucketName, region);\n console.log(` emptied s3://${bucketName} (${removed} objects/versions)`);\n } catch (error) {\n if (error instanceof NoSuchBucket) {\n console.log(` skipped s3://${bucketName} (bucket does not exist - not deployed?)`);\n return;\n }\n throw error;\n }\n return;\n }\n\n // 'kvs' matches the resourceType every runtime KVS action processor passes,\n // giving the deployed '-qpqkvs' table name suffix.\n const tableName = awsNamingUtils.getKvsDynamoTableNameFromConfig(resource.resourceName, qpqConfig, 'kvs');\n console.log(` truncating ${tableName} ...`);\n try {\n const removed = await truncateTable(tableName, region);\n console.log(` truncated ${tableName} (${removed} items)`);\n } catch (error) {\n if (error instanceof ResourceNotFoundException) {\n console.log(` skipped ${tableName} (table does not exist - not deployed?)`);\n return;\n }\n throw error;\n }\n};\n\nexport const awsClearResources = async (appName: string, plan: ClearResourcesPlan): Promise<void> => {\n if (plan.kind === 'cancelled') {\n return;\n }\n\n if ((await isAwsCredentialsValid()) === false) {\n console.log('Credentials are expired or invalid.');\n return;\n }\n\n console.log('\\nEmptying resources:');\n\n // Sequential on purpose: predictable output, and no burst of parallel scans\n // against provisioned-throughput tables.\n for (const resource of plan.resources) {\n await clearResource(appName, resource);\n }\n\n console.log('Done.');\n};\n"]}
@@ -16,7 +16,10 @@ exports.awsGo = void 0;
16
16
  // AWS sequential deploy (`qpq go`). Per service it: synths the QPQ config,
17
17
  // rspack-bundles the backend (programmatic — no per-service rspack.config.ts),
18
18
  // deploys the inf/api/web CDK stacks (cdk runs the generic workspace app via
19
- // --app), bundles views (rspack, production) and syncs them to S3.
19
+ // --app), bundles views (rspack, production) and syncs them to S3. Finally, any
20
+ // service that opts into module federation has its federated remote published
21
+ // (built + uploaded + manifest flipped), so a deploy that ships new backend
22
+ // code also republishes the code the lambdas federate.
20
23
  const quidproquo_deploy_awscdk_1 = require("quidproquo-deploy-awscdk");
21
24
  const quidproquo_deploy_rspack_1 = require("quidproquo-deploy-rspack");
22
25
  const path_1 = __importDefault(require("path"));
@@ -29,6 +32,7 @@ const runCommand_1 = require("../../lib/runCommand");
29
32
  const timing_1 = require("../../lib/timing");
30
33
  const views_1 = require("../../lib/views");
31
34
  const awsCredentials_1 = require("./awsCredentials");
35
+ const publish_1 = require("./publish");
32
36
  const stacks_1 = require("./stacks");
33
37
  const viewsSync_1 = require("./viewsSync");
34
38
  const buildAndDeploy = (serviceName, needsSynth, needsBuildApi, needsInfStack, needsApiStack, needsWebStack, needsViewStack, appName) => __awaiter(void 0, void 0, void 0, function* () {
@@ -110,6 +114,16 @@ const awsGo = (appName, plan) => __awaiter(void 0, void 0, void 0, function* ()
110
114
  return buildAndDeploy(service, phase === 0, phase === 1 && shouldBuildApi, phase === 2 && (allStacks || stacks === 'inf'), phase === 3 && (allStacks || stacks === 'api'), phase === 4 && (allStacks || stacks === 'web'), phase === 5 && (allStacks || stacks === 'views'), appName);
111
115
  }), Promise.resolve());
112
116
  }
117
+ // Publishing federated remotes only matters once the new backend code is
118
+ // live, so it's gated on the api stack having been (re)deployed. Services
119
+ // without defineFederatedModuleStore(...) are skipped.
120
+ if (allStacks || stacks === 'api') {
121
+ const federatedServices = (0, qpqConfigs_1.getServiceNamesWithFederation)(appName, services);
122
+ if (federatedServices.length > 0) {
123
+ console.log('\n\nPublishing federated backends\n');
124
+ yield (0, publish_1.awsPublish)(appName, federatedServices);
125
+ }
126
+ }
113
127
  (0, timing_1.logTimeEnd)('totalTime');
114
128
  });
115
129
  exports.awsGo = awsGo;
@@ -1 +1 @@
1
- {"version":3,"file":"go.js","sourceRoot":"","sources":["../../../../src/platforms/aws/go.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2EAA2E;AAC3E,+EAA+E;AAC/E,6EAA6E;AAC7E,mEAAmE;AACnE,uEAAgE;AAChE,uEAAkE;AAElE,gDAAwB;AAExB,gDAAoD;AAEpD,mDAAoF;AACpF,2CAA6C;AAC7C,qDAA4D;AAC5D,mDAAgD;AAChD,qDAAkD;AAClD,6CAA4D;AAC5D,2CAA8C;AAC9C,qDAAyD;AACzD,qCAA2G;AAC3G,2CAA4C;AAE5C,MAAM,cAAc,GAAG,CACrB,WAAmB,EACnB,UAAmB,EACnB,aAAsB,EACtB,aAAsB,EACtB,aAAsB,EACtB,aAAsB,EACtB,cAAuB,EACvB,OAAe,EACA,EAAE;IACjB,IAAI,UAAU,EAAE,CAAC;QACf,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;QACjC,MAAM,IAAA,oBAA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C,EAC9C,KAAK,KAAK,CAAC,IAAI,CAAC,SAAS,IAAI,MAAM,KAAK,OAAO,CAAC,EAChD,OAAO,CACR,CAAC;QACJ,CAAC,CAAA,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;IACxB,CAAC;IAED,IAAA,mBAAU,EAAC,WAAW,CAAC,CAAC;AAC1B,CAAC,CAAA,CAAC;AAxEW,QAAA,KAAK,SAwEhB","sourcesContent":["// AWS sequential deploy (`qpq go`). Per service it: synths the QPQ config,\n// rspack-bundles the backend (programmatic — no per-service rspack.config.ts),\n// deploys the inf/api/web CDK stacks (cdk runs the generic workspace app via\n// --app), bundles views (rspack, production) and syncs them to S3.\nimport { qpqDeployAwsCdkUtils } from 'quidproquo-deploy-awscdk';\nimport { getServiceRspackConfig } from 'quidproquo-deploy-rspack';\n\nimport path from 'path';\n\nimport { synthCommand } from '../../commands/synth';\nimport { DeployPlan } from '../../lib/deployPrompts';\nimport { getServiceDirectory, getServiceNamesWithViews } from '../../lib/discovery';\nimport { runAppHook } from '../../lib/hooks';\nimport { loadServiceQpqConfig } from '../../lib/qpqConfigs';\nimport { runRspack } from '../../lib/rspackRun';\nimport { runCommand } from '../../lib/runCommand';\nimport { logTimeEnd, logTimeStart } from '../../lib/timing';\nimport { bundleViews } from '../../lib/views';\nimport { isAwsCredentialsValid } from './awsCredentials';\nimport { deployAccountStack, deployBootstrapStack, deployDomainStack, deployServiceStack } from './stacks';\nimport { syncViewsToS3 } from './viewsSync';\n\nconst buildAndDeploy = async (\n serviceName: string,\n needsSynth: boolean,\n needsBuildApi: boolean,\n needsInfStack: boolean,\n needsApiStack: boolean,\n needsWebStack: boolean,\n needsViewStack: boolean,\n appName: string,\n): Promise<void> => {\n if (needsSynth) {\n console.log('Synth QPQ Configs');\n await synthCommand([serviceName, '--app', appName]);\n }\n\n const qpqConfigForService = loadServiceQpqConfig(appName, serviceName);\n\n if (needsBuildApi) {\n console.log('Building Api: ', serviceName);\n await runRspack(getServiceRspackConfig(qpqConfigForService, path.join(getServiceDirectory(appName, serviceName), 'service')));\n }\n\n if (needsInfStack) {\n console.log('Deploy Inf: ', serviceName);\n await deployServiceStack(serviceName, qpqDeployAwsCdkUtils.getInfStackName(qpqConfigForService), appName);\n }\n\n if (needsApiStack) {\n console.log('Deploy Api: ', serviceName);\n await deployServiceStack(serviceName, qpqDeployAwsCdkUtils.getApiStackName(qpqConfigForService), appName);\n }\n\n if (needsWebStack) {\n console.log('Deploy Web: ', serviceName);\n await deployServiceStack(serviceName, qpqDeployAwsCdkUtils.getWebStackName(qpqConfigForService), appName);\n }\n\n if (needsViewStack && getServiceNamesWithViews(appName).includes(serviceName)) {\n console.log('Building Views: ', serviceName);\n await bundleViews(appName, serviceName);\n await syncViewsToS3(appName, serviceName);\n }\n};\n\nexport const awsGo = async (appName: string, plan: DeployPlan): Promise<void> => {\n if (plan.kind === 'cancelled') {\n return;\n }\n\n logTimeStart('totalTime');\n\n if (plan.kind === 'account') {\n await deployAccountStack(plan.appName);\n logTimeEnd('totalTime');\n return;\n }\n\n if (plan.kind === 'bootstrap') {\n // Actor bootstraps deploy into a shared account — leave the account-level\n // guardrails stack alone (deploy it explicitly via the 'account' option).\n if (process.env.ACTOR_NAME) {\n console.log('Skipping account stack for actor deploy');\n } else {\n await deployAccountStack(plan.appName);\n }\n if (plan.includeDomain) {\n await deployDomainStack(plan.appName);\n }\n await deployBootstrapStack(plan.appName);\n logTimeEnd('totalTime');\n return;\n }\n\n const { services, stacks } = plan;\n const shouldBuildApi = stacks !== 'views';\n\n console.log('\\n\\nRunning automated deploy\\n\\n');\n console.log('Executing for services');\n console.log(services.join(', '));\n\n if ((await isAwsCredentialsValid()) === false) {\n console.log('Credentials are expired or invalid.');\n return;\n }\n\n const allStacks = stacks === 'all';\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 // Views uploads resolve bucket names from the shell service's config.\n if (allStacks || stacks === 'views') {\n await synthCommand(['shell', '--app', appName]);\n }\n\n for (let phase = 0; phase <= 5; phase += 1) {\n await services.reduce(async (cur, service) => {\n await cur;\n return buildAndDeploy(\n service,\n phase === 0,\n phase === 1 && shouldBuildApi,\n phase === 2 && (allStacks || stacks === 'inf'),\n phase === 3 && (allStacks || stacks === 'api'),\n phase === 4 && (allStacks || stacks === 'web'),\n phase === 5 && (allStacks || stacks === 'views'),\n appName,\n );\n }, Promise.resolve());\n }\n\n logTimeEnd('totalTime');\n};\n"]}
1
+ {"version":3,"file":"go.js","sourceRoot":"","sources":["../../../../src/platforms/aws/go.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2EAA2E;AAC3E,+EAA+E;AAC/E,6EAA6E;AAC7E,gFAAgF;AAChF,8EAA8E;AAC9E,4EAA4E;AAC5E,uDAAuD;AACvD,uEAAgE;AAChE,uEAAkE;AAElE,gDAAwB;AAExB,gDAAoD;AAEpD,mDAAoF;AACpF,2CAA6C;AAC7C,qDAA2F;AAC3F,mDAAgD;AAChD,qDAAkD;AAClD,6CAA4D;AAC5D,2CAA8C;AAC9C,qDAAyD;AACzD,uCAAuC;AACvC,qCAA2G;AAC3G,2CAA4C;AAE5C,MAAM,cAAc,GAAG,CACrB,WAAmB,EACnB,UAAmB,EACnB,aAAsB,EACtB,aAAsB,EACtB,aAAsB,EACtB,aAAsB,EACtB,cAAuB,EACvB,OAAe,EACA,EAAE;IACjB,IAAI,UAAU,EAAE,CAAC;QACf,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;QACjC,MAAM,IAAA,oBAAY,EAAC,CAAC,WAAW,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;IACtD,CAAC;IAED,MAAM,mBAAmB,GAAG,IAAA,iCAAoB,EAAC,OAAO,EAAE,WAAW,CAAC,CAAC;IAEvE,IAAI,aAAa,EAAE,CAAC;QAClB,O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,0EAA0E;IAC1E,uDAAuD;IACvD,IAAI,SAAS,IAAI,MAAM,KAAK,KAAK,EAAE,CAAC;QAClC,MAAM,iBAAiB,GAAG,IAAA,0CAA6B,EAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QAC3E,IAAI,iBAAiB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACjC,OAAO,CAAC,GAAG,CAAC,qCAAqC,CAAC,CAAC;YACnD,MAAM,IAAA,oBAAU,EAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC;IAED,IAAA,mBAAU,EAAC,WAAW,CAAC,CAAC;AAC1B,CAAC,CAAA,CAAC;AAnFW,QAAA,KAAK,SAmFhB","sourcesContent":["// AWS sequential deploy (`qpq go`). Per service it: synths the QPQ config,\n// rspack-bundles the backend (programmatic — no per-service rspack.config.ts),\n// deploys the inf/api/web CDK stacks (cdk runs the generic workspace app via\n// --app), bundles views (rspack, production) and syncs them to S3. Finally, any\n// service that opts into module federation has its federated remote published\n// (built + uploaded + manifest flipped), so a deploy that ships new backend\n// code also republishes the code the lambdas federate.\nimport { qpqDeployAwsCdkUtils } from 'quidproquo-deploy-awscdk';\nimport { getServiceRspackConfig } from 'quidproquo-deploy-rspack';\n\nimport path from 'path';\n\nimport { synthCommand } from '../../commands/synth';\nimport { DeployPlan } from '../../lib/deployPrompts';\nimport { getServiceDirectory, getServiceNamesWithViews } from '../../lib/discovery';\nimport { runAppHook } from '../../lib/hooks';\nimport { getServiceNamesWithFederation, loadServiceQpqConfig } from '../../lib/qpqConfigs';\nimport { runRspack } from '../../lib/rspackRun';\nimport { runCommand } from '../../lib/runCommand';\nimport { logTimeEnd, logTimeStart } from '../../lib/timing';\nimport { bundleViews } from '../../lib/views';\nimport { isAwsCredentialsValid } from './awsCredentials';\nimport { awsPublish } from './publish';\nimport { deployAccountStack, deployBootstrapStack, deployDomainStack, deployServiceStack } from './stacks';\nimport { syncViewsToS3 } from './viewsSync';\n\nconst buildAndDeploy = async (\n serviceName: string,\n needsSynth: boolean,\n needsBuildApi: boolean,\n needsInfStack: boolean,\n needsApiStack: boolean,\n needsWebStack: boolean,\n needsViewStack: boolean,\n appName: string,\n): Promise<void> => {\n if (needsSynth) {\n console.log('Synth QPQ Configs');\n await synthCommand([serviceName, '--app', appName]);\n }\n\n const qpqConfigForService = loadServiceQpqConfig(appName, serviceName);\n\n if (needsBuildApi) {\n console.log('Building Api: ', serviceName);\n await runRspack(getServiceRspackConfig(qpqConfigForService, path.join(getServiceDirectory(appName, serviceName), 'service')));\n }\n\n if (needsInfStack) {\n console.log('Deploy Inf: ', serviceName);\n await deployServiceStack(serviceName, qpqDeployAwsCdkUtils.getInfStackName(qpqConfigForService), appName);\n }\n\n if (needsApiStack) {\n console.log('Deploy Api: ', serviceName);\n await deployServiceStack(serviceName, qpqDeployAwsCdkUtils.getApiStackName(qpqConfigForService), appName);\n }\n\n if (needsWebStack) {\n console.log('Deploy Web: ', serviceName);\n await deployServiceStack(serviceName, qpqDeployAwsCdkUtils.getWebStackName(qpqConfigForService), appName);\n }\n\n if (needsViewStack && getServiceNamesWithViews(appName).includes(serviceName)) {\n console.log('Building Views: ', serviceName);\n await bundleViews(appName, serviceName);\n await syncViewsToS3(appName, serviceName);\n }\n};\n\nexport const awsGo = async (appName: string, plan: DeployPlan): Promise<void> => {\n if (plan.kind === 'cancelled') {\n return;\n }\n\n logTimeStart('totalTime');\n\n if (plan.kind === 'account') {\n await deployAccountStack(plan.appName);\n logTimeEnd('totalTime');\n return;\n }\n\n if (plan.kind === 'bootstrap') {\n // Actor bootstraps deploy into a shared account — leave the account-level\n // guardrails stack alone (deploy it explicitly via the 'account' option).\n if (process.env.ACTOR_NAME) {\n console.log('Skipping account stack for actor deploy');\n } else {\n await deployAccountStack(plan.appName);\n }\n if (plan.includeDomain) {\n await deployDomainStack(plan.appName);\n }\n await deployBootstrapStack(plan.appName);\n logTimeEnd('totalTime');\n return;\n }\n\n const { services, stacks } = plan;\n const shouldBuildApi = stacks !== 'views';\n\n console.log('\\n\\nRunning automated deploy\\n\\n');\n console.log('Executing for services');\n console.log(services.join(', '));\n\n if ((await isAwsCredentialsValid()) === false) {\n console.log('Credentials are expired or invalid.');\n return;\n }\n\n const allStacks = stacks === 'all';\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 // Views uploads resolve bucket names from the shell service's config.\n if (allStacks || stacks === 'views') {\n await synthCommand(['shell', '--app', appName]);\n }\n\n for (let phase = 0; phase <= 5; phase += 1) {\n await services.reduce(async (cur, service) => {\n await cur;\n return buildAndDeploy(\n service,\n phase === 0,\n phase === 1 && shouldBuildApi,\n phase === 2 && (allStacks || stacks === 'inf'),\n phase === 3 && (allStacks || stacks === 'api'),\n phase === 4 && (allStacks || stacks === 'web'),\n phase === 5 && (allStacks || stacks === 'views'),\n appName,\n );\n }, Promise.resolve());\n }\n\n // Publishing federated remotes only matters once the new backend code is\n // live, so it's gated on the api stack having been (re)deployed. Services\n // without defineFederatedModuleStore(...) are skipped.\n if (allStacks || stacks === 'api') {\n const federatedServices = getServiceNamesWithFederation(appName, services);\n if (federatedServices.length > 0) {\n console.log('\\n\\nPublishing federated backends\\n');\n await awsPublish(appName, federatedServices);\n }\n }\n\n logTimeEnd('totalTime');\n};\n"]}
@@ -17,8 +17,9 @@ exports.awsGoDocker = void 0;
17
17
  // parallel via docker instead of sequentially:
18
18
  //
19
19
  // 1. Build everything locally first: QPQ config synth, rspack API bundles,
20
- // rspack view bundles, and one self-contained CDK cloud assembly per
21
- // service (`cdk synth --output dist/qpq/cdk-docker/<app>/<service>`).
20
+ // rspack view bundles, rspack federated-remote bundles, and one
21
+ // self-contained CDK cloud assembly per service
22
+ // (`cdk synth --output dist/qpq/cdk-docker/<app>/<service>`).
22
23
  // 2. Wave 1 (inf): one docker container per service deploys its inf stack,
23
24
  // all concurrently. Containers run only the CDK CLI against the mounted
24
25
  // pre-synthesized assembly — the workspace (and its npm-linked
@@ -28,6 +29,9 @@ exports.awsGoDocker = void 0;
28
29
  // each other).
29
30
  // 4. Views: the already-built bundles are synced to S3, one aws-cli
30
31
  // container per service, all concurrently.
32
+ // 5. Publish: the already-built federated remotes (backends that opt in with
33
+ // defineFederatedModuleStore(...)) are synced to S3 and their manifests
34
+ // flipped, one aws-cli container per service, all concurrently.
31
35
  //
32
36
  // domain/bootstrap menu options deploy host-side exactly like `qpq go` —
33
37
  // a single stack gains nothing from docker.
@@ -51,6 +55,7 @@ const timing_1 = require("../../lib/timing");
51
55
  const views_1 = require("../../lib/views");
52
56
  const awsCredentials_1 = require("./awsCredentials");
53
57
  const cdkApp_1 = require("./cdkApp");
58
+ const remote_1 = require("./remote");
54
59
  const stacks_1 = require("./stacks");
55
60
  const viewsSync_1 = require("./viewsSync");
56
61
  const IMAGE_TAG = 'qpq-cdk-deployer';
@@ -144,6 +149,42 @@ const dockerSyncViews = (color, appName, serviceName) => __awaiter(void 0, void
144
149
  ], { color });
145
150
  }
146
151
  });
152
+ // Publish one service's already-built federated remote to S3 in a throwaway
153
+ // aws-cli container named <service>-publish. The version dir (everything the
154
+ // manifest references) syncs first, then the manifest.json is copied last —
155
+ // same ordering guarantee as the host-side publish, so a reading lambda never
156
+ // sees a manifest whose files aren't all present yet. resolvePublishTarget reads
157
+ // the manifest hash + resolved bucket/prefix from the buildRemote output.
158
+ const dockerPublishRemote = (color, appName, serviceName) => __awaiter(void 0, void 0, void 0, function* () {
159
+ const { publishPath, manifestHash, bucketName, servicePrefix } = (0, remote_1.resolvePublishTarget)(appName, serviceName);
160
+ const containerName = `${serviceName}-publish`;
161
+ // /publish is the service-remote-published dir; the hashed version subdir and
162
+ // manifest.json both live directly under it.
163
+ const s3Operations = [
164
+ ['s3', 'sync', `/publish/${manifestHash}`, `s3://${bucketName}/${servicePrefix}/${manifestHash}`],
165
+ ['s3', 'cp', '/publish/manifest.json', `s3://${bucketName}/${servicePrefix}/manifest.json`],
166
+ ];
167
+ for (const s3Operation of s3Operations) {
168
+ yield (0, runCommand_1.runCommandPrefixed)(`publish:${serviceName}`, 'docker', [
169
+ 'rm',
170
+ '-f',
171
+ containerName,
172
+ '>/dev/null',
173
+ '2>&1',
174
+ ';',
175
+ 'docker',
176
+ 'run',
177
+ '--rm',
178
+ '--name',
179
+ containerName,
180
+ '-v',
181
+ `"${publishPath}:/publish:ro"`,
182
+ ...AWS_ENV_PASSTHROUGH.flatMap((name) => ['-e', name]),
183
+ AWS_CLI_IMAGE,
184
+ ...s3Operation,
185
+ ], { color });
186
+ }
187
+ });
147
188
  const awsGoDocker = (appName, plan) => __awaiter(void 0, void 0, void 0, function* () {
148
189
  if (plan.kind === 'cancelled') {
149
190
  return;
@@ -177,17 +218,14 @@ const awsGoDocker = (appName, plan) => __awaiter(void 0, void 0, void 0, functio
177
218
  console.log('\n\nRunning dockerized deploy\n\n');
178
219
  console.log('Executing for services');
179
220
  console.log(services.join(', '));
221
+ // Federated publish needs the api stack (needApi ⇒ needCdkDeploys), so any
222
+ // docker preflight it requires is already covered by these two checks.
180
223
  if (needCdkDeploys || viewServices.length > 0) {
181
224
  yield assertDockerRunning();
182
225
  }
183
226
  if (needCdkDeploys) {
184
227
  yield buildDeployerImage();
185
228
  }
186
- if (viewServices.length > 0) {
187
- // Pull up front so the views wave doesn't race N containers into pulling
188
- // the same image.
189
- yield (0, runCommand_1.runCommand)('docker', ['pull', AWS_CLI_IMAGE]);
190
- }
191
229
  // ---- Phase 1: build everything locally ----
192
230
  console.log('\n=== Phase 1: local builds ===\n');
193
231
  yield (0, hooks_1.runAppHook)(appName, 'predeploy');
@@ -203,6 +241,16 @@ const awsGoDocker = (appName, plan) => __awaiter(void 0, void 0, void 0, functio
203
241
  for (const service of qpqSynthServices) {
204
242
  yield (0, synth_1.synthCommand)([service, '--app', appName]);
205
243
  }
244
+ // Federated remotes are the backend story code, so republish them whenever the
245
+ // api stack was (re)deployed. Skips services without defineFederatedModuleStore(...).
246
+ // Detected here (after the workspace build) because it loads each service's config.
247
+ const federatedServices = needApi ? (0, qpqConfigs_1.getServiceNamesWithFederation)(appName, services) : [];
248
+ // The aws-cli image backs both the views sync (phase 4) and the federated
249
+ // publish (phase 5) waves. Pull once now so those waves don't race N containers
250
+ // into pulling the same image. Docker is already confirmed running above.
251
+ if (viewServices.length > 0 || federatedServices.length > 0) {
252
+ yield (0, runCommand_1.runCommand)('docker', ['pull', AWS_CLI_IMAGE]);
253
+ }
206
254
  if (stacks !== 'views') {
207
255
  (0, runTasks_1.assertNoFailures)('API bundling', yield (0, runTasks_1.runTasks)(services.map((service) => ({
208
256
  label: `bundle-api:${service}`,
@@ -220,6 +268,16 @@ const awsGoDocker = (appName, plan) => __awaiter(void 0, void 0, void 0, functio
220
268
  yield (0, views_1.bundleViews)(appName, service);
221
269
  }),
222
270
  })), BUILD_CONCURRENCY));
271
+ // Build the federated remotes locally now (rspack needs the workspace), so the
272
+ // publish wave only has to sync the already-built output — mirroring how views
273
+ // are bundled here and synced later.
274
+ (0, runTasks_1.assertNoFailures)('Remote bundling', yield (0, runTasks_1.runTasks)(federatedServices.map((service) => ({
275
+ label: `bundle-remote:${service}`,
276
+ run: () => __awaiter(void 0, void 0, void 0, function* () {
277
+ console.log(`Bundling federated remote: [${service}]`);
278
+ yield (0, remote_1.buildRemote)(appName, service);
279
+ }),
280
+ })), BUILD_CONCURRENCY));
223
281
  if (needCdkDeploys) {
224
282
  // One self-contained cloud assembly per service (all its stacks + staged
225
283
  // assets) — separate --output dirs so synths can run in parallel and
@@ -229,7 +287,7 @@ const awsGoDocker = (appName, plan) => __awaiter(void 0, void 0, void 0, functio
229
287
  run: () => __awaiter(void 0, void 0, void 0, function* () {
230
288
  const outputDir = assemblyDir(appName, service);
231
289
  fs_1.default.rmSync(outputDir, { recursive: true, force: true });
232
- yield (0, runCommand_1.runCommandPrefixed)(`cdk-synth:${service}`, 'npx', ['cdk', 'synth', '--all', '--quiet', '--app', `'${(0, cdkApp_1.getCdkAppCommand)()}'`, '--output', `"${outputDir}"`], {
290
+ yield (0, runCommand_1.runCommandPrefixed)(`cdk-synth:${service}`, 'npx', ['cdk', 'synth', '--quiet', '--app', `'${(0, cdkApp_1.getCdkAppCommand)()}'`, '--output', `"${outputDir}"`], {
233
291
  cwd: (0, discovery_1.getRoot)(),
234
292
  env: { DEPLOY_SERVICE_NAME: service, DEPLOY_APP_NAME: appName },
235
293
  color: (0, runCommand_1.nextPrefixColor)(),
@@ -281,6 +339,16 @@ const awsGoDocker = (appName, plan) => __awaiter(void 0, void 0, void 0, functio
281
339
  })), DEPLOY_CONCURRENCY));
282
340
  (0, timing_1.logTimeEnd)('viewsWave');
283
341
  }
342
+ // ---- Phase 5: publish the pre-built federated remotes to S3, all concurrent ----
343
+ if (federatedServices.length > 0) {
344
+ console.log('\n=== Phase 5: publish federated remotes to S3 (docker) ===\n');
345
+ (0, timing_1.logTimeStart)('publishWave');
346
+ (0, runTasks_1.assertNoFailures)('Federated publish', yield (0, runTasks_1.runTasks)(federatedServices.map((service) => ({
347
+ label: `publish:${service}`,
348
+ run: () => dockerPublishRemote((0, runCommand_1.nextPrefixColor)(), appName, service),
349
+ })), DEPLOY_CONCURRENCY));
350
+ (0, timing_1.logTimeEnd)('publishWave');
351
+ }
284
352
  (0, timing_1.logTimeEnd)('totalTime');
285
353
  });
286
354
  exports.awsGoDocker = awsGoDocker;