@devkong/cli 0.0.2-0 → 0.0.3
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 +100 -37
- 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 +2 -0
- package/packages/kong-cli/src/commands/listExtensionSnapshotCommand.d.ts +2 -1
- package/packages/kong-cli/src/commands/publishCommand.d.ts +2 -1
- 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, { 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,7 +69369,38 @@ 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 {
|
|
69401
|
+
constructor(verbose) {
|
|
69402
|
+
this.verbose = verbose;
|
|
69403
|
+
}
|
|
69373
69404
|
async execute(extensionName) {
|
|
69374
69405
|
await new Listr([
|
|
69375
69406
|
{
|
|
@@ -69378,9 +69409,15 @@ var InstallCommand = class {
|
|
|
69378
69409
|
const scriptPath = this.scriptPath();
|
|
69379
69410
|
const extensionPath = import_path3.default.join(process.cwd(), extensionName);
|
|
69380
69411
|
task.output = `${scriptPath} ${extensionPath}`;
|
|
69381
|
-
await spawnCommand(
|
|
69412
|
+
await spawnCommand(
|
|
69413
|
+
`${scriptPath} ${extensionPath}`,
|
|
69414
|
+
new ListrTaskLogger(task, this.verbose ? 3 /* DEBUG */ : 0 /* INFO */)
|
|
69415
|
+
);
|
|
69382
69416
|
},
|
|
69383
|
-
rendererOptions: {
|
|
69417
|
+
rendererOptions: {
|
|
69418
|
+
bottomBar: this.verbose ? Infinity : true,
|
|
69419
|
+
persistentOutput: true
|
|
69420
|
+
}
|
|
69384
69421
|
}
|
|
69385
69422
|
]).run();
|
|
69386
69423
|
}
|
|
@@ -69395,6 +69432,9 @@ var InstallCommand = class {
|
|
|
69395
69432
|
|
|
69396
69433
|
// packages/kong-cli/src/commands/generateCommand.ts
|
|
69397
69434
|
var GenerateCommand = class {
|
|
69435
|
+
constructor(verbose = false) {
|
|
69436
|
+
this.verbose = verbose;
|
|
69437
|
+
}
|
|
69398
69438
|
async execute(extensionName, sdk, presetVersion) {
|
|
69399
69439
|
const id = generateShortId();
|
|
69400
69440
|
await (0, import_create_nx_workspace.createWorkspace)(`@devkong/cli-nx@${presetVersion}`, {
|
|
@@ -69404,7 +69444,7 @@ var GenerateCommand = class {
|
|
|
69404
69444
|
nxCloud: "skip",
|
|
69405
69445
|
packageManager: "npm"
|
|
69406
69446
|
});
|
|
69407
|
-
await new InstallCommand().execute(extensionName);
|
|
69447
|
+
await new InstallCommand(this.verbose).execute(extensionName);
|
|
69408
69448
|
}
|
|
69409
69449
|
};
|
|
69410
69450
|
|
|
@@ -69643,7 +69683,8 @@ var ManagementClient = class {
|
|
|
69643
69683
|
|
|
69644
69684
|
// packages/kong-cli/src/commands/listExtensionSnapshotCommand.ts
|
|
69645
69685
|
var ListExtensionSnapshotCommand = class {
|
|
69646
|
-
constructor(profile) {
|
|
69686
|
+
constructor(profile, verbose) {
|
|
69687
|
+
this.verbose = verbose;
|
|
69647
69688
|
this.managementClient = new ManagementClient(profile.kongBaseUrl);
|
|
69648
69689
|
}
|
|
69649
69690
|
async execute() {
|
|
@@ -69664,7 +69705,9 @@ var ListExtensionSnapshotCommand = class {
|
|
|
69664
69705
|
task.output = result.join("\n");
|
|
69665
69706
|
}
|
|
69666
69707
|
},
|
|
69667
|
-
rendererOptions: {
|
|
69708
|
+
rendererOptions: {
|
|
69709
|
+
persistentOutput: true
|
|
69710
|
+
}
|
|
69668
69711
|
}
|
|
69669
69712
|
],
|
|
69670
69713
|
{
|
|
@@ -69692,7 +69735,8 @@ var RegistryClient = class {
|
|
|
69692
69735
|
|
|
69693
69736
|
// packages/kong-cli/src/commands/publishCommand.ts
|
|
69694
69737
|
var PublishCommand = class {
|
|
69695
|
-
constructor(profile) {
|
|
69738
|
+
constructor(profile, verbose = false) {
|
|
69739
|
+
this.verbose = verbose;
|
|
69696
69740
|
this.isWin = process.platform === "win32";
|
|
69697
69741
|
this.registryClient = new RegistryClient(profile.kongBaseUrl);
|
|
69698
69742
|
this.managementClient = new ManagementClient(profile.kongBaseUrl);
|
|
@@ -69701,6 +69745,10 @@ var PublishCommand = class {
|
|
|
69701
69745
|
return this.isWin ? "wsl" : "";
|
|
69702
69746
|
}
|
|
69703
69747
|
async execute(repoName) {
|
|
69748
|
+
const defaultRendererOptions = {
|
|
69749
|
+
bottomBar: this.verbose ? Infinity : true,
|
|
69750
|
+
persistentOutput: true
|
|
69751
|
+
};
|
|
69704
69752
|
await new Listr(
|
|
69705
69753
|
[
|
|
69706
69754
|
{
|
|
@@ -69718,9 +69766,11 @@ var PublishCommand = class {
|
|
|
69718
69766
|
ctx.publishDetails.userName,
|
|
69719
69767
|
ctx.publishDetails.token,
|
|
69720
69768
|
regUrl
|
|
69721
|
-
)
|
|
69769
|
+
),
|
|
69770
|
+
new ListrTaskLogger(task, this.verbose ? 3 /* DEBUG */ : 0 /* INFO */)
|
|
69722
69771
|
);
|
|
69723
|
-
}
|
|
69772
|
+
},
|
|
69773
|
+
rendererOptions: defaultRendererOptions
|
|
69724
69774
|
},
|
|
69725
69775
|
{
|
|
69726
69776
|
title: "Docker build",
|
|
@@ -69728,28 +69778,35 @@ var PublishCommand = class {
|
|
|
69728
69778
|
const details = ctx.publishDetails;
|
|
69729
69779
|
const regUrl = this.resolveRegistryUrl(details.repoName);
|
|
69730
69780
|
ctx.fullImageName = `${regUrl}/${details.imageName}:${details.imageVersion}`;
|
|
69731
|
-
await spawnCommand(
|
|
69732
|
-
|
|
69781
|
+
await spawnCommand(
|
|
69782
|
+
this.dockerBuildCmdText(ctx.fullImageName),
|
|
69783
|
+
new ListrTaskLogger(task, this.verbose ? 3 /* DEBUG */ : 0 /* INFO */)
|
|
69784
|
+
);
|
|
69785
|
+
},
|
|
69786
|
+
rendererOptions: defaultRendererOptions
|
|
69733
69787
|
},
|
|
69734
69788
|
{
|
|
69735
69789
|
title: "Docker push",
|
|
69736
69790
|
task: async (ctx, task) => {
|
|
69737
69791
|
const cmd = this.dockerPushCmdText(ctx.fullImageName);
|
|
69738
|
-
|
|
69739
|
-
|
|
69792
|
+
await spawnCommand(
|
|
69793
|
+
cmd,
|
|
69794
|
+
new ListrTaskLogger(task, this.verbose ? 3 /* DEBUG */ : 0 /* INFO */)
|
|
69795
|
+
);
|
|
69740
69796
|
},
|
|
69741
|
-
rendererOptions:
|
|
69797
|
+
rendererOptions: defaultRendererOptions
|
|
69742
69798
|
},
|
|
69743
69799
|
{
|
|
69744
69800
|
title: "Generate schema",
|
|
69745
69801
|
task: async (ctx, task) => {
|
|
69802
|
+
const logger = new ListrTaskLogger(task, this.verbose ? 3 /* DEBUG */ : 0 /* INFO */);
|
|
69746
69803
|
try {
|
|
69747
|
-
ctx.schemaText = await spawnCommand(this.getSchemaCmdText("python3"));
|
|
69804
|
+
ctx.schemaText = await spawnCommand(this.getSchemaCmdText("python3"), logger);
|
|
69748
69805
|
} catch {
|
|
69749
|
-
ctx.schemaText = await spawnCommand(this.getSchemaCmdText("python"));
|
|
69806
|
+
ctx.schemaText = await spawnCommand(this.getSchemaCmdText("python"), logger);
|
|
69750
69807
|
}
|
|
69751
69808
|
},
|
|
69752
|
-
rendererOptions:
|
|
69809
|
+
rendererOptions: defaultRendererOptions
|
|
69753
69810
|
},
|
|
69754
69811
|
{
|
|
69755
69812
|
title: "Save publish details",
|
|
@@ -69777,7 +69834,8 @@ var PublishCommand = class {
|
|
|
69777
69834
|
snapshot
|
|
69778
69835
|
);
|
|
69779
69836
|
task.output = `Version ${ctx.publishDetails.imageVersion} published!`;
|
|
69780
|
-
}
|
|
69837
|
+
},
|
|
69838
|
+
rendererOptions: defaultRendererOptions
|
|
69781
69839
|
}
|
|
69782
69840
|
],
|
|
69783
69841
|
{
|
|
@@ -69800,7 +69858,7 @@ var PublishCommand = class {
|
|
|
69800
69858
|
return `${this.wslPrefix} docker push ${imageName}`;
|
|
69801
69859
|
}
|
|
69802
69860
|
dockerLoginCmdText(username, password, registry3) {
|
|
69803
|
-
return `${this.wslPrefix} echo ${password} |docker login -u ${username} --password-stdin ${registry3}`;
|
|
69861
|
+
return `${this.wslPrefix} /bin/bash -c 'echo ${password} |docker login -u ${username} --password-stdin ${registry3}'`;
|
|
69804
69862
|
}
|
|
69805
69863
|
getSchemaCmdText(engine) {
|
|
69806
69864
|
const mainPyPath = resolveProjectPath("src/main.py");
|
|
@@ -69900,10 +69958,10 @@ import_dotenv_expand.default.expand(import_dotenv.default.config({ path: import_
|
|
|
69900
69958
|
async function main() {
|
|
69901
69959
|
const generateCommand = new Command("generate").description("Generate new extension").argument("name", "Extension name").addOption(
|
|
69902
69960
|
new Option("--sdk", "Target sdk platform").choices(["python", "kotlin"]).default("python")
|
|
69903
|
-
).action(async (name, options) => {
|
|
69961
|
+
).addOption(new Option("--verbose", "Show full logs during command execution")).action(async (name, options) => {
|
|
69904
69962
|
try {
|
|
69905
69963
|
const presetVersion = getPresetVersion();
|
|
69906
|
-
await new GenerateCommand().execute(name, options.sdk, presetVersion);
|
|
69964
|
+
await new GenerateCommand(options.verbose).execute(name, options.sdk, presetVersion);
|
|
69907
69965
|
} catch (ex) {
|
|
69908
69966
|
printError("generate command failed", ex);
|
|
69909
69967
|
}
|
|
@@ -69911,26 +69969,31 @@ async function main() {
|
|
|
69911
69969
|
const configureCommand = new Command("configure").description("Configure access to kong environments").action(async () => {
|
|
69912
69970
|
await new ConfigureCommand().execute();
|
|
69913
69971
|
});
|
|
69914
|
-
const installCommand = new Command("install").description("Setup virtual environment and install dependencies").action(async () => {
|
|
69972
|
+
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
69973
|
try {
|
|
69916
|
-
await new InstallCommand().execute();
|
|
69974
|
+
await new InstallCommand(options.verbose).execute();
|
|
69917
69975
|
} catch (ex) {
|
|
69918
69976
|
printError("install command failed", ex);
|
|
69919
69977
|
}
|
|
69920
69978
|
});
|
|
69921
69979
|
const publishVersionCommand = new Command("publish-version").description(
|
|
69922
69980
|
"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) => {
|
|
69981
|
+
).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) => {
|
|
69924
69982
|
try {
|
|
69925
69983
|
const kongJson = getKongJson();
|
|
69926
|
-
await new PublishCommand(getProfile(options.profile)).execute(
|
|
69984
|
+
await new PublishCommand(getProfile(options.profile), options.verbose).execute(
|
|
69985
|
+
kongJson.name
|
|
69986
|
+
);
|
|
69927
69987
|
} catch (ex) {
|
|
69928
69988
|
printError("publish-version command failed", ex);
|
|
69929
69989
|
}
|
|
69930
69990
|
});
|
|
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) => {
|
|
69991
|
+
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
69992
|
try {
|
|
69933
|
-
await new ListExtensionSnapshotCommand(
|
|
69993
|
+
await new ListExtensionSnapshotCommand(
|
|
69994
|
+
getProfile(options.profile),
|
|
69995
|
+
options.verbose
|
|
69996
|
+
).execute();
|
|
69934
69997
|
} catch (ex) {
|
|
69935
69998
|
printError("list-versions command failed", ex);
|
|
69936
69999
|
}
|
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,10 +1,11 @@
|
|
|
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
|
+
constructor(profile: Profile, verbose?: boolean);
|
|
8
9
|
execute(repoName: string): Promise<void>;
|
|
9
10
|
private resolveRegistryUrl;
|
|
10
11
|
private dockerBuildCmdText;
|
|
@@ -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";
|