Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Codegen fixups concerning dashes and jsr deps #17

Merged
merged 5 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/deno-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
- v1.41
- v1.43
- v1.45
- v2.0
- canary
fail-fast: false # run each branch to completion

Expand Down
2 changes: 1 addition & 1 deletion generation/codegen-structs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 ');
Expand Down
8 changes: 7 additions & 1 deletion generation/codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ 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:') && path.includes('@')) {
return `from "${apisModuleRoot}${path.split('/')[1].replace('@', '/')}"`;
} else {
return `from "${apisModuleRoot}${path}"`;
}
});
}
return text;
}
Expand Down
3 changes: 3 additions & 0 deletions lib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down