From 5e1eaf5e74d24be149ea497867232e015b66da48 Mon Sep 17 00:00:00 2001 From: Daniel Lamando Date: Tue, 15 Oct 2024 08:50:17 +0200 Subject: [PATCH 1/5] fix(generation): Add a missing maybeQuote() Fixes #14 --- generation/codegen-structs.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generation/codegen-structs.ts b/generation/codegen-structs.ts index de21c6c..74d5db7 100644 --- a/generation/codegen-structs.ts +++ b/generation/codegen-structs.ts @@ -291,7 +291,7 @@ export function generateStructsTypescript(surface: SurfaceMap, apiS: SurfaceApi) chunks.push('{'); for (const [field, inner] of shape.fields) { const isReq = shape.required.includes(field); - chunks.push(` ${field}${isReq ? '' : '?'}: ${generateType(inner)}${isReq ? '' : ' | null'};`); + chunks.push(` ${maybeQuote(field)}${isReq ? '' : '?'}: ${generateType(inner)}${isReq ? '' : ' | null'};`); } chunks.push('}'); return chunks.join('\n').replace(/\n/g, '\n '); From 1bb73b3f807c2153051765b925003153a3583568 Mon Sep 17 00:00:00 2001 From: Daniel Lamando Date: Tue, 15 Oct 2024 08:59:18 +0200 Subject: [PATCH 2/5] feat(codegen): Support importing APIs from JSR Fixes #15 --- generation/codegen.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/generation/codegen.ts b/generation/codegen.ts index 8862797..f05234f 100644 --- a/generation/codegen.ts +++ b/generation/codegen.ts @@ -8,7 +8,17 @@ export async function writeApiModule(surface: SurfaceMap, api: SurfaceApi, categ function postProcess(text: string) { if (apisModuleRoot) { - text = text.replaceAll(/from "..\/..\//g, `from "${apisModuleRoot}`); + text = text.replaceAll(/from "..\/..\/([^"]+)"/g, (_, path) => { + if (apisModuleRoot.startsWith('jsr:')) { + if (path.includes('@')) { + return `from "${apisModuleRoot}${path.split('/')[1].replace('@', '/')}"`; + } else { + return `from "${apisModuleRoot}${path}"`; + } + } else { + return `from "${apisModuleRoot}${path}"`; + } + }); } return text; } From 8214d5444a8500ed7580e7a367d10e5f2c1c4c89 Mon Sep 17 00:00:00 2001 From: Daniel Lamando Date: Wed, 16 Oct 2024 21:17:35 +0200 Subject: [PATCH 3/5] Simplify conditional --- generation/codegen.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/generation/codegen.ts b/generation/codegen.ts index f05234f..bab28f6 100644 --- a/generation/codegen.ts +++ b/generation/codegen.ts @@ -9,12 +9,8 @@ export async function writeApiModule(surface: SurfaceMap, api: SurfaceApi, categ function postProcess(text: string) { if (apisModuleRoot) { text = text.replaceAll(/from "..\/..\/([^"]+)"/g, (_, path) => { - if (apisModuleRoot.startsWith('jsr:')) { - if (path.includes('@')) { - return `from "${apisModuleRoot}${path.split('/')[1].replace('@', '/')}"`; - } else { - return `from "${apisModuleRoot}${path}"`; - } + if (apisModuleRoot.startsWith('jsr:') && path.includes('@')) { + return `from "${apisModuleRoot}${path.split('/')[1].replace('@', '/')}"`; } else { return `from "${apisModuleRoot}${path}"`; } From 82a09d8232a43dd02f90a4e2561def9ff2fb67e7 Mon Sep 17 00:00:00 2001 From: Daniel Lamando Date: Wed, 16 Oct 2024 21:54:06 +0200 Subject: [PATCH 4/5] Add a release note --- lib/README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/README.md b/lib/README.md index abcdff3..d0313ce 100644 --- a/lib/README.md +++ b/lib/README.md @@ -32,6 +32,9 @@ see `/x/kubernetes_client` for more information. ## Changelog +* `v0.5.3` on `2024-10-16`: + * Fix CRD codegen issues with particular definitions and when using JSR import paths. + * `v0.5.2` on `2024-09-28`: * Includes 'builtin' APIs generated from K8s `v1.30.4`. * New kinds `ValidatingAdmissionPolicy`, `ServiceCIDR`, `ResourceSlice` From 15361b721e875f93be3e39a417371bf50f0269e5 Mon Sep 17 00:00:00 2001 From: Daniel Lamando Date: Wed, 16 Oct 2024 21:54:46 +0200 Subject: [PATCH 5/5] ci: Add deno v2 --- .github/workflows/deno-ci.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/deno-ci.yaml b/.github/workflows/deno-ci.yaml index 0b7ca22..039144c 100644 --- a/.github/workflows/deno-ci.yaml +++ b/.github/workflows/deno-ci.yaml @@ -16,6 +16,7 @@ jobs: - v1.41 - v1.43 - v1.45 + - v2.0 - canary fail-fast: false # run each branch to completion