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

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.
@@ -1,4 +1,5 @@
1
1
  #!/bin/bash
2
+ set -e
2
3
 
3
4
  EXTENSION_DIR=$1
4
5
 
@@ -8,18 +9,17 @@ else
8
9
  PYTHON_CMD="python3"
9
10
  fi
10
11
 
11
- if [ -x "$(command -v python)" ]; then
12
- PIP_CMD="pip"
13
- else
14
- PIP_CMD="pip3"
15
- fi
16
-
17
12
  cd "$EXTENSION_DIR" || exit
18
13
 
19
- $PYTHON_CMD -m venv .venv
14
+ # Recreate the venv from scratch so a stale interpreter path (e.g. left over
15
+ # after a Python/nvm/pyenv upgrade) can't leave pip pointing at a missing
16
+ # binary, which fails with "cannot execute: required file not found".
17
+ $PYTHON_CMD -m venv --clear .venv
20
18
 
21
19
  source .venv/bin/activate
22
20
 
23
- $PIP_CMD freeze > requirements-lock.txt
24
- $PIP_CMD install --default-timeout=120 -r requirements-dev.txt -r requirements.txt
25
- $PIP_CMD freeze > requirements-lock.txt
21
+ # Invoke pip via `python -m pip` rather than the pip/pip3 wrapper so we don't
22
+ # depend on the wrapper script's (possibly stale) shebang.
23
+ python -m pip freeze > requirements-lock.txt
24
+ python -m pip install --default-timeout=120 -r requirements-dev.txt -r requirements.txt
25
+ python -m pip freeze > requirements-lock.txt
package/index.js CHANGED
@@ -63521,9 +63521,7 @@ function validateName(value) {
63521
63521
  }
63522
63522
  }
63523
63523
  var DEPLOY_STEPS = [
63524
- "start extension set alias",
63525
63524
  "create deployment",
63526
- "health check",
63527
63525
  "save deployment details",
63528
63526
  "deployment completed"
63529
63527
  ];
@@ -63550,6 +63548,7 @@ var SetAliasCommand = class {
63550
63548
  async execute(aliasName, extensionVersion, timeoutSeconds) {
63551
63549
  validateName(aliasName);
63552
63550
  const startedAt = utcNow(DEFAULT_TIMEZONE);
63551
+ const steps = createDeploySteps();
63553
63552
  await new Listr(
63554
63553
  [
63555
63554
  {
@@ -63596,61 +63595,12 @@ var SetAliasCommand = class {
63596
63595
  updatedBy: ""
63597
63596
  };
63598
63597
  await this.publicClient.assignExtensionAlias(ctx.kongJson.id, alias);
63599
- task.output = joinUrlAndPath(this.profile.kongBaseUrl, "/extensions/aliases");
63598
+ this.pollDeploymentSteps(steps, ctx.kongJson.id, aliasName, startedAt, timeoutSeconds);
63600
63599
  },
63601
63600
  rendererOptions: { persistentOutput: true }
63602
63601
  },
63603
- {
63604
- title: "Wait for deployment",
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, {
63614
- objectType: "EXTENSION_ALIAS",
63615
- basedOnId: ctx.kongJson.id,
63616
- aliasName,
63617
- createdAfter: startedAt,
63618
- timeoutSeconds,
63619
- onProgress: (progress) => {
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();
63626
- }
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));
63643
- });
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
- }
63653
- }
63602
+ // Known deployment steps as a checklist; each ticks off on its event.
63603
+ ...steps.map((step) => ({ title: step.action, task: () => step.done }))
63654
63604
  ],
63655
63605
  {
63656
63606
  renderer: "default",
@@ -63662,6 +63612,47 @@ var SetAliasCommand = class {
63662
63612
  }
63663
63613
  ).run();
63664
63614
  }
63615
+ /**
63616
+ * Poll the deployment audit log and settle one step per matching event. Runs
63617
+ * detached from the task list; it settles a step as its event arrives and
63618
+ * fails the rest on a failed/timed-out deployment, stopping on the failed or
63619
+ * "deployment completed" event (poll terminal).
63620
+ */
63621
+ pollDeploymentSteps(steps, basedOnId, aliasName, createdAfter, timeoutSeconds) {
63622
+ const pending = new Map(steps.map((step) => [step.action, step]));
63623
+ const seen = /* @__PURE__ */ new Set();
63624
+ void pollDeployment(this.managementClient, {
63625
+ objectType: "EXTENSION_ALIAS",
63626
+ basedOnId,
63627
+ aliasName,
63628
+ createdAfter,
63629
+ timeoutSeconds,
63630
+ onProgress: (progress) => {
63631
+ for (const event of [...progress.events].reverse()) {
63632
+ if (seen.has(event.action)) {
63633
+ continue;
63634
+ }
63635
+ seen.add(event.action);
63636
+ pending.get(event.action)?.settle();
63637
+ }
63638
+ }
63639
+ }).then((result) => {
63640
+ if (result.status === "failed") {
63641
+ const error = new AppError(deploymentErrorMessage(result.events));
63642
+ steps.forEach((step) => step.settle(error));
63643
+ } else if (result.timedOut) {
63644
+ const error = new AppError(
63645
+ `Still deploying after ${result.waitedSeconds}s \u2014 check the UI for completion.`
63646
+ );
63647
+ steps.forEach((step) => step.settle(error));
63648
+ } else {
63649
+ steps.forEach((step) => step.settle());
63650
+ }
63651
+ }).catch((error) => {
63652
+ const wrapped = error instanceof Error ? error : new AppError(String(error));
63653
+ steps.forEach((step) => step.settle(wrapped));
63654
+ });
63655
+ }
63665
63656
  };
63666
63657
 
63667
63658
  // packages/kong-cli/src/common/cli.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devkong/cli",
3
- "version": "0.0.67-alpha.6",
3
+ "version": "0.0.67-alpha.8",
4
4
  "type": "commonjs",
5
5
  "main": "./index.js",
6
6
  "typings": "./index.d.ts",
@@ -5,4 +5,11 @@ export declare class SetAliasCommand {
5
5
  private managementClient;
6
6
  constructor(profile: Profile);
7
7
  execute(aliasName: string, extensionVersion: number, timeoutSeconds: number): Promise<void>;
8
+ /**
9
+ * Poll the deployment audit log and settle one step per matching event. Runs
10
+ * detached from the task list; it settles a step as its event arrives and
11
+ * fails the rest on a failed/timed-out deployment, stopping on the failed or
12
+ * "deployment completed" event (poll terminal).
13
+ */
14
+ private pollDeploymentSteps;
8
15
  }