@devkong/cli-nx 0.0.18-0 → 0.0.18
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/package.json +2 -2
- package/README.md +0 -11
- package/generators.json +0 -10
- package/src/generators/preset/files/kotlin/.dockerignore +0 -6
- package/src/generators/preset/files/kotlin/.editorconfig +0 -24
- package/src/generators/preset/files/kotlin/.vscode/extensions.json +0 -18
- package/src/generators/preset/files/kotlin/.vscode/launch.json +0 -16
- package/src/generators/preset/files/kotlin/.vscode/settings.json +0 -7
- package/src/generators/preset/files/kotlin/.vscode/tasks.json +0 -81
- package/src/generators/preset/files/kotlin/Dockerfile +0 -22
- package/src/generators/preset/files/kotlin/README.md +0 -77
- package/src/generators/preset/files/kotlin/build.gradle.kts.template +0 -64
- package/src/generators/preset/files/kotlin/extension.http +0 -83
- package/src/generators/preset/files/kotlin/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/src/generators/preset/files/kotlin/gradle/wrapper/gradle-wrapper.properties +0 -6
- package/src/generators/preset/files/kotlin/gradle.properties +0 -19
- package/src/generators/preset/files/kotlin/gradlew +0 -245
- package/src/generators/preset/files/kotlin/gradlew.bat +0 -92
- package/src/generators/preset/files/kotlin/kong.json +0 -7
- package/src/generators/preset/files/kotlin/nx.json +0 -14
- package/src/generators/preset/files/kotlin/package-lock.json +0 -1577
- package/src/generators/preset/files/kotlin/package.json +0 -15
- package/src/generators/preset/files/kotlin/project.json +0 -50
- package/src/generators/preset/files/kotlin/settings.gradle.kts +0 -14
- package/src/generators/preset/files/kotlin/src/main/kotlin/io/kong/extension/Main.kt +0 -43
- package/src/generators/preset/files/kotlin/src/main/resources/META-INF/resources/index.html +0 -362
- package/src/generators/preset/files/kotlin/src/main/resources/application.properties.template +0 -13
- package/src/generators/preset/files/kotlin/src/native-test/kotlin/io/kong/extension/.gitkeep +0 -0
- package/src/generators/preset/files/kotlin/src/test/kotlin/io/kong/extension/.gitkeep +0 -0
- package/src/generators/preset/files/python/.dockerignore +0 -5
- package/src/generators/preset/files/python/.editorconfig +0 -16
- package/src/generators/preset/files/python/.gitattributes +0 -25
- package/src/generators/preset/files/python/.gitignore.template +0 -69
- package/src/generators/preset/files/python/.idea/inspectionProfiles/Project_Default.xml +0 -7
- package/src/generators/preset/files/python/.idea/inspectionProfiles/profiles_settings.xml +0 -6
- package/src/generators/preset/files/python/.idea/kong-cli-python-template.iml +0 -10
- package/src/generators/preset/files/python/.pylintrc +0 -547
- package/src/generators/preset/files/python/.vscode/extensions.json +0 -14
- package/src/generators/preset/files/python/.vscode/launch.json +0 -18
- package/src/generators/preset/files/python/.vscode/settings.json +0 -62
- package/src/generators/preset/files/python/Dockerfile +0 -13
- package/src/generators/preset/files/python/README.md +0 -115
- package/src/generators/preset/files/python/kong.json +0 -7
- package/src/generators/preset/files/python/project.json.template +0 -8
- package/src/generators/preset/files/python/pyproject.toml +0 -3
- package/src/generators/preset/files/python/requirements-dev.txt +0 -10
- package/src/generators/preset/files/python/requirements.txt +0 -4
- package/src/generators/preset/files/python/src/__init__.py +0 -0
- package/src/generators/preset/files/python/src/main.py +0 -67
- package/src/generators/preset/files/python/src/main_test.py +0 -18
- package/src/generators/preset/schema.d.ts +0 -5
- package/src/generators/preset/schema.json +0 -27
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
# Kong Extension
|
|
2
|
-
|
|
3
|
-
Welcome to the Kong extension development workspace!
|
|
4
|
-
|
|
5
|
-
### Prerequisites
|
|
6
|
-
|
|
7
|
-
Before you start, make sure you have the following installed:
|
|
8
|
-
|
|
9
|
-
- [Node.js](https://nodejs.org/en/download/prebuilt-installer). Version >= 20.0
|
|
10
|
-
- [Python](https://www.python.org/downloads/). Version >= 3.10
|
|
11
|
-
- [Docker](https://docs.docker.com/desktop/). If using Docker Desktop, start it
|
|
12
|
-
- Mac M2 users, see [Troubleshooting](#Troubleshooting)
|
|
13
|
-
|
|
14
|
-
To verify the installation and check the versions, run the following commands:
|
|
15
|
-
|
|
16
|
-
```shell script
|
|
17
|
-
node --version
|
|
18
|
-
python --version # or python3 --version
|
|
19
|
-
docker info
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
### Getting Started
|
|
23
|
-
|
|
24
|
-
1. Add your username to the `ownership` field in the `kong.json` file (e.g., "kong-dev", "kong-qa")
|
|
25
|
-
2. Make sure you're in the terminal and inside the extension folder you generated
|
|
26
|
-
3. Run the following commands in your terminal:
|
|
27
|
-
|
|
28
|
-
```shell script
|
|
29
|
-
# configure the base Kong URL (e.g., https://kong.dev.app-dts.net)
|
|
30
|
-
kong configure
|
|
31
|
-
|
|
32
|
-
# install Python dependencies from requirements.txt
|
|
33
|
-
kong install --verbose
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
That's it! Now, modify [main.py](./src/main.py), tag it by publishing a new version, and assign aliases for use in the workflow.
|
|
37
|
-
|
|
38
|
-
### Publish a New Version
|
|
39
|
-
|
|
40
|
-
To automatically tag your code with an incremented version number (e.g., 1, 2, 3), run:
|
|
41
|
-
|
|
42
|
-
```shell script
|
|
43
|
-
kong publish-version --verbose
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
### List Available Versions
|
|
47
|
-
|
|
48
|
-
To see all available versions of your extension, run:
|
|
49
|
-
|
|
50
|
-
```shell script
|
|
51
|
-
kong list-versions
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
### Assign an Alias to a Version
|
|
55
|
-
|
|
56
|
-
You can assign an alias (e.g., stable, beta) to a specific version. This alias will appear in the UI as a separate step in the workflow. For example, to assign the alias stable to version 1, use:
|
|
57
|
-
|
|
58
|
-
```shell script
|
|
59
|
-
kong set-alias stable 1
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
### Running and Debugging Tests
|
|
63
|
-
|
|
64
|
-
To run the tests, execute the following command:
|
|
65
|
-
|
|
66
|
-
```shell script
|
|
67
|
-
pytest ./src
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
This will run the tests located in the `src` directory.
|
|
71
|
-
The debugging process depends on the IDE you're using. For example, in [VSCode](https://code.visualstudio.com/), follow these steps:
|
|
72
|
-
|
|
73
|
-
1. Open the Run and Debug panel from the left sidebar
|
|
74
|
-
2. In the top combobox (dropdown), select "test" to configure the test environment
|
|
75
|
-
3. Click the green play button to start debugging the tests
|
|
76
|
-
|
|
77
|
-
This will allow you to set breakpoints and step through your tests.
|
|
78
|
-
|
|
79
|
-
### Update Python Dependencies
|
|
80
|
-
|
|
81
|
-
If you modify requirements.txt or requirements-dev.txt, run the following to apply the changes:
|
|
82
|
-
|
|
83
|
-
```shell script
|
|
84
|
-
kong install --verbose
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
### Using a Custom Profile
|
|
88
|
-
|
|
89
|
-
If you're developing an extension that will be used in different regions (or need to work with a specific profile), you can create a new profile using `kong configure`. Then, include the `--profile <name>` parameter when running the publish-version and set-alias commands to use the desired profile.
|
|
90
|
-
|
|
91
|
-
### Update CLI
|
|
92
|
-
|
|
93
|
-
To install the latest version of the CLI, run:
|
|
94
|
-
|
|
95
|
-
```shell script
|
|
96
|
-
npm i -g @devkong/cli@latest
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
### Troubleshooting
|
|
100
|
-
|
|
101
|
-
#### Mac M2 Users
|
|
102
|
-
|
|
103
|
-
To emulate a Linux platform, you need to install Rosetta:
|
|
104
|
-
|
|
105
|
-
```shell script
|
|
106
|
-
softwareupdate --install-rosetta
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
#### Using a Different Python Version
|
|
110
|
-
|
|
111
|
-
To change the Python version, update the `FROM` statement in the `Dockerfile` to the desired version from [Docker Hub](https://hub.docker.com/_/python/):
|
|
112
|
-
|
|
113
|
-
```docker
|
|
114
|
-
FROM --platform=linux/amd64 python:3.13.1-slim-bullseye
|
|
115
|
-
```
|
|
File without changes
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import sys
|
|
2
|
-
from typing import Optional
|
|
3
|
-
|
|
4
|
-
from kong.sdk.app import App
|
|
5
|
-
from kong.sdk.kong_function import KongFunction
|
|
6
|
-
from pydantic import BaseModel, Field
|
|
7
|
-
|
|
8
|
-
# This script is for developing an extension for Kong.
|
|
9
|
-
# For more details, please refer to the README.md file.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
class InputData(BaseModel):
|
|
13
|
-
# Define the structure of the input data that your extension will accept.
|
|
14
|
-
# Be sure to include example values for each field. These examples help generate
|
|
15
|
-
# sample objects in the UI, making it easier to work with the models.
|
|
16
|
-
# For more standard types, refer to: https://docs.pydantic.dev/latest/concepts/types/
|
|
17
|
-
|
|
18
|
-
# REPLACE BELLOW WITH YOUR FIELDS
|
|
19
|
-
|
|
20
|
-
a: int = Field(
|
|
21
|
-
examples=[1],
|
|
22
|
-
description="An integer number",
|
|
23
|
-
)
|
|
24
|
-
|
|
25
|
-
b: int = Field(
|
|
26
|
-
examples=[2],
|
|
27
|
-
description="An integer number",
|
|
28
|
-
)
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
class OutputData(BaseModel):
|
|
32
|
-
# Define the structure of the output data that your extension will return.
|
|
33
|
-
|
|
34
|
-
# REPLACE BELLOW WITH YOUR FIELDS
|
|
35
|
-
|
|
36
|
-
sum_of: int = Field(
|
|
37
|
-
examples=[3],
|
|
38
|
-
description="Result of a + b",
|
|
39
|
-
)
|
|
40
|
-
|
|
41
|
-
comment: Optional[str] = Field(
|
|
42
|
-
examples=["This example extension returns sum of a and b"],
|
|
43
|
-
description="A string field",
|
|
44
|
-
)
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
class MyExtension(KongFunction):
|
|
48
|
-
# This is where you implement the logic to handle the input data
|
|
49
|
-
# and produce the output.
|
|
50
|
-
|
|
51
|
-
# OVERRIDE BELLOW TO CUSTOMIZE THE PROCESSING.
|
|
52
|
-
|
|
53
|
-
async def handle(self, data: InputData) -> OutputData:
|
|
54
|
-
return OutputData(
|
|
55
|
-
sum_of=data.a + data.b,
|
|
56
|
-
comment=f"sum of {data.a} and {data.b}",
|
|
57
|
-
)
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
app = App(
|
|
61
|
-
InputData,
|
|
62
|
-
OutputData,
|
|
63
|
-
MyExtension,
|
|
64
|
-
)
|
|
65
|
-
|
|
66
|
-
if __name__ == "__main__":
|
|
67
|
-
app.run(sys.argv)
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
from kong.sdk.conftest import ExtensionFixture
|
|
2
|
-
from src.main import InputData, MyExtension
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
# The test function to validate the behavior of the extension
|
|
6
|
-
async def test_should_return_value_from_string_field_when_input_is_provided(
|
|
7
|
-
create_extension: ExtensionFixture,
|
|
8
|
-
):
|
|
9
|
-
extension = create_extension(MyExtension, InputData)
|
|
10
|
-
|
|
11
|
-
# Prepare the input data
|
|
12
|
-
input_data = InputData(
|
|
13
|
-
a=1,
|
|
14
|
-
b=2,
|
|
15
|
-
)
|
|
16
|
-
|
|
17
|
-
output = await extension.handle(input_data)
|
|
18
|
-
assert output.sum_of == 3
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://json-schema.org/schema",
|
|
3
|
-
"$id": "Preset",
|
|
4
|
-
"title": "",
|
|
5
|
-
"type": "object",
|
|
6
|
-
"properties": {
|
|
7
|
-
"name": {
|
|
8
|
-
"type": "string",
|
|
9
|
-
"description": "",
|
|
10
|
-
"$default": {
|
|
11
|
-
"$source": "argv",
|
|
12
|
-
"index": 0
|
|
13
|
-
},
|
|
14
|
-
"x-prompt": "What name would you like to use?"
|
|
15
|
-
},
|
|
16
|
-
"platform": {
|
|
17
|
-
"type": "string",
|
|
18
|
-
"description": "",
|
|
19
|
-
"$default": {
|
|
20
|
-
"$source": "argv",
|
|
21
|
-
"index": 1
|
|
22
|
-
},
|
|
23
|
-
"x-prompt": "What platform would you like to use?"
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
"required": ["name"]
|
|
27
|
-
}
|