@devkong/cli 0.0.67-alpha.5 → 0.0.67-alpha.6

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 (2) hide show
  1. package/index.js +60 -21
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -63432,7 +63432,7 @@ var PublishVersionCommand = class {
63432
63432
 
63433
63433
  // packages/kong-cli/src/common/deployment.ts
63434
63434
  var DEPLOY_SUCCESS_ACTIONS = /* @__PURE__ */ new Set(["deployment completed"]);
63435
- var DEPLOY_FAILURE_ACTIONS = /* @__PURE__ */ new Set(["deployment failed", "save deployment details"]);
63435
+ var DEPLOY_FAILURE_ACTIONS = /* @__PURE__ */ new Set(["deployment failed"]);
63436
63436
  function isFailureEvent(event) {
63437
63437
  return event.eventType === "error" || DEPLOY_FAILURE_ACTIONS.has(event.action);
63438
63438
  }
@@ -63520,6 +63520,26 @@ function validateName(value) {
63520
63520
  );
63521
63521
  }
63522
63522
  }
63523
+ var DEPLOY_STEPS = [
63524
+ "start extension set alias",
63525
+ "create deployment",
63526
+ "health check",
63527
+ "save deployment details",
63528
+ "deployment completed"
63529
+ ];
63530
+ function createDeploySteps() {
63531
+ return DEPLOY_STEPS.map((action) => {
63532
+ const handlers = {
63533
+ resolve: () => void 0,
63534
+ reject: () => void 0
63535
+ };
63536
+ const done = new Promise((resolve2, reject) => {
63537
+ handlers.resolve = resolve2;
63538
+ handlers.reject = reject;
63539
+ });
63540
+ return { action, done, settle: (error) => error ? handlers.reject(error) : handlers.resolve() };
63541
+ });
63542
+ }
63523
63543
  var SetAliasCommand = class {
63524
63544
  constructor(profile) {
63525
63545
  this.profile = profile;
@@ -63582,35 +63602,54 @@ var SetAliasCommand = class {
63582
63602
  },
63583
63603
  {
63584
63604
  title: "Wait for deployment",
63585
- task: async (ctx, task) => {
63586
- let stopped = false;
63587
- const result = await pollDeployment(this.managementClient, {
63605
+ // Render the known deployment steps as a checklist and tick each one
63606
+ // off as its audit event arrives. Polling runs alongside the subtask
63607
+ // list, settling a step per event and failing the rest on error; it
63608
+ // stops on the failed or "deployment completed" event (poll terminal).
63609
+ task: (ctx, task) => {
63610
+ const steps = createDeploySteps();
63611
+ const pending = new Map(steps.map((step) => [step.action, step]));
63612
+ const seen = /* @__PURE__ */ new Set();
63613
+ void pollDeployment(this.managementClient, {
63588
63614
  objectType: "EXTENSION_ALIAS",
63589
63615
  basedOnId: ctx.kongJson.id,
63590
63616
  aliasName,
63591
63617
  createdAfter: startedAt,
63592
63618
  timeoutSeconds,
63593
63619
  onProgress: (progress) => {
63594
- if (stopped) {
63595
- return;
63596
- }
63597
- const latest = progress.events[0];
63598
- if (latest) {
63599
- task.output = `${latest.eventType === "error" ? "\u2717" : "\u2713"} ${latest.action}`;
63600
- }
63601
- if (progress.status === "failed") {
63602
- stopped = true;
63620
+ for (const event of [...progress.events].reverse()) {
63621
+ if (seen.has(event.action)) {
63622
+ continue;
63623
+ }
63624
+ seen.add(event.action);
63625
+ pending.get(event.action)?.settle();
63603
63626
  }
63604
63627
  }
63628
+ }).then((result) => {
63629
+ if (result.status === "failed") {
63630
+ const error = new AppError(deploymentErrorMessage(result.events));
63631
+ steps.forEach((step) => step.settle(error));
63632
+ } else if (result.timedOut) {
63633
+ const error = new AppError(
63634
+ `Still deploying after ${result.waitedSeconds}s \u2014 check the UI for completion.`
63635
+ );
63636
+ steps.forEach((step) => step.settle(error));
63637
+ } else {
63638
+ steps.forEach((step) => step.settle());
63639
+ }
63640
+ }).catch((error) => {
63641
+ const wrapped = error instanceof Error ? error : new AppError(String(error));
63642
+ steps.forEach((step) => step.settle(wrapped));
63605
63643
  });
63606
- if (result.status === "failed") {
63607
- throw new AppError(deploymentErrorMessage(result.events));
63608
- }
63609
- if (result.timedOut) {
63610
- task.output = `Still deploying after ${result.waitedSeconds}s \u2014 check the UI for completion.`;
63611
- }
63612
- },
63613
- rendererOptions: { persistentOutput: true }
63644
+ return task.newListr(
63645
+ steps.map((step) => ({ title: step.action, task: () => step.done })),
63646
+ {
63647
+ concurrent: false,
63648
+ exitOnError: true,
63649
+ rendererOptions: { collapseSubtasks: false }
63650
+ }
63651
+ );
63652
+ }
63614
63653
  }
63615
63654
  ],
63616
63655
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devkong/cli",
3
- "version": "0.0.67-alpha.5",
3
+ "version": "0.0.67-alpha.6",
4
4
  "type": "commonjs",
5
5
  "main": "./index.js",
6
6
  "typings": "./index.d.ts",