@devkong/cli 0.0.15 → 0.0.17-0
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/assets/python-install.bat +1 -2
- package/index.js +72 -15
- package/package.json +1 -1
- package/packages/kong-cli/src/commands/listAliasesCommand.d.ts +8 -0
- package/packages/kong-cli/src/commands/{listExtensionSnapshotCommand.d.ts → listVersionsCommand.d.ts} +1 -1
- package/packages/kong-cli/src/commands/{setExtensionAliasCommand.d.ts → setAliasCommand.d.ts} +1 -1
- package/packages/kong-cli/src/common/profile.d.ts +1 -0
- package/packages/kong-cli/src/services/managementClient.d.ts +2 -1
- package/packages/kong-spec/src/lib/kongSpec.d.ts +1 -0
- package/packages/kong-ts-contract/src/index.d.ts +1 -0
- package/packages/kong-ts-contract/src/lib/appTestCase.d.ts +3 -1
- package/packages/kong-ts-contract/src/lib/appTestResult.d.ts +12 -0
package/index.js
CHANGED
|
@@ -66902,9 +66902,12 @@ function getProfile(profileName = "default") {
|
|
|
66902
66902
|
const profile = availableProfiles[profileName] || {
|
|
66903
66903
|
kongBaseUrl: urlText("")
|
|
66904
66904
|
};
|
|
66905
|
-
profile.kongBaseUrl = urlText(optionalEnv("KONG_BASE_URL"))
|
|
66905
|
+
profile.kongBaseUrl = profile.kongBaseUrl || urlText(optionalEnv("KONG_BASE_URL"));
|
|
66906
66906
|
return profile;
|
|
66907
66907
|
}
|
|
66908
|
+
function printProfile(profile) {
|
|
66909
|
+
console.info(`Current profile=${profile}, baseUrl=${getProfile(profile).kongBaseUrl}`);
|
|
66910
|
+
}
|
|
66908
66911
|
|
|
66909
66912
|
// packages/kong-cli/src/commands/configureCommand.ts
|
|
66910
66913
|
var ConfigureCommand = class {
|
|
@@ -67165,7 +67168,8 @@ var GenerateCommand = class {
|
|
|
67165
67168
|
id,
|
|
67166
67169
|
sdk,
|
|
67167
67170
|
name: extensionName,
|
|
67168
|
-
ownership: ["devkong"]
|
|
67171
|
+
ownership: ["devkong"],
|
|
67172
|
+
alias: {}
|
|
67169
67173
|
});
|
|
67170
67174
|
await (0, import_create_nx_workspace.createWorkspace)(`@devkong/cli-nx@${presetVersion}`, {
|
|
67171
67175
|
name: extensionName,
|
|
@@ -69695,7 +69699,6 @@ var InstallCommand = class {
|
|
|
69695
69699
|
title: "Installing dependencies with pip",
|
|
69696
69700
|
task: async (_2, task) => {
|
|
69697
69701
|
const scriptPath = this.scriptPath();
|
|
69698
|
-
task.output = `${scriptPath} ${workspaceDirectory}`;
|
|
69699
69702
|
await spawnCommand(
|
|
69700
69703
|
`${scriptPath} ${workspaceDirectory}`,
|
|
69701
69704
|
new ListrTaskLogger(task, this.verbose ? 3 /* DEBUG */ : 0 /* INFO */),
|
|
@@ -69754,10 +69757,58 @@ var ManagementClient = class {
|
|
|
69754
69757
|
const url2 = joinUrlAndPath(this.baseUrl, "v1/extensions", extensionId, "/snapshots/versions");
|
|
69755
69758
|
return (await axios_default.get(url2, API_HEADERS)).data;
|
|
69756
69759
|
}
|
|
69760
|
+
async getExtensionSnapshotAliases(extensionId) {
|
|
69761
|
+
const url2 = joinUrlAndPath(this.baseUrl, "v1/extensions", extensionId, "/aliases");
|
|
69762
|
+
return (await axios_default.get(url2, API_HEADERS)).data;
|
|
69763
|
+
}
|
|
69757
69764
|
};
|
|
69758
69765
|
|
|
69759
|
-
// packages/kong-cli/src/commands/
|
|
69760
|
-
var
|
|
69766
|
+
// packages/kong-cli/src/commands/listAliasesCommand.ts
|
|
69767
|
+
var ListAliasesCommand = class {
|
|
69768
|
+
constructor(profile, verbose) {
|
|
69769
|
+
this.profile = profile;
|
|
69770
|
+
this.verbose = verbose;
|
|
69771
|
+
this.managementClient = new ManagementClient(this.profile.kongBaseUrl);
|
|
69772
|
+
}
|
|
69773
|
+
async execute() {
|
|
69774
|
+
await new Listr(
|
|
69775
|
+
[
|
|
69776
|
+
{
|
|
69777
|
+
title: "List extension aliases",
|
|
69778
|
+
task: async (ctx, task) => {
|
|
69779
|
+
const kongJson = getKongJson();
|
|
69780
|
+
const aliases = await this.managementClient.getExtensionSnapshotAliases(kongJson.id);
|
|
69781
|
+
if (aliases.length === 0) {
|
|
69782
|
+
task.output = "No aliases available";
|
|
69783
|
+
} else {
|
|
69784
|
+
const result = [];
|
|
69785
|
+
for (const alias of aliases) {
|
|
69786
|
+
for (const item of alias.use) {
|
|
69787
|
+
result.push(`${alias.name}, ${item.snapshot.version}, ${item.balance}%`);
|
|
69788
|
+
}
|
|
69789
|
+
}
|
|
69790
|
+
task.output = result.join("\n");
|
|
69791
|
+
}
|
|
69792
|
+
},
|
|
69793
|
+
rendererOptions: {
|
|
69794
|
+
persistentOutput: true
|
|
69795
|
+
}
|
|
69796
|
+
}
|
|
69797
|
+
],
|
|
69798
|
+
{
|
|
69799
|
+
renderer: "default",
|
|
69800
|
+
rendererOptions: {
|
|
69801
|
+
logger: new ListrLogger({
|
|
69802
|
+
processOutput: new ProcessOutput(process.stderr, process.stderr)
|
|
69803
|
+
})
|
|
69804
|
+
}
|
|
69805
|
+
}
|
|
69806
|
+
).run();
|
|
69807
|
+
}
|
|
69808
|
+
};
|
|
69809
|
+
|
|
69810
|
+
// packages/kong-cli/src/commands/listVersionsCommand.ts
|
|
69811
|
+
var ListVersionsCommand = class {
|
|
69761
69812
|
constructor(profile, verbose) {
|
|
69762
69813
|
this.verbose = verbose;
|
|
69763
69814
|
this.managementClient = new ManagementClient(profile.kongBaseUrl);
|
|
@@ -69951,7 +70002,7 @@ var PublicClient = class {
|
|
|
69951
70002
|
}
|
|
69952
70003
|
};
|
|
69953
70004
|
|
|
69954
|
-
// packages/kong-cli/src/commands/
|
|
70005
|
+
// packages/kong-cli/src/commands/setAliasCommand.ts
|
|
69955
70006
|
function validateName(value) {
|
|
69956
70007
|
if (isEmpty(value)) {
|
|
69957
70008
|
throw new AppError("The alias name should not be empty.");
|
|
@@ -69962,7 +70013,7 @@ function validateName(value) {
|
|
|
69962
70013
|
);
|
|
69963
70014
|
}
|
|
69964
70015
|
}
|
|
69965
|
-
var
|
|
70016
|
+
var SetAliasCommand = class {
|
|
69966
70017
|
constructor(profile) {
|
|
69967
70018
|
this.publicClient = new PublicClient(profile.kongBaseUrl);
|
|
69968
70019
|
this.managementClient = new ManagementClient(profile.kongBaseUrl);
|
|
@@ -70067,6 +70118,7 @@ async function main() {
|
|
|
70067
70118
|
"Build and automatically tag the current code with an incremented version, ready for selection in extension aliases"
|
|
70068
70119
|
).addOption(new Option("--profile <name>", "Configured Kong profile to use").default("default")).addOption(new Option("--verbose", "Show full logs during command execution")).addOption(new Option("--notes [text]", "Optional version notes").default("")).action(async (options) => {
|
|
70069
70120
|
try {
|
|
70121
|
+
printProfile(options.profile);
|
|
70070
70122
|
const kongJson = getKongJson();
|
|
70071
70123
|
await new PublishVersionCommand(getProfile(options.profile), options.verbose).execute(
|
|
70072
70124
|
kongJson.name,
|
|
@@ -70078,24 +70130,28 @@ async function main() {
|
|
|
70078
70130
|
});
|
|
70079
70131
|
const listVersionsCommand = new Command("list-versions").description("List available versions").addOption(new Option("--profile <name>", "Configured Kong profile to use").default("default")).addOption(new Option("--verbose", "Show full logs during command execution")).action(async (options) => {
|
|
70080
70132
|
try {
|
|
70081
|
-
|
|
70082
|
-
|
|
70083
|
-
options.verbose
|
|
70084
|
-
).execute();
|
|
70133
|
+
printProfile(options.profile);
|
|
70134
|
+
await new ListVersionsCommand(getProfile(options.profile), options.verbose).execute();
|
|
70085
70135
|
} catch (ex) {
|
|
70086
70136
|
printError("list-versions command failed", ex);
|
|
70087
70137
|
}
|
|
70088
70138
|
});
|
|
70089
70139
|
const setAliasCommand = new Command("set-alias").description("Assign alias to an extension").argument("alias-name", "Alias name to assign").argument("extension-version", "Extension version to use. Should be one of existing versions").addOption(new Option("--profile <name>", "Configured Kong profile to use").default("default")).action(async (aliasName, extensionVersion, options) => {
|
|
70090
70140
|
try {
|
|
70091
|
-
|
|
70092
|
-
|
|
70093
|
-
extensionVersion
|
|
70094
|
-
);
|
|
70141
|
+
printProfile(options.profile);
|
|
70142
|
+
await new SetAliasCommand(getProfile(options.profile)).execute(aliasName, extensionVersion);
|
|
70095
70143
|
} catch (ex) {
|
|
70096
70144
|
printError("set-alias command failed", ex);
|
|
70097
70145
|
}
|
|
70098
70146
|
});
|
|
70147
|
+
const listAliasesCommand = new Command("list-aliases").description("List available extension aliases").addOption(new Option("--profile <name>", "Configured Kong profile to use").default("default")).action(async (options) => {
|
|
70148
|
+
try {
|
|
70149
|
+
printProfile(options.profile);
|
|
70150
|
+
await new ListAliasesCommand(getProfile(options.profile), options.verbose).execute();
|
|
70151
|
+
} catch (ex) {
|
|
70152
|
+
printError("list-aliases command failed", ex);
|
|
70153
|
+
}
|
|
70154
|
+
});
|
|
70099
70155
|
const cli = new Command().version(getPresetVersion()).description("CLI to support creating and publishing Kong extensions");
|
|
70100
70156
|
cli.addCommand(generateCommand);
|
|
70101
70157
|
cli.addCommand(configureCommand);
|
|
@@ -70103,6 +70159,7 @@ async function main() {
|
|
|
70103
70159
|
cli.addCommand(publishVersionCommand);
|
|
70104
70160
|
cli.addCommand(listVersionsCommand);
|
|
70105
70161
|
cli.addCommand(setAliasCommand);
|
|
70162
|
+
cli.addCommand(listAliasesCommand);
|
|
70106
70163
|
cli.parse(process.argv);
|
|
70107
70164
|
}
|
|
70108
70165
|
main();
|
package/package.json
CHANGED
|
@@ -7,3 +7,4 @@ export type ConfigProfiles = Record<ProfileName, Profile>;
|
|
|
7
7
|
export declare function loadProfiles(): ConfigProfiles;
|
|
8
8
|
export declare function saveProfiles(profiles: ConfigProfiles): void;
|
|
9
9
|
export declare function getProfile(profileName?: string): Profile;
|
|
10
|
+
export declare function printProfile(profile: string): void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AppExtension, AppExtensionSnapshot, AppExtensionSnapshotDetails } from "@kong/contract";
|
|
1
|
+
import { AppExtension, AppExtensionAlias, AppExtensionSnapshot, AppExtensionSnapshotDetails } from "@kong/contract";
|
|
2
2
|
import { Optional, UrlText } from "@kong/ts";
|
|
3
3
|
export declare class ManagementClient {
|
|
4
4
|
private readonly baseUrl;
|
|
@@ -6,4 +6,5 @@ export declare class ManagementClient {
|
|
|
6
6
|
createExtensionSnapshot(extensionId: AppExtension["id"], extensionName: AppExtension["name"], snapshot: Omit<AppExtensionSnapshotDetails, "id">): Promise<void>;
|
|
7
7
|
getExtensionSnapshot(extensionName: AppExtension["name"], extensionSnapshotVersion: AppExtensionSnapshot["version"]): Promise<Optional<AppExtensionSnapshotDetails>>;
|
|
8
8
|
getExtensionSnapshotVersions(extensionId: AppExtension["id"]): Promise<AppExtensionSnapshot[]>;
|
|
9
|
+
getExtensionSnapshotAliases(extensionId: AppExtension["id"]): Promise<AppExtensionAlias[]>;
|
|
9
10
|
}
|
|
@@ -111,6 +111,7 @@ export interface KongSpecStateCompensate extends KongSpecStateBase, KongSpecSupp
|
|
|
111
111
|
}
|
|
112
112
|
export interface KongSpecCondition extends KongSpecSupportsTransition, KongSpecSupportsTransition {
|
|
113
113
|
id: Distinct<string, "KongSpecConditionId">;
|
|
114
|
+
description: string;
|
|
114
115
|
match: JqFilter;
|
|
115
116
|
}
|
|
116
117
|
export interface KongSpecStateSwitch extends KongSpecStateBase, KongSpecCanBeUsedForCompensation, KongSpecSupportsTransition {
|
|
@@ -18,5 +18,6 @@ export type { AppProject } from "./lib/appProject";
|
|
|
18
18
|
export type { AppTestCase } from "./lib/appTestCase";
|
|
19
19
|
export type { AppTestCaseDetails } from "./lib/appTestCaseDetails";
|
|
20
20
|
export type { AppTestCaseMatchFeature } from "./lib/appTestCaseMatchFeature";
|
|
21
|
+
export type { AppTestResult } from "./lib/appTestResult";
|
|
21
22
|
export type { AppWorkspace } from "./lib/appWorkspace";
|
|
22
23
|
export type { SdkExtensionAlias } from "./lib/sdkExtensionAlias";
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { Entity, User, UtcDateTime } from "@kong/ts";
|
|
1
|
+
import { Entity, JsonObject, User, UtcDateTime } from "@kong/ts";
|
|
2
2
|
export interface AppTestCase extends Entity {
|
|
3
3
|
id: number;
|
|
4
4
|
title: string;
|
|
5
5
|
tags: string[];
|
|
6
|
+
inputPayload: JsonObject;
|
|
7
|
+
expectedResult: JsonObject;
|
|
6
8
|
created: UtcDateTime;
|
|
7
9
|
updated: UtcDateTime;
|
|
8
10
|
createdBy: User["name"];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { JsonObject, User, UtcDateTime } from "@kong/ts";
|
|
2
|
+
import { AppTestCase } from "./appTestCase";
|
|
3
|
+
export interface AppTestResult {
|
|
4
|
+
id?: number;
|
|
5
|
+
testCaseId: AppTestCase["id"];
|
|
6
|
+
testRunId: number;
|
|
7
|
+
actualResult: JsonObject;
|
|
8
|
+
created: UtcDateTime;
|
|
9
|
+
updated: UtcDateTime;
|
|
10
|
+
createdBy: User["name"];
|
|
11
|
+
updatedBy: User["name"];
|
|
12
|
+
}
|