@devkong/cli 0.0.16 → 0.0.18-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.
@@ -23,5 +23,4 @@ cd %EXTENSION_DIR%
23
23
 
24
24
  call .venv\Scripts\activate.bat
25
25
 
26
- %PIP_CMD% install -r requirements.txt
27
- %PIP_CMD% install -r requirements-dev.txt
26
+ %PIP_CMD% install -r requirements.txt -r requirements-dev.txt
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")) || profile.kongBaseUrl;
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 {
@@ -69696,7 +69699,6 @@ var InstallCommand = class {
69696
69699
  title: "Installing dependencies with pip",
69697
69700
  task: async (_2, task) => {
69698
69701
  const scriptPath = this.scriptPath();
69699
- task.output = `${scriptPath} ${workspaceDirectory}`;
69700
69702
  await spawnCommand(
69701
69703
  `${scriptPath} ${workspaceDirectory}`,
69702
69704
  new ListrTaskLogger(task, this.verbose ? 3 /* DEBUG */ : 0 /* INFO */),
@@ -69755,10 +69757,58 @@ var ManagementClient = class {
69755
69757
  const url2 = joinUrlAndPath(this.baseUrl, "v1/extensions", extensionId, "/snapshots/versions");
69756
69758
  return (await axios_default.get(url2, API_HEADERS)).data;
69757
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
+ }
69764
+ };
69765
+
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
+ }
69758
69808
  };
69759
69809
 
69760
- // packages/kong-cli/src/commands/listExtensionSnapshotCommand.ts
69761
- var ListExtensionSnapshotCommand = class {
69810
+ // packages/kong-cli/src/commands/listVersionsCommand.ts
69811
+ var ListVersionsCommand = class {
69762
69812
  constructor(profile, verbose) {
69763
69813
  this.verbose = verbose;
69764
69814
  this.managementClient = new ManagementClient(profile.kongBaseUrl);
@@ -69816,6 +69866,10 @@ var PublishVersionCommand = class {
69816
69866
  constructor(profile, verbose = false) {
69817
69867
  this.verbose = verbose;
69818
69868
  this.isWin = process.platform === "win32";
69869
+ this.defaultRendererOptions = {
69870
+ bottomBar: this.verbose ? Infinity : true,
69871
+ persistentOutput: true
69872
+ };
69819
69873
  this.registryClient = new RegistryClient(profile.kongBaseUrl);
69820
69874
  this.managementClient = new ManagementClient(profile.kongBaseUrl);
69821
69875
  }
@@ -69823,10 +69877,6 @@ var PublishVersionCommand = class {
69823
69877
  return this.isWin ? "wsl" : "";
69824
69878
  }
69825
69879
  async execute(repoName, notes) {
69826
- const defaultRendererOptions = {
69827
- bottomBar: this.verbose ? Infinity : true,
69828
- persistentOutput: true
69829
- };
69830
69880
  await new Listr(
69831
69881
  [
69832
69882
  {
@@ -69848,7 +69898,7 @@ var PublishVersionCommand = class {
69848
69898
  new ListrTaskLogger(task, this.verbose ? 3 /* DEBUG */ : 0 /* INFO */)
69849
69899
  );
69850
69900
  },
69851
- rendererOptions: defaultRendererOptions
69901
+ rendererOptions: this.defaultRendererOptions
69852
69902
  },
69853
69903
  {
69854
69904
  title: "Docker build",
@@ -69861,7 +69911,7 @@ var PublishVersionCommand = class {
69861
69911
  new ListrTaskLogger(task, this.verbose ? 3 /* DEBUG */ : 0 /* INFO */)
69862
69912
  );
69863
69913
  },
69864
- rendererOptions: defaultRendererOptions
69914
+ rendererOptions: this.defaultRendererOptions
69865
69915
  },
69866
69916
  {
69867
69917
  title: "Docker push",
@@ -69872,16 +69922,9 @@ var PublishVersionCommand = class {
69872
69922
  new ListrTaskLogger(task, this.verbose ? 3 /* DEBUG */ : 0 /* INFO */)
69873
69923
  );
69874
69924
  },
69875
- rendererOptions: defaultRendererOptions
69876
- },
69877
- {
69878
- title: "Generate schema",
69879
- task: async (ctx, task) => {
69880
- const logger = new ListrTaskLogger(task, this.verbose ? 3 /* DEBUG */ : 0 /* INFO */);
69881
- ctx.schemaText = await spawnCommand(this.getSchemaCmdText(), logger);
69882
- },
69883
- rendererOptions: defaultRendererOptions
69925
+ rendererOptions: this.defaultRendererOptions
69884
69926
  },
69927
+ this.getSchemaTask(),
69885
69928
  {
69886
69929
  title: "Save publish details",
69887
69930
  task: async (ctx, task) => {
@@ -69909,7 +69952,7 @@ var PublishVersionCommand = class {
69909
69952
  );
69910
69953
  task.output = `The version ${ctx.publishDetails.imageVersion} has been successfully published!`;
69911
69954
  },
69912
- rendererOptions: defaultRendererOptions
69955
+ rendererOptions: this.defaultRendererOptions
69913
69956
  }
69914
69957
  ],
69915
69958
  {
@@ -69934,11 +69977,26 @@ var PublishVersionCommand = class {
69934
69977
  dockerLoginCmdText(username, password, registry3) {
69935
69978
  return `${this.wslPrefix} /bin/bash -c 'echo ${password} |docker login -u ${username} --password-stdin ${registry3}'`;
69936
69979
  }
69937
- getSchemaCmdText() {
69980
+ getPythonSchemaCmdText() {
69938
69981
  const engine = this.isWin ? ".\\.venv\\Scripts\\python.exe" : "./.venv/bin/python";
69939
69982
  const mainPyPath = resolveProjectPath("src/main.py");
69940
69983
  return `${engine} ${mainPyPath} --schema`;
69941
69984
  }
69985
+ getKotlinSchemaCmdTask(fullImageName) {
69986
+ return `${this.wslPrefix} docker run -it ${fullImageName} ./application --schema`;
69987
+ }
69988
+ getSchemaTask() {
69989
+ return {
69990
+ title: "Generate schema",
69991
+ task: async (ctx, task) => {
69992
+ const logger = new ListrTaskLogger(task, this.verbose ? 3 /* DEBUG */ : 0 /* INFO */);
69993
+ const kongJson = getKongJson();
69994
+ const cmdText = kongJson.sdk === "python" ? this.getPythonSchemaCmdText() : this.getKotlinSchemaCmdTask(ctx.fullImageName);
69995
+ ctx.schemaText = await spawnCommand(cmdText, logger);
69996
+ },
69997
+ rendererOptions: this.defaultRendererOptions
69998
+ };
69999
+ }
69942
70000
  };
69943
70001
 
69944
70002
  // packages/kong-cli/src/services/publicClient.ts
@@ -69952,7 +70010,7 @@ var PublicClient = class {
69952
70010
  }
69953
70011
  };
69954
70012
 
69955
- // packages/kong-cli/src/commands/setExtensionAliasCommand.ts
70013
+ // packages/kong-cli/src/commands/setAliasCommand.ts
69956
70014
  function validateName(value) {
69957
70015
  if (isEmpty(value)) {
69958
70016
  throw new AppError("The alias name should not be empty.");
@@ -69963,7 +70021,7 @@ function validateName(value) {
69963
70021
  );
69964
70022
  }
69965
70023
  }
69966
- var SetExtensionAliasCommand = class {
70024
+ var SetAliasCommand = class {
69967
70025
  constructor(profile) {
69968
70026
  this.publicClient = new PublicClient(profile.kongBaseUrl);
69969
70027
  this.managementClient = new ManagementClient(profile.kongBaseUrl);
@@ -70043,7 +70101,7 @@ function getPresetVersion() {
70043
70101
  import_dotenv_expand.default.expand(import_dotenv.default.config({ path: import_path5.default.join(__dirname, ".env") }));
70044
70102
  async function main() {
70045
70103
  const generateCommand = new Command("generate").description("Generate new extension").argument("name", "Extension name").addOption(
70046
- new Option("--sdk", "Target sdk platform").choices(["python", "kotlin"]).default("python")
70104
+ new Option("--sdk <name>", "Target sdk platform for extension").choices(["python", "kotlin"]).default("python")
70047
70105
  ).addOption(new Option("--verbose", "Show full logs during command execution")).action(async (name, options) => {
70048
70106
  try {
70049
70107
  const presetVersion = getPresetVersion();
@@ -70068,6 +70126,7 @@ async function main() {
70068
70126
  "Build and automatically tag the current code with an incremented version, ready for selection in extension aliases"
70069
70127
  ).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) => {
70070
70128
  try {
70129
+ printProfile(options.profile);
70071
70130
  const kongJson = getKongJson();
70072
70131
  await new PublishVersionCommand(getProfile(options.profile), options.verbose).execute(
70073
70132
  kongJson.name,
@@ -70079,24 +70138,28 @@ async function main() {
70079
70138
  });
70080
70139
  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) => {
70081
70140
  try {
70082
- await new ListExtensionSnapshotCommand(
70083
- getProfile(options.profile),
70084
- options.verbose
70085
- ).execute();
70141
+ printProfile(options.profile);
70142
+ await new ListVersionsCommand(getProfile(options.profile), options.verbose).execute();
70086
70143
  } catch (ex) {
70087
70144
  printError("list-versions command failed", ex);
70088
70145
  }
70089
70146
  });
70090
70147
  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) => {
70091
70148
  try {
70092
- await new SetExtensionAliasCommand(getProfile(options.profile)).execute(
70093
- aliasName,
70094
- extensionVersion
70095
- );
70149
+ printProfile(options.profile);
70150
+ await new SetAliasCommand(getProfile(options.profile)).execute(aliasName, extensionVersion);
70096
70151
  } catch (ex) {
70097
70152
  printError("set-alias command failed", ex);
70098
70153
  }
70099
70154
  });
70155
+ 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) => {
70156
+ try {
70157
+ printProfile(options.profile);
70158
+ await new ListAliasesCommand(getProfile(options.profile), options.verbose).execute();
70159
+ } catch (ex) {
70160
+ printError("list-aliases command failed", ex);
70161
+ }
70162
+ });
70100
70163
  const cli = new Command().version(getPresetVersion()).description("CLI to support creating and publishing Kong extensions");
70101
70164
  cli.addCommand(generateCommand);
70102
70165
  cli.addCommand(configureCommand);
@@ -70104,6 +70167,7 @@ async function main() {
70104
70167
  cli.addCommand(publishVersionCommand);
70105
70168
  cli.addCommand(listVersionsCommand);
70106
70169
  cli.addCommand(setAliasCommand);
70170
+ cli.addCommand(listAliasesCommand);
70107
70171
  cli.parse(process.argv);
70108
70172
  }
70109
70173
  main();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devkong/cli",
3
- "version": "0.0.16",
3
+ "version": "0.0.18-0",
4
4
  "type": "commonjs",
5
5
  "main": "./index.js",
6
6
  "typings": "./index.d.ts",
@@ -0,0 +1,8 @@
1
+ import { Profile } from "../common/profile";
2
+ export declare class ListAliasesCommand {
3
+ private profile;
4
+ private verbose;
5
+ private readonly managementClient;
6
+ constructor(profile: Profile, verbose: boolean);
7
+ execute(): Promise<void>;
8
+ }
@@ -1,5 +1,5 @@
1
1
  import { Profile } from "../common/profile";
2
- export declare class ListExtensionSnapshotCommand {
2
+ export declare class ListVersionsCommand {
3
3
  private verbose;
4
4
  private readonly managementClient;
5
5
  constructor(profile: Profile, verbose: boolean);
@@ -4,6 +4,7 @@ export declare class PublishVersionCommand {
4
4
  private readonly isWin;
5
5
  private registryClient;
6
6
  private managementClient;
7
+ private defaultRendererOptions;
7
8
  private get wslPrefix();
8
9
  constructor(profile: Profile, verbose?: boolean);
9
10
  execute(repoName: string, notes: string): Promise<void>;
@@ -11,5 +12,7 @@ export declare class PublishVersionCommand {
11
12
  private dockerBuildCmdText;
12
13
  private dockerPushCmdText;
13
14
  private dockerLoginCmdText;
14
- private getSchemaCmdText;
15
+ private getPythonSchemaCmdText;
16
+ private getKotlinSchemaCmdTask;
17
+ private getSchemaTask;
15
18
  }
@@ -1,5 +1,5 @@
1
1
  import { Profile } from "../common/profile";
2
- export declare class SetExtensionAliasCommand {
2
+ export declare class SetAliasCommand {
3
3
  private publicClient;
4
4
  private managementClient;
5
5
  constructor(profile: Profile);
@@ -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
+ }