@devkong/cli 0.0.2-0 → 0.0.4
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 +113 -48
- package/package.json +1 -1
- package/packages/kong-cli/src/commands/generateCommand.d.ts +2 -0
- package/packages/kong-cli/src/commands/installCommand.d.ts +3 -1
- package/packages/kong-cli/src/commands/listExtensionSnapshotCommand.d.ts +2 -1
- package/packages/kong-cli/src/commands/publishCommand.d.ts +3 -2
- package/packages/kong-cli/src/common/listrTaskLogger.d.ts +20 -0
- package/packages/kong-cli/src/common/utils.d.ts +7 -1
- package/packages/kong-ts-contract/src/index.d.ts +1 -1
- package/packages/kong-ts-contract/src/lib/appDevRequest.d.ts +8 -0
- package/packages/kong-ts-contract/src/lib/appProcessTest.d.ts +0 -6
package/index.js
CHANGED
|
@@ -66759,23 +66759,23 @@ function generateShortId() {
|
|
|
66759
66759
|
uuidHash.push(uuidToJavaHashCode(guid()) & 2147483647);
|
|
66760
66760
|
return sqids.encode(uuidHash);
|
|
66761
66761
|
}
|
|
66762
|
-
async function spawnCommand(commandText,
|
|
66762
|
+
async function spawnCommand(commandText, logger = null) {
|
|
66763
66763
|
return new Promise((resolve2, reject) => {
|
|
66764
66764
|
const commandWithArgs = commandText.split(" ").filter((s) => s);
|
|
66765
|
+
logger.debug(commandText);
|
|
66765
66766
|
const command = commandWithArgs.shift();
|
|
66766
66767
|
const commandArgs = commandWithArgs;
|
|
66767
|
-
const
|
|
66768
|
-
const child = (0, import_child_process.spawn)(command, commandArgs, { stdio: [mode, mode, mode] });
|
|
66768
|
+
const child = (0, import_child_process.spawn)(command, commandArgs, { shell: true, stdio: ["pipe", "pipe", "pipe"] });
|
|
66769
66769
|
let stdout = "";
|
|
66770
66770
|
let stderr = "";
|
|
66771
|
-
|
|
66772
|
-
|
|
66773
|
-
|
|
66774
|
-
|
|
66775
|
-
|
|
66776
|
-
|
|
66777
|
-
|
|
66778
|
-
}
|
|
66771
|
+
child.stdout.on("data", (data) => {
|
|
66772
|
+
stdout += data.toString();
|
|
66773
|
+
logger?.debug(data);
|
|
66774
|
+
});
|
|
66775
|
+
child.stderr.on("data", (data) => {
|
|
66776
|
+
stderr += data.toString();
|
|
66777
|
+
logger?.error(data);
|
|
66778
|
+
});
|
|
66779
66779
|
child.on("close", (code) => {
|
|
66780
66780
|
if (code === 0) {
|
|
66781
66781
|
resolve2(stdout);
|
|
@@ -69369,18 +69369,54 @@ var Listr = class {
|
|
|
69369
69369
|
|
|
69370
69370
|
// packages/kong-cli/src/commands/installCommand.ts
|
|
69371
69371
|
var import_path3 = __toESM(require("path"));
|
|
69372
|
+
|
|
69373
|
+
// packages/kong-cli/src/common/listrTaskLogger.ts
|
|
69374
|
+
var ListrTaskLogger = class {
|
|
69375
|
+
constructor(task, logLevel = 0 /* INFO */) {
|
|
69376
|
+
this.task = task;
|
|
69377
|
+
this.logLevel = logLevel;
|
|
69378
|
+
}
|
|
69379
|
+
info(message2) {
|
|
69380
|
+
this.task.output = message2;
|
|
69381
|
+
}
|
|
69382
|
+
debug(message2) {
|
|
69383
|
+
if (this.logLevel == 3 /* DEBUG */) {
|
|
69384
|
+
this.task.output = message2;
|
|
69385
|
+
}
|
|
69386
|
+
}
|
|
69387
|
+
error(message2) {
|
|
69388
|
+
if (this.logLevel >= 2 /* ERROR */) {
|
|
69389
|
+
this.task.output = message2;
|
|
69390
|
+
}
|
|
69391
|
+
}
|
|
69392
|
+
warn(message2) {
|
|
69393
|
+
if (this.logLevel >= 1 /* WARN */) {
|
|
69394
|
+
this.task.output = message2;
|
|
69395
|
+
}
|
|
69396
|
+
}
|
|
69397
|
+
};
|
|
69398
|
+
|
|
69399
|
+
// packages/kong-cli/src/commands/installCommand.ts
|
|
69372
69400
|
var InstallCommand = class {
|
|
69373
|
-
|
|
69401
|
+
constructor(verbose) {
|
|
69402
|
+
this.verbose = verbose;
|
|
69403
|
+
}
|
|
69404
|
+
async execute(workspaceDirectory) {
|
|
69374
69405
|
await new Listr([
|
|
69375
69406
|
{
|
|
69376
69407
|
title: "Installing dependencies with pip",
|
|
69377
69408
|
task: async (_2, task) => {
|
|
69378
69409
|
const scriptPath = this.scriptPath();
|
|
69379
|
-
|
|
69380
|
-
|
|
69381
|
-
|
|
69410
|
+
task.output = `${scriptPath} ${workspaceDirectory}`;
|
|
69411
|
+
await spawnCommand(
|
|
69412
|
+
`${scriptPath} ${workspaceDirectory}`,
|
|
69413
|
+
new ListrTaskLogger(task, this.verbose ? 3 /* DEBUG */ : 0 /* INFO */)
|
|
69414
|
+
);
|
|
69382
69415
|
},
|
|
69383
|
-
rendererOptions: {
|
|
69416
|
+
rendererOptions: {
|
|
69417
|
+
bottomBar: this.verbose ? Infinity : true,
|
|
69418
|
+
persistentOutput: true
|
|
69419
|
+
}
|
|
69384
69420
|
}
|
|
69385
69421
|
]).run();
|
|
69386
69422
|
}
|
|
@@ -69395,16 +69431,19 @@ var InstallCommand = class {
|
|
|
69395
69431
|
|
|
69396
69432
|
// packages/kong-cli/src/commands/generateCommand.ts
|
|
69397
69433
|
var GenerateCommand = class {
|
|
69434
|
+
constructor(verbose = false) {
|
|
69435
|
+
this.verbose = verbose;
|
|
69436
|
+
}
|
|
69398
69437
|
async execute(extensionName, sdk, presetVersion) {
|
|
69399
69438
|
const id = generateShortId();
|
|
69400
|
-
await (0, import_create_nx_workspace.createWorkspace)(`@devkong/cli-nx@${presetVersion}`, {
|
|
69439
|
+
const workspace = await (0, import_create_nx_workspace.createWorkspace)(`@devkong/cli-nx@${presetVersion}`, {
|
|
69401
69440
|
name: extensionName,
|
|
69402
69441
|
id,
|
|
69403
69442
|
platform: sdk,
|
|
69404
69443
|
nxCloud: "skip",
|
|
69405
69444
|
packageManager: "npm"
|
|
69406
69445
|
});
|
|
69407
|
-
await new InstallCommand().execute(
|
|
69446
|
+
await new InstallCommand(this.verbose).execute(workspace.directory);
|
|
69408
69447
|
}
|
|
69409
69448
|
};
|
|
69410
69449
|
|
|
@@ -69643,7 +69682,8 @@ var ManagementClient = class {
|
|
|
69643
69682
|
|
|
69644
69683
|
// packages/kong-cli/src/commands/listExtensionSnapshotCommand.ts
|
|
69645
69684
|
var ListExtensionSnapshotCommand = class {
|
|
69646
|
-
constructor(profile) {
|
|
69685
|
+
constructor(profile, verbose) {
|
|
69686
|
+
this.verbose = verbose;
|
|
69647
69687
|
this.managementClient = new ManagementClient(profile.kongBaseUrl);
|
|
69648
69688
|
}
|
|
69649
69689
|
async execute() {
|
|
@@ -69659,12 +69699,14 @@ var ListExtensionSnapshotCommand = class {
|
|
|
69659
69699
|
} else {
|
|
69660
69700
|
const result = [];
|
|
69661
69701
|
for (const ver of versions) {
|
|
69662
|
-
result.push(`${ver.version}, ${ver.created}, ${ver.createdBy}`);
|
|
69702
|
+
result.push(`${ver.version}, ${ver.created}, ${ver.createdBy}, ${ver.notes}`);
|
|
69663
69703
|
}
|
|
69664
69704
|
task.output = result.join("\n");
|
|
69665
69705
|
}
|
|
69666
69706
|
},
|
|
69667
|
-
rendererOptions: {
|
|
69707
|
+
rendererOptions: {
|
|
69708
|
+
persistentOutput: true
|
|
69709
|
+
}
|
|
69668
69710
|
}
|
|
69669
69711
|
],
|
|
69670
69712
|
{
|
|
@@ -69692,7 +69734,8 @@ var RegistryClient = class {
|
|
|
69692
69734
|
|
|
69693
69735
|
// packages/kong-cli/src/commands/publishCommand.ts
|
|
69694
69736
|
var PublishCommand = class {
|
|
69695
|
-
constructor(profile) {
|
|
69737
|
+
constructor(profile, verbose = false) {
|
|
69738
|
+
this.verbose = verbose;
|
|
69696
69739
|
this.isWin = process.platform === "win32";
|
|
69697
69740
|
this.registryClient = new RegistryClient(profile.kongBaseUrl);
|
|
69698
69741
|
this.managementClient = new ManagementClient(profile.kongBaseUrl);
|
|
@@ -69700,7 +69743,11 @@ var PublishCommand = class {
|
|
|
69700
69743
|
get wslPrefix() {
|
|
69701
69744
|
return this.isWin ? "wsl" : "";
|
|
69702
69745
|
}
|
|
69703
|
-
async execute(repoName) {
|
|
69746
|
+
async execute(repoName, notes) {
|
|
69747
|
+
const defaultRendererOptions = {
|
|
69748
|
+
bottomBar: this.verbose ? Infinity : true,
|
|
69749
|
+
persistentOutput: true
|
|
69750
|
+
};
|
|
69704
69751
|
await new Listr(
|
|
69705
69752
|
[
|
|
69706
69753
|
{
|
|
@@ -69718,9 +69765,11 @@ var PublishCommand = class {
|
|
|
69718
69765
|
ctx.publishDetails.userName,
|
|
69719
69766
|
ctx.publishDetails.token,
|
|
69720
69767
|
regUrl
|
|
69721
|
-
)
|
|
69768
|
+
),
|
|
69769
|
+
new ListrTaskLogger(task, this.verbose ? 3 /* DEBUG */ : 0 /* INFO */)
|
|
69722
69770
|
);
|
|
69723
|
-
}
|
|
69771
|
+
},
|
|
69772
|
+
rendererOptions: defaultRendererOptions
|
|
69724
69773
|
},
|
|
69725
69774
|
{
|
|
69726
69775
|
title: "Docker build",
|
|
@@ -69728,28 +69777,31 @@ var PublishCommand = class {
|
|
|
69728
69777
|
const details = ctx.publishDetails;
|
|
69729
69778
|
const regUrl = this.resolveRegistryUrl(details.repoName);
|
|
69730
69779
|
ctx.fullImageName = `${regUrl}/${details.imageName}:${details.imageVersion}`;
|
|
69731
|
-
await spawnCommand(
|
|
69732
|
-
|
|
69780
|
+
await spawnCommand(
|
|
69781
|
+
this.dockerBuildCmdText(ctx.fullImageName),
|
|
69782
|
+
new ListrTaskLogger(task, this.verbose ? 3 /* DEBUG */ : 0 /* INFO */)
|
|
69783
|
+
);
|
|
69784
|
+
},
|
|
69785
|
+
rendererOptions: defaultRendererOptions
|
|
69733
69786
|
},
|
|
69734
69787
|
{
|
|
69735
69788
|
title: "Docker push",
|
|
69736
69789
|
task: async (ctx, task) => {
|
|
69737
69790
|
const cmd = this.dockerPushCmdText(ctx.fullImageName);
|
|
69738
|
-
|
|
69739
|
-
|
|
69791
|
+
await spawnCommand(
|
|
69792
|
+
cmd,
|
|
69793
|
+
new ListrTaskLogger(task, this.verbose ? 3 /* DEBUG */ : 0 /* INFO */)
|
|
69794
|
+
);
|
|
69740
69795
|
},
|
|
69741
|
-
rendererOptions:
|
|
69796
|
+
rendererOptions: defaultRendererOptions
|
|
69742
69797
|
},
|
|
69743
69798
|
{
|
|
69744
69799
|
title: "Generate schema",
|
|
69745
69800
|
task: async (ctx, task) => {
|
|
69746
|
-
|
|
69747
|
-
|
|
69748
|
-
} catch {
|
|
69749
|
-
ctx.schemaText = await spawnCommand(this.getSchemaCmdText("python"));
|
|
69750
|
-
}
|
|
69801
|
+
const logger = new ListrTaskLogger(task, this.verbose ? 3 /* DEBUG */ : 0 /* INFO */);
|
|
69802
|
+
ctx.schemaText = await spawnCommand(this.getSchemaCmdText(), logger);
|
|
69751
69803
|
},
|
|
69752
|
-
rendererOptions:
|
|
69804
|
+
rendererOptions: defaultRendererOptions
|
|
69753
69805
|
},
|
|
69754
69806
|
{
|
|
69755
69807
|
title: "Save publish details",
|
|
@@ -69767,7 +69819,7 @@ var PublishCommand = class {
|
|
|
69767
69819
|
outputSchema: jsonSchemas.output,
|
|
69768
69820
|
metadata: kongJson,
|
|
69769
69821
|
version: Number(ctx.publishDetails.imageVersion),
|
|
69770
|
-
notes
|
|
69822
|
+
notes,
|
|
69771
69823
|
created: utcNow(DEFAULT_TIMEZONE),
|
|
69772
69824
|
createdBy: kongJson.ownership.at(0)
|
|
69773
69825
|
};
|
|
@@ -69777,7 +69829,8 @@ var PublishCommand = class {
|
|
|
69777
69829
|
snapshot
|
|
69778
69830
|
);
|
|
69779
69831
|
task.output = `Version ${ctx.publishDetails.imageVersion} published!`;
|
|
69780
|
-
}
|
|
69832
|
+
},
|
|
69833
|
+
rendererOptions: defaultRendererOptions
|
|
69781
69834
|
}
|
|
69782
69835
|
],
|
|
69783
69836
|
{
|
|
@@ -69800,9 +69853,13 @@ var PublishCommand = class {
|
|
|
69800
69853
|
return `${this.wslPrefix} docker push ${imageName}`;
|
|
69801
69854
|
}
|
|
69802
69855
|
dockerLoginCmdText(username, password, registry3) {
|
|
69803
|
-
return `${this.wslPrefix} echo ${password} |docker login -u ${username} --password-stdin ${registry3}`;
|
|
69856
|
+
return `${this.wslPrefix} /bin/bash -c 'echo ${password} |docker login -u ${username} --password-stdin ${registry3}'`;
|
|
69804
69857
|
}
|
|
69805
|
-
getSchemaCmdText(
|
|
69858
|
+
getSchemaCmdText() {
|
|
69859
|
+
let engine = ".\\.venv\\Scripts\\python.exe";
|
|
69860
|
+
if (process.platform !== "win32") {
|
|
69861
|
+
engine = "./.venv/bin/python";
|
|
69862
|
+
}
|
|
69806
69863
|
const mainPyPath = resolveProjectPath("src/main.py");
|
|
69807
69864
|
return `${engine} ${mainPyPath} --schema`;
|
|
69808
69865
|
}
|
|
@@ -69900,10 +69957,10 @@ import_dotenv_expand.default.expand(import_dotenv.default.config({ path: import_
|
|
|
69900
69957
|
async function main() {
|
|
69901
69958
|
const generateCommand = new Command("generate").description("Generate new extension").argument("name", "Extension name").addOption(
|
|
69902
69959
|
new Option("--sdk", "Target sdk platform").choices(["python", "kotlin"]).default("python")
|
|
69903
|
-
).action(async (name, options) => {
|
|
69960
|
+
).addOption(new Option("--verbose", "Show full logs during command execution")).action(async (name, options) => {
|
|
69904
69961
|
try {
|
|
69905
69962
|
const presetVersion = getPresetVersion();
|
|
69906
|
-
await new GenerateCommand().execute(name, options.sdk, presetVersion);
|
|
69963
|
+
await new GenerateCommand(options.verbose).execute(name, options.sdk, presetVersion);
|
|
69907
69964
|
} catch (ex) {
|
|
69908
69965
|
printError("generate command failed", ex);
|
|
69909
69966
|
}
|
|
@@ -69911,26 +69968,34 @@ async function main() {
|
|
|
69911
69968
|
const configureCommand = new Command("configure").description("Configure access to kong environments").action(async () => {
|
|
69912
69969
|
await new ConfigureCommand().execute();
|
|
69913
69970
|
});
|
|
69914
|
-
const installCommand = new Command("install").description("Setup virtual environment and install dependencies").action(async () => {
|
|
69971
|
+
const installCommand = new Command("install").description("Setup virtual environment and install dependencies").addOption(new Option("--verbose", "Show full logs during command execution")).action(async (options) => {
|
|
69915
69972
|
try {
|
|
69916
|
-
|
|
69973
|
+
const kongJsonPath = resolveProjectPath("kong.json");
|
|
69974
|
+
const projectRoot = import_path5.default.dirname(kongJsonPath);
|
|
69975
|
+
await new InstallCommand(options.verbose).execute(projectRoot);
|
|
69917
69976
|
} catch (ex) {
|
|
69918
69977
|
printError("install command failed", ex);
|
|
69919
69978
|
}
|
|
69920
69979
|
});
|
|
69921
69980
|
const publishVersionCommand = new Command("publish-version").description(
|
|
69922
69981
|
"Build and automatically tag the current code with an incremented version, ready for selection in extension aliases"
|
|
69923
|
-
).addOption(new Option("--profile <name>", "Configured Kong profile to use").default("default")).action(async (options) => {
|
|
69982
|
+
).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) => {
|
|
69924
69983
|
try {
|
|
69925
69984
|
const kongJson = getKongJson();
|
|
69926
|
-
await new PublishCommand(getProfile(options.profile)).execute(
|
|
69985
|
+
await new PublishCommand(getProfile(options.profile), options.verbose).execute(
|
|
69986
|
+
kongJson.name,
|
|
69987
|
+
options.notes
|
|
69988
|
+
);
|
|
69927
69989
|
} catch (ex) {
|
|
69928
69990
|
printError("publish-version command failed", ex);
|
|
69929
69991
|
}
|
|
69930
69992
|
});
|
|
69931
|
-
const listVersionsCommand = new Command("list-versions").description("List available versions").addOption(new Option("--profile <name>", "Configured Kong profile to use").default("default")).action(async (options) => {
|
|
69993
|
+
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) => {
|
|
69932
69994
|
try {
|
|
69933
|
-
await new ListExtensionSnapshotCommand(
|
|
69995
|
+
await new ListExtensionSnapshotCommand(
|
|
69996
|
+
getProfile(options.profile),
|
|
69997
|
+
options.verbose
|
|
69998
|
+
).execute();
|
|
69934
69999
|
} catch (ex) {
|
|
69935
70000
|
printError("list-versions command failed", ex);
|
|
69936
70001
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Profile } from "../common/profile";
|
|
2
2
|
export declare class ListExtensionSnapshotCommand {
|
|
3
|
+
private verbose;
|
|
3
4
|
private readonly managementClient;
|
|
4
|
-
constructor(profile: Profile);
|
|
5
|
+
constructor(profile: Profile, verbose: boolean);
|
|
5
6
|
execute(): Promise<void>;
|
|
6
7
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { Profile } from "../common/profile";
|
|
2
2
|
export declare class PublishCommand {
|
|
3
|
+
private verbose;
|
|
3
4
|
private readonly isWin;
|
|
4
5
|
private registryClient;
|
|
5
6
|
private managementClient;
|
|
6
7
|
private get wslPrefix();
|
|
7
|
-
constructor(profile: Profile);
|
|
8
|
-
execute(repoName: string): Promise<void>;
|
|
8
|
+
constructor(profile: Profile, verbose?: boolean);
|
|
9
|
+
execute(repoName: string, notes: string): Promise<void>;
|
|
9
10
|
private resolveRegistryUrl;
|
|
10
11
|
private dockerBuildCmdText;
|
|
11
12
|
private dockerPushCmdText;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ILogger } from "./utils";
|
|
2
|
+
interface ITaskWithOutput {
|
|
3
|
+
set output(output: string | never[]);
|
|
4
|
+
}
|
|
5
|
+
export declare enum LogLevel {
|
|
6
|
+
INFO = 0,
|
|
7
|
+
WARN = 1,
|
|
8
|
+
ERROR = 2,
|
|
9
|
+
DEBUG = 3
|
|
10
|
+
}
|
|
11
|
+
export declare class ListrTaskLogger implements ILogger {
|
|
12
|
+
private task;
|
|
13
|
+
private logLevel;
|
|
14
|
+
constructor(task: ITaskWithOutput, logLevel?: LogLevel);
|
|
15
|
+
info(message: string): void;
|
|
16
|
+
debug(message: string): void;
|
|
17
|
+
error(message: string): void;
|
|
18
|
+
warn(message: string): void;
|
|
19
|
+
}
|
|
20
|
+
export {};
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
+
export interface ILogger {
|
|
2
|
+
info(message: string): any;
|
|
3
|
+
debug(message: string): any;
|
|
4
|
+
error(message: string): any;
|
|
5
|
+
warn(message: string): any;
|
|
6
|
+
}
|
|
1
7
|
export declare function env(key: string): string;
|
|
2
8
|
export declare function optionalEnv(key: string): string;
|
|
3
9
|
export declare function resolveProjectPath(fileName: string): string;
|
|
4
10
|
export declare function generateShortId(): string;
|
|
5
|
-
export declare function spawnCommand(commandText: string,
|
|
11
|
+
export declare function spawnCommand(commandText: string, logger?: ILogger): Promise<string>;
|
|
6
12
|
export declare function printError(message: string, error: unknown): void;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export type { AppCheckpoint } from "./lib/appCheckpoint";
|
|
2
|
+
export type { AppDevRequest } from "./lib/appDevRequest";
|
|
2
3
|
export type { AppDocument } from "./lib/appDocument";
|
|
3
4
|
export type { AppDocumentBuild } from "./lib/appDocumentBuild";
|
|
4
5
|
export type { AppDocumentSnapshot } from "./lib/appDocumentSnapshot";
|
|
@@ -13,7 +14,6 @@ export type { AppPresignedUrl } from "./lib/appPresignedUrl";
|
|
|
13
14
|
export type { AppProcessAlias } from "./lib/appProcessAlias";
|
|
14
15
|
export type { AppProcessAliasUse } from "./lib/appProcessAliasUse";
|
|
15
16
|
export type { AppProcessInstanceId } from "./lib/appProcessInstanceId";
|
|
16
|
-
export type { AppProcessTest } from "./lib/appProcessTest";
|
|
17
17
|
export type { AppProject } from "./lib/appProject";
|
|
18
18
|
export type { AppTestCase } from "./lib/appTestCase";
|
|
19
19
|
export type { AppTestCaseDetails } from "./lib/appTestCaseDetails";
|