@devkong/cli-nx 0.0.67-alpha.2 → 0.0.67-alpha.20

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.
Files changed (59) hide show
  1. package/package.json +1 -1
  2. package/src/generators/preset/files/kotlin/.dockerignore +6 -0
  3. package/src/generators/preset/files/kotlin/.editorconfig +24 -0
  4. package/src/generators/preset/files/kotlin/.vscode/extensions.json +18 -0
  5. package/src/generators/preset/files/kotlin/.vscode/launch.json +16 -0
  6. package/src/generators/preset/files/kotlin/.vscode/settings.json +7 -0
  7. package/src/generators/preset/files/kotlin/.vscode/tasks.json +81 -0
  8. package/src/generators/preset/files/kotlin/Dockerfile +58 -0
  9. package/src/generators/preset/files/kotlin/README.md +165 -0
  10. package/src/generators/preset/files/kotlin/build.gradle.kts.template +64 -0
  11. package/src/generators/preset/files/kotlin/gradle/wrapper/gradle-wrapper.jar +0 -0
  12. package/src/generators/preset/files/kotlin/gradle/wrapper/gradle-wrapper.properties +6 -0
  13. package/src/generators/preset/files/kotlin/gradle.properties +25 -0
  14. package/src/generators/preset/files/kotlin/gradlew +245 -0
  15. package/src/generators/preset/files/kotlin/gradlew.bat +92 -0
  16. package/src/generators/preset/files/kotlin/kong.json.template +6 -0
  17. package/src/generators/preset/files/kotlin/project.json.template +29 -0
  18. package/src/generators/preset/files/kotlin/settings.gradle.kts +14 -0
  19. package/src/generators/preset/files/kotlin/src/main/kotlin/io/kong/extension/InputData.kt +26 -0
  20. package/src/generators/preset/files/kotlin/src/main/kotlin/io/kong/extension/Main.kt +72 -0
  21. package/src/generators/preset/files/kotlin/src/main/kotlin/io/kong/extension/OutputData.kt +15 -0
  22. package/src/generators/preset/files/kotlin/src/main/kotlin/io/kong/extension/RegisterFrontend.kt +21 -0
  23. package/src/generators/preset/files/kotlin/src/main/resources/META-INF/resources/index.html +362 -0
  24. package/src/generators/preset/files/kotlin/src/main/resources/application.properties.template +3 -0
  25. package/src/generators/preset/files/kotlin/src/main/resources/reflect-config.json.template +1 -0
  26. package/src/generators/preset/files/kotlin/src/test/kotlin/io/kong/extension/Test.kt +40 -0
  27. package/src/generators/preset/files/python/.dockerignore +5 -0
  28. package/src/generators/preset/files/python/.editorconfig +16 -0
  29. package/src/generators/preset/files/python/.gitattributes +25 -0
  30. package/src/generators/preset/files/python/.gitignore.template +69 -0
  31. package/src/generators/preset/files/python/.idea/inspectionProfiles/Project_Default.xml +7 -0
  32. package/src/generators/preset/files/python/.idea/inspectionProfiles/profiles_settings.xml +6 -0
  33. package/src/generators/preset/files/python/.idea/kong-cli-python-template.iml +10 -0
  34. package/src/generators/preset/files/python/.pylintrc +543 -0
  35. package/src/generators/preset/files/python/.vscode/extensions.json +14 -0
  36. package/src/generators/preset/files/python/.vscode/launch.json +19 -0
  37. package/src/generators/preset/files/python/.vscode/settings.json +65 -0
  38. package/src/generators/preset/files/python/Dockerfile +30 -0
  39. package/src/generators/preset/files/python/README.md +255 -0
  40. package/src/generators/preset/files/python/kong.json.template +6 -0
  41. package/src/generators/preset/files/python/project.json.template +8 -0
  42. package/src/generators/preset/files/python/pyproject.toml +3 -0
  43. package/src/generators/preset/files/python/requirements-dev.txt +10 -0
  44. package/src/generators/preset/files/python/requirements.txt +2 -0
  45. package/src/generators/preset/files/python/src/__init__.py +0 -0
  46. package/src/generators/preset/files/python/src/frontend.py +3 -0
  47. package/src/generators/preset/files/python/src/input_data.py +13 -0
  48. package/src/generators/preset/files/python/src/main.py +28 -0
  49. package/src/generators/preset/files/python/src/main_test.py +19 -0
  50. package/src/generators/preset/files/python/src/output_data.py +15 -0
  51. package/src/generators/preset/files/python-advanced/src/frontend.py +9 -0
  52. package/src/generators/preset/files/python-advanced/src/input_data.py +47 -0
  53. package/src/generators/preset/files/python-advanced/src/main.py +51 -0
  54. package/src/generators/preset/files/python-advanced/src/main_test.py +46 -0
  55. package/src/generators/preset/files/python-advanced/src/output_data.py +16 -0
  56. package/src/generators/preset/generator.js +8 -0
  57. package/src/generators/preset/generator.js.map +1 -1
  58. package/src/generators/preset/schema.d.ts +7 -1
  59. package/src/generators/preset/schema.json +27 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devkong/cli-nx",
3
- "version": "0.0.67-alpha.2",
3
+ "version": "0.0.67-alpha.20",
4
4
  "type": "commonjs",
5
5
  "main": "./src/index.js",
6
6
  "typings": "./src/index.d.ts",
@@ -0,0 +1,6 @@
1
+ node_modules
2
+ .nx
3
+ .idea
4
+ .vscode
5
+ .kotlin
6
+ build
@@ -0,0 +1,24 @@
1
+ # Editor configuration, see http://editorconfig.org
2
+ root = true
3
+
4
+ [*]
5
+ indent_size = 2
6
+ end_of_line = lf
7
+ insert_final_newline = true
8
+ trim_trailing_whitespace = true
9
+
10
+ [*.{kt,kts}]
11
+ ktlint_code_style = ktlint_official
12
+ ktlint_ignore_back_ticked_identifier = true
13
+ ktlint_standard = enabled
14
+ indent_style = space
15
+ max_line_length = 100
16
+ # Don't allow any wildcard imports
17
+ ij_kotlin_packages_to_use_import_on_demand = unset
18
+ # Prevent wildcard imports
19
+ ij_kotlin_name_count_to_use_star_import = 99
20
+ ij_kotlin_name_count_to_use_star_import_for_members = 99
21
+
22
+ [*.md]
23
+ max_line_length = off
24
+ trim_trailing_whitespace = false
@@ -0,0 +1,18 @@
1
+ {
2
+ "recommendations": [
3
+ "nrwl.angular-console",
4
+ "esbenp.prettier-vscode",
5
+ "mathiasfrohlich.kotlin",
6
+ "nrwl.angular-console",
7
+ "redhat.java",
8
+ "redhat.vscode-microprofile",
9
+ "redhat.vscode-quarkus",
10
+ "redhat.vscode-redhat-account",
11
+ "stylelint.vscode-stylelint",
12
+ "vscjava.vscode-java-debug",
13
+ "vscjava.vscode-java-dependency",
14
+ "vscjava.vscode-java-pack",
15
+ "vscjava.vscode-java-test",
16
+ "vscjava.vscode-maven"
17
+ ]
18
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ // Use IntelliSense to learn about possible attributes.
3
+ // Hover to view descriptions of existing attributes.
4
+ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5
+ "version": "0.2.0",
6
+ "configurations": [
7
+ {
8
+ "preLaunchTask": "quarkusDev",
9
+ "type": "java",
10
+ "request": "attach",
11
+ "hostName": "localhost",
12
+ "name": "Debug Quarkus application",
13
+ "port": 5005
14
+ }
15
+ ]
16
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "java.compile.nullAnalysis.mode": "automatic",
3
+ "java.configuration.runtimes": [
4
+
5
+ ],
6
+ "java.configuration.updateBuildConfiguration": "interactive"
7
+ }
@@ -0,0 +1,81 @@
1
+ // See https://go.microsoft.com/fwlink/?LinkId=733558
2
+ // for the documentation about the tasks.json format
3
+ {
4
+ "version": "2.0.0",
5
+ "tasks": [
6
+ {
7
+ "type": "shell",
8
+ "isBackground": true,
9
+ "problemMatcher": [
10
+ {
11
+ "owner": "quarkus",
12
+ "fileLocation": [
13
+ "relative",
14
+ "${workspaceFolder}/src/main/resources/templates"
15
+ ],
16
+ "pattern": [
17
+ {
18
+ "regexp": "\\[(\\d+)\\]\\s(.*):(\\d+):(\\d+)\\s\\-\\s{(.*)}:\\s(.*)$",
19
+ "file": 2,
20
+ "line": 3,
21
+ "column": 4,
22
+ "message": 6
23
+ }
24
+ ],
25
+ "background": {
26
+ "activeOnStart": true,
27
+ "beginsPattern": "^.*Task: ",
28
+ "endsPattern": "(^.*Quarkus .* started in .*\\.)|(^.* ERROR .* Failed to start)"
29
+ }
30
+ }
31
+ ],
32
+ "group": "build",
33
+ "label": "quarkusDev",
34
+ "command": "./gradlew quarkusDev --console=plain",
35
+ "windows": {
36
+ "command": ".\\gradlew.bat quarkusDev --console=plain"
37
+ }
38
+ },
39
+ {
40
+ "type": "shell",
41
+ "isBackground": true,
42
+ "problemMatcher": [
43
+ {
44
+ "owner": "quarkus",
45
+ "fileLocation": [
46
+ "relative",
47
+ "${workspaceFolder}/src/main/resources/templates"
48
+ ],
49
+ "pattern": [
50
+ {
51
+ "regexp": "\\[(\\d+)\\]\\s(.*):(\\d+):(\\d+)\\s\\-\\s{(.*)}:\\s(.*)$",
52
+ "file": 2,
53
+ "line": 3,
54
+ "column": 4,
55
+ "message": 6
56
+ }
57
+ ],
58
+ "background": {
59
+ "activeOnStart": true
60
+ }
61
+ }
62
+ ],
63
+ "group": "build",
64
+ "label": "buildNative",
65
+ "command": "./gradlew buildNative --console=plain",
66
+ "windows": {
67
+ "command": ".\\gradlew.bat buildNative --console=plain"
68
+ }
69
+ },
70
+ {
71
+ "label": "build",
72
+ "type": "shell",
73
+ "command": "./gradlew build -x test",
74
+ "problemMatcher": [],
75
+ "group": {
76
+ "kind": "build",
77
+ "isDefault": true
78
+ }
79
+ }
80
+ ]
81
+ }
@@ -0,0 +1,58 @@
1
+ # syntax=docker/dockerfile:1
2
+
3
+ # ==============================================
4
+ # Stage 1: Build native executable
5
+ # ==============================================
6
+ FROM quay.io/quarkus/ubi-quarkus-mandrel-builder-image:jdk-21 AS build
7
+
8
+ # Switch to root for installation
9
+ USER root
10
+ RUN microdnf install -y findutils
11
+
12
+ # Copy Gradle wrapper and build configuration first (for better caching)
13
+ COPY --chown=quarkus:quarkus gradlew /code/gradlew
14
+ COPY --chown=quarkus:quarkus gradle /code/gradle
15
+ COPY --chown=quarkus:quarkus .editorconfig /code/
16
+ COPY --chown=quarkus:quarkus build.gradle.kts /code/
17
+ COPY --chown=quarkus:quarkus settings.gradle.kts /code/
18
+ COPY --chown=quarkus:quarkus gradle.properties /code/
19
+
20
+ # Switch user for security
21
+ USER quarkus
22
+ WORKDIR /code
23
+
24
+ # Make Gradle wrapper executable and download dependencies
25
+ RUN --mount=type=cache,target=/home/quarkus/.gradle,uid=1001,gid=1001 \
26
+ chmod +x gradlew && \
27
+ ./gradlew dependencies --no-daemon --stacktrace
28
+
29
+
30
+ # Build native executable
31
+ COPY --chown=quarkus:quarkus src /code/src
32
+ RUN --mount=type=cache,target=/home/quarkus/.gradle,uid=1001,gid=1001 \
33
+ ./gradlew build \
34
+ -Dquarkus.package.main-class=io.kong.sdk.function.template.QuarkusApp \
35
+ -Dquarkus.native.enabled=true \
36
+ -Dquarkus.profile=prod \
37
+ -Dquarkus.package.jar.enabled=false \
38
+ -x test \
39
+ --no-daemon \
40
+ --stacktrace
41
+
42
+ # ==============================================
43
+ # Stage 2: Create runtime image
44
+ # ==============================================
45
+ FROM quay.io/quarkus/quarkus-micro-image:2.0
46
+
47
+ WORKDIR /work/
48
+
49
+ RUN chown 1001 /work \
50
+ && chmod "g+rwX" /work \
51
+ && chown 1001:root /work
52
+ COPY --chown=1001:root --from=build /code/build/*-runner /work/application
53
+
54
+ EXPOSE 8080
55
+ USER 1001
56
+
57
+ CMD ["./application", "-Dquarkus.http.host=0.0.0.0"]
58
+
@@ -0,0 +1,165 @@
1
+ # Kong Extension
2
+
3
+ Welcome to the Kong extension development workspace!
4
+
5
+ To have a better experience, open this file in preview mode of your IDE.
6
+
7
+ ### Prerequisites
8
+
9
+ Before you start, make sure you have the following installed depending on your OS:
10
+
11
+ [▶ Windows](#windows-setup)
12
+
13
+ [▶ Ubuntu](#ubuntu-setup)
14
+
15
+ [▶ macOS](#macos-setup)
16
+
17
+ To verify the installation and check the versions, run the following commands:
18
+
19
+ ```shell script
20
+ node --version
21
+ docker info
22
+ ```
23
+
24
+ ### Getting Started
25
+
26
+ 1. Make sure you're in the terminal and inside the extension folder you generated
27
+ 2. Run the following commands in your terminal:
28
+
29
+ ```shell script
30
+ # configure the base Kong URL (e.g., https://sandbox.kong.dev.app-dts.net)
31
+ kong configure
32
+ ```
33
+
34
+ and assign aliases for use in the workflow.
35
+
36
+ ### Publish a New Version
37
+
38
+ To automatically tag your code with an incremented version number (e.g., 1, 2, 3), run:
39
+
40
+ ```shell script
41
+ kong publish-version --verbose
42
+ ```
43
+
44
+ ### List Available Versions
45
+
46
+ To see all available versions of your extension, run:
47
+
48
+ ```shell script
49
+ kong list-versions
50
+ ```
51
+
52
+ ### Assign an Alias to a Version
53
+
54
+ 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:
55
+
56
+ ```shell script
57
+ kong set-alias stable 1
58
+ ```
59
+
60
+ ### Using a Custom Profile
61
+
62
+ 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.
63
+
64
+ ### Update CLI
65
+
66
+ To install the latest version of the CLI, run:
67
+
68
+ ```shell script
69
+ npm i -g @devkong/cli@latest
70
+ ```
71
+
72
+ ### Setup
73
+
74
+ <details id="windows-setup">
75
+ <summary><strong>Windows</strong></summary>
76
+
77
+ ### Install Windows Subsystem for Linux (WSL2)
78
+
79
+ 1. Open PowerShell as Administrator.
80
+ 2. Run the following command to install WSL and set WSL2 as the default version:
81
+ ```powershell
82
+ wsl --install
83
+ ```
84
+ 3. Restart your computer if prompted.
85
+ 4. After restarting, install a preferred Linux distribution (e.g., Ubuntu) by running:
86
+ ```powershell
87
+ wsl --install -d Ubuntu
88
+ ```
89
+
90
+ ### Install Docker within WSL2
91
+
92
+ 1. Download Docker Desktop for Windows from [Docker's official website](https://www.docker.com/products/docker-desktop).
93
+ 2. Run the installer and follow the setup instructions.
94
+ 3. During installation, ensure the "Use the WSL 2 based engine" option is selected.
95
+ 4. Once installed, open Docker Desktop, go to Settings > General, and enable "Use WSL 2 based engine" if it isn't already enabled.
96
+ 5. Confirm Docker is working in your WSL2 distribution (e.g., Ubuntu) by running:
97
+ ```bash
98
+ docker --version
99
+ ```
100
+
101
+ ### Install Node.js and npm on Windows Host
102
+
103
+ 1. Download the Node.js installer for Windows from the [official Node.js website](https://nodejs.org/).
104
+ 2. Run the installer, making sure to include the npm package manager during installation.
105
+ 3. Verify installation by opening a new Command Prompt and running:
106
+ ```cmd
107
+ node -v
108
+ npm -v
109
+ ```
110
+
111
+ </details>
112
+
113
+ <details id="ubuntu-setup">
114
+ <summary><strong>Ubuntu</strong></summary>
115
+
116
+ ### Install Docker
117
+
118
+ 1. Follow the installation instructions on [Docker's official website](https://docs.docker.com/engine/install/ubuntu/).
119
+ 2. Start Docker and enable it to start on boot:
120
+ ```bash
121
+ sudo systemctl start docker
122
+ sudo systemctl enable docker
123
+ ```
124
+
125
+ ### Install Node.js and npm
126
+
127
+ 1. Run the following commands:
128
+ ```bash
129
+ sudo apt update
130
+ sudo apt install -y nodejs npm
131
+ ```
132
+ 2. Verify installation:
133
+ ```bash
134
+ node -v
135
+ npm -v
136
+ ```
137
+
138
+ </details>
139
+
140
+ <details id="macos-setup">
141
+ <summary><strong>macOS</strong></summary>
142
+
143
+ To emulate a Linux platform, you need to install Rosetta:
144
+
145
+ ```shell script
146
+ softwareupdate --install-rosetta
147
+ ```
148
+
149
+ ### Install Docker
150
+
151
+ 1. Download and install Docker Desktop for Mac from [Docker's official website](https://www.docker.com/products/docker-desktop).
152
+
153
+ ### Install Node.js and npm
154
+
155
+ 1. Use Homebrew to install:
156
+ ```bash
157
+ brew install node
158
+ ```
159
+ 2. Verify installation:
160
+ ```bash
161
+ node -v
162
+ npm -v
163
+ ```
164
+
165
+ </details>
@@ -0,0 +1,64 @@
1
+ val javaVersion: String by project
2
+ val kongVersion: String by project
3
+ val kotlinxCoroutinesTestVersion: String by project
4
+ val quarkusVersion: String by project
5
+
6
+ plugins {
7
+ kotlin("jvm")
8
+ kotlin("plugin.allopen")
9
+ id("io.quarkus")
10
+ id("org.jlleitschuh.gradle.ktlint")
11
+ }
12
+
13
+ repositories {
14
+ mavenCentral()
15
+ mavenLocal()
16
+ maven {
17
+ url = uri("https://nexus.shared.sg.app-dts.net/repository/maven-releases/")
18
+ }
19
+ maven {
20
+ url = uri("https://nexus.shared.sg.app-dts.net/repository/maven-snapshots/")
21
+ }
22
+ }
23
+
24
+ dependencies {
25
+ implementation("io.kong:kong-common:$kongVersion")
26
+ implementation("io.kong:kong-sdk-kotlin:$kongVersion")
27
+ implementation("io.kong:kong-sdk-function-template:$kongVersion")
28
+
29
+ implementation(enforcedPlatform("io.quarkus.platform:quarkus-bom:$quarkusVersion"))
30
+ implementation("io.quarkus:quarkus-arc")
31
+ implementation("io.quarkus:quarkus-jackson")
32
+ implementation("io.quarkus:quarkus-kotlin")
33
+
34
+ testImplementation("io.quarkus:quarkus-junit5")
35
+ testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:$kotlinxCoroutinesTestVersion")
36
+ }
37
+
38
+ group = "io.kong.extension"
39
+ version = "0.0.1-SNAPSHOT"
40
+
41
+ java {
42
+ sourceCompatibility = JavaVersion.toVersion(javaVersion)
43
+ targetCompatibility = JavaVersion.toVersion(javaVersion)
44
+ }
45
+
46
+ tasks.withType<Test> {
47
+ systemProperty("java.util.logging.manager", "org.jboss.logmanager.LogManager")
48
+ }
49
+
50
+ allOpen {
51
+ annotation("jakarta.ws.rs.Path")
52
+ annotation("jakarta.enterprise.context.ApplicationScoped")
53
+ annotation("jakarta.persistence.Entity")
54
+ annotation("io.quarkus.test.junit.QuarkusTest")
55
+ }
56
+
57
+ kotlin {
58
+ compilerOptions {
59
+ jvmTarget =
60
+ org.jetbrains.kotlin.gradle.dsl.JvmTarget
61
+ .fromTarget(javaVersion)
62
+ javaParameters = true
63
+ }
64
+ }
@@ -0,0 +1,6 @@
1
+ distributionBase=GRADLE_USER_HOME
2
+ distributionPath=wrapper/dists
3
+ distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.4-bin.zip
4
+ networkTimeout=10000
5
+ zipStoreBase=GRADLE_USER_HOME
6
+ zipStorePath=wrapper/dists
@@ -0,0 +1,25 @@
1
+ # Gradle properties
2
+ org.gradle.jvmargs=-Xms4g -Xmx4g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
3
+ kotlin.code.style=official
4
+ javaVersion=21
5
+
6
+ # kong artifacts
7
+ kongVersion=0.0.40-SNAPSHOT
8
+
9
+ # https://mvnrepository.com/artifact/org.jlleitschuh.gradle/ktlint-gradle
10
+ jlleitschuhGradlePluginVersion=14.0.1
11
+
12
+ #https://mvnrepository.com/artifact/com.networknt/json-schema-validator
13
+ jsonSchemaValidatorVersion=1.5.8
14
+
15
+ # https://mvnrepository.com/artifact/org.jetbrains.kotlin/kotlin-stdlib
16
+ kotlinVersion=2.1.21
17
+
18
+ # https://mvnrepository.com/artifact/org.jetbrains.kotlinx/kotlinx-coroutines-test
19
+ kotlinxCoroutinesTestVersion=1.10.2
20
+
21
+ # https://mvnrepository.com/artifact/dev.nx.gradle.project-graph/dev.nx.gradle.project-graph.gradle.plugin
22
+ nxGradleVersion=0.1.21
23
+
24
+ # https://mvnrepository.com/artifact/io.quarkus/quarkus-core
25
+ quarkusVersion=3.27.3