@go-to-k/cdkd 0.82.0 → 0.82.1

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/dist/cli.js CHANGED
@@ -71220,6 +71220,24 @@ function extractHashFromImageUri(imageUri) {
71220
71220
  // src/cli/commands/local-invoke.ts
71221
71221
  init_aws_clients();
71222
71222
 
71223
+ // src/utils/single-flight.ts
71224
+ function singleFlight(fn, onError) {
71225
+ let promise;
71226
+ return async () => {
71227
+ if (!promise) {
71228
+ promise = (async () => {
71229
+ try {
71230
+ await fn();
71231
+ } catch (err) {
71232
+ if (onError)
71233
+ onError(err);
71234
+ }
71235
+ })();
71236
+ }
71237
+ await promise;
71238
+ };
71239
+ }
71240
+
71223
71241
  // src/cli/commands/local-start-api.ts
71224
71242
  import { cpSync, mkdirSync as mkdirSync2, mkdtempSync as mkdtempSync2, readFileSync as readFileSync6, rmSync as rmSync2, writeFileSync as writeFileSync5 } from "node:fs";
71225
71243
  import { tmpdir as tmpdir2 } from "node:os";
@@ -76047,21 +76065,12 @@ async function localStartApiCommand(options) {
76047
76065
  });
76048
76066
  logger.info(`Watching ${options.output} (and ${lastAssetPaths.value.length} asset dir(s))`);
76049
76067
  }
76050
- let shuttingDown = false;
76068
+ let shutdownStarted = false;
76069
+ let firstSignal;
76070
+ let firstExitCode = 0;
76051
76071
  let forceExitArmed = false;
76052
- const shutdown = async (signal, exitCode) => {
76053
- if (shuttingDown) {
76054
- if (!forceExitArmed) {
76055
- forceExitArmed = true;
76056
- logger.warn(
76057
- `Received second ${signal}; force-exiting. Orphan containers may remain \u2014 run 'docker ps --filter name=cdkd-local-' and 'docker rm -f' to clean up.`
76058
- );
76059
- process.exit(130);
76060
- }
76061
- return;
76062
- }
76063
- shuttingDown = true;
76064
- logger.info(`Received ${signal}, shutting down...`);
76072
+ const runCleanup = singleFlight(async () => {
76073
+ logger.info(`Received ${firstSignal}, shutting down...`);
76065
76074
  if (watcher) {
76066
76075
  try {
76067
76076
  await watcher.close();
@@ -76109,7 +76118,23 @@ async function localStartApiCommand(options) {
76109
76118
  );
76110
76119
  }
76111
76120
  }
76112
- process.exit(exitCode);
76121
+ });
76122
+ const shutdown = async (signal, exitCode) => {
76123
+ if (shutdownStarted) {
76124
+ if (!forceExitArmed) {
76125
+ forceExitArmed = true;
76126
+ logger.warn(
76127
+ `Received second ${signal}; force-exiting. Orphan containers may remain \u2014 run 'docker ps --filter name=cdkd-local-' and 'docker rm -f' to clean up.`
76128
+ );
76129
+ process.exit(130);
76130
+ }
76131
+ return;
76132
+ }
76133
+ shutdownStarted = true;
76134
+ firstSignal = signal;
76135
+ firstExitCode = exitCode;
76136
+ await runCleanup();
76137
+ process.exit(firstExitCode);
76113
76138
  };
76114
76139
  process.on("SIGINT", () => {
76115
76140
  void shutdown("SIGINT", 130);
@@ -78089,44 +78114,49 @@ async function localInvokeCommand(target, options) {
78089
78114
  let containerId;
78090
78115
  let stopLogs;
78091
78116
  let sigintHandler;
78092
- const cleanup = async () => {
78093
- if (stopLogs) {
78094
- try {
78095
- stopLogs();
78096
- } catch (err) {
78097
- getLogger().debug(
78098
- `streamLogs stop failed: ${err instanceof Error ? err.message : String(err)}`
78099
- );
78117
+ const cleanup = singleFlight(
78118
+ async () => {
78119
+ if (stopLogs) {
78120
+ try {
78121
+ stopLogs();
78122
+ } catch (err) {
78123
+ getLogger().debug(
78124
+ `streamLogs stop failed: ${err instanceof Error ? err.message : String(err)}`
78125
+ );
78126
+ }
78100
78127
  }
78101
- }
78102
- if (containerId) {
78103
- try {
78104
- await removeContainer(containerId);
78105
- } catch (err) {
78106
- getLogger().debug(
78107
- `removeContainer(${containerId}) failed: ${err instanceof Error ? err.message : String(err)}`
78108
- );
78128
+ if (containerId) {
78129
+ try {
78130
+ await removeContainer(containerId);
78131
+ } catch (err) {
78132
+ getLogger().debug(
78133
+ `removeContainer(${containerId}) failed: ${err instanceof Error ? err.message : String(err)}`
78134
+ );
78135
+ }
78109
78136
  }
78110
- }
78111
- if (imagePlan?.inlineTmpDir) {
78112
- try {
78113
- rmSync3(imagePlan.inlineTmpDir, { recursive: true, force: true });
78114
- } catch (err) {
78115
- getLogger().debug(
78116
- `Failed to remove inline-code tmpdir ${imagePlan.inlineTmpDir}: ${err instanceof Error ? err.message : String(err)}`
78117
- );
78137
+ if (imagePlan?.inlineTmpDir) {
78138
+ try {
78139
+ rmSync3(imagePlan.inlineTmpDir, { recursive: true, force: true });
78140
+ } catch (err) {
78141
+ getLogger().debug(
78142
+ `Failed to remove inline-code tmpdir ${imagePlan.inlineTmpDir}: ${err instanceof Error ? err.message : String(err)}`
78143
+ );
78144
+ }
78118
78145
  }
78119
- }
78120
- if (imagePlan?.layersTmpDir) {
78121
- try {
78122
- rmSync3(imagePlan.layersTmpDir, { recursive: true, force: true });
78123
- } catch (err) {
78124
- getLogger().debug(
78125
- `Failed to remove merged-layers tmpdir ${imagePlan.layersTmpDir}: ${err instanceof Error ? err.message : String(err)}`
78126
- );
78146
+ if (imagePlan?.layersTmpDir) {
78147
+ try {
78148
+ rmSync3(imagePlan.layersTmpDir, { recursive: true, force: true });
78149
+ } catch (err) {
78150
+ getLogger().debug(
78151
+ `Failed to remove merged-layers tmpdir ${imagePlan.layersTmpDir}: ${err instanceof Error ? err.message : String(err)}`
78152
+ );
78153
+ }
78127
78154
  }
78155
+ },
78156
+ (err) => {
78157
+ getLogger().debug(`cleanup failed: ${err instanceof Error ? err.message : String(err)}`);
78128
78158
  }
78129
- };
78159
+ );
78130
78160
  try {
78131
78161
  await applyRoleArnIfSet({ roleArn: options.roleArn, region: options.region });
78132
78162
  await ensureDockerAvailable();
@@ -78658,7 +78688,7 @@ function reorderArgs(argv) {
78658
78688
  }
78659
78689
  async function main() {
78660
78690
  const program = new Command17();
78661
- program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.82.0");
78691
+ program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.82.1");
78662
78692
  program.addCommand(createBootstrapCommand());
78663
78693
  program.addCommand(createSynthCommand());
78664
78694
  program.addCommand(createListCommand());