@devkong/cli 0.0.67-alpha.6 → 0.0.67-alpha.7
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/index.js
CHANGED
|
@@ -63521,7 +63521,6 @@ function validateName(value) {
|
|
|
63521
63521
|
}
|
|
63522
63522
|
}
|
|
63523
63523
|
var DEPLOY_STEPS = [
|
|
63524
|
-
"start extension set alias",
|
|
63525
63524
|
"create deployment",
|
|
63526
63525
|
"health check",
|
|
63527
63526
|
"save deployment details",
|
|
@@ -63550,6 +63549,7 @@ var SetAliasCommand = class {
|
|
|
63550
63549
|
async execute(aliasName, extensionVersion, timeoutSeconds) {
|
|
63551
63550
|
validateName(aliasName);
|
|
63552
63551
|
const startedAt = utcNow(DEFAULT_TIMEZONE);
|
|
63552
|
+
const steps = createDeploySteps();
|
|
63553
63553
|
await new Listr(
|
|
63554
63554
|
[
|
|
63555
63555
|
{
|
|
@@ -63597,60 +63597,12 @@ var SetAliasCommand = class {
|
|
|
63597
63597
|
};
|
|
63598
63598
|
await this.publicClient.assignExtensionAlias(ctx.kongJson.id, alias);
|
|
63599
63599
|
task.output = joinUrlAndPath(this.profile.kongBaseUrl, "/extensions/aliases");
|
|
63600
|
+
this.pollDeploymentSteps(steps, ctx.kongJson.id, aliasName, startedAt, timeoutSeconds);
|
|
63600
63601
|
},
|
|
63601
63602
|
rendererOptions: { persistentOutput: true }
|
|
63602
63603
|
},
|
|
63603
|
-
|
|
63604
|
-
|
|
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
|
-
}
|
|
63604
|
+
// Known deployment steps as a checklist; each ticks off on its event.
|
|
63605
|
+
...steps.map((step) => ({ title: step.action, task: () => step.done }))
|
|
63654
63606
|
],
|
|
63655
63607
|
{
|
|
63656
63608
|
renderer: "default",
|
|
@@ -63662,6 +63614,47 @@ var SetAliasCommand = class {
|
|
|
63662
63614
|
}
|
|
63663
63615
|
).run();
|
|
63664
63616
|
}
|
|
63617
|
+
/**
|
|
63618
|
+
* Poll the deployment audit log and settle one step per matching event. Runs
|
|
63619
|
+
* detached from the task list; it settles a step as its event arrives and
|
|
63620
|
+
* fails the rest on a failed/timed-out deployment, stopping on the failed or
|
|
63621
|
+
* "deployment completed" event (poll terminal).
|
|
63622
|
+
*/
|
|
63623
|
+
pollDeploymentSteps(steps, basedOnId, aliasName, createdAfter, timeoutSeconds) {
|
|
63624
|
+
const pending = new Map(steps.map((step) => [step.action, step]));
|
|
63625
|
+
const seen = /* @__PURE__ */ new Set();
|
|
63626
|
+
void pollDeployment(this.managementClient, {
|
|
63627
|
+
objectType: "EXTENSION_ALIAS",
|
|
63628
|
+
basedOnId,
|
|
63629
|
+
aliasName,
|
|
63630
|
+
createdAfter,
|
|
63631
|
+
timeoutSeconds,
|
|
63632
|
+
onProgress: (progress) => {
|
|
63633
|
+
for (const event of [...progress.events].reverse()) {
|
|
63634
|
+
if (seen.has(event.action)) {
|
|
63635
|
+
continue;
|
|
63636
|
+
}
|
|
63637
|
+
seen.add(event.action);
|
|
63638
|
+
pending.get(event.action)?.settle();
|
|
63639
|
+
}
|
|
63640
|
+
}
|
|
63641
|
+
}).then((result) => {
|
|
63642
|
+
if (result.status === "failed") {
|
|
63643
|
+
const error = new AppError(deploymentErrorMessage(result.events));
|
|
63644
|
+
steps.forEach((step) => step.settle(error));
|
|
63645
|
+
} else if (result.timedOut) {
|
|
63646
|
+
const error = new AppError(
|
|
63647
|
+
`Still deploying after ${result.waitedSeconds}s \u2014 check the UI for completion.`
|
|
63648
|
+
);
|
|
63649
|
+
steps.forEach((step) => step.settle(error));
|
|
63650
|
+
} else {
|
|
63651
|
+
steps.forEach((step) => step.settle());
|
|
63652
|
+
}
|
|
63653
|
+
}).catch((error) => {
|
|
63654
|
+
const wrapped = error instanceof Error ? error : new AppError(String(error));
|
|
63655
|
+
steps.forEach((step) => step.settle(wrapped));
|
|
63656
|
+
});
|
|
63657
|
+
}
|
|
63665
63658
|
};
|
|
63666
63659
|
|
|
63667
63660
|
// packages/kong-cli/src/common/cli.ts
|
package/package.json
CHANGED
|
@@ -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
|
}
|