Skip to content

Commit

Permalink
feat(cli)!: restructure models by k8s group and version (#94)
Browse files Browse the repository at this point in the history
instead of modifying the open-api schema file, work with the output ts files
thus, removed group-version-kind-map.json and added schemas.json

use tsx instead of bun to run the ts-morph, because bun was incredibly slow compared to tsx
  • Loading branch information
shinebayar-g authored Feb 6, 2025
1 parent b552816 commit 432f6a0
Show file tree
Hide file tree
Showing 14 changed files with 7,580 additions and 4,049 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ dist
*.cts
*.mjs

.DS_Store

packages/cli/files
packages/cli/gen
packages/cli/src/models
41 changes: 19 additions & 22 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ SHELL := /bin/bash
k8sVersion := v1.32.1


.PHONY: all
all: download-schema parse-schema models core


# Download Kubernetes OpenAPI schemas to packages/cli/input-spec/*.json
.PHONY: download-schema
download-schema:
Expand All @@ -16,36 +20,29 @@ download-schema:
@rm -rf temp-k8s


# Generate packages/cli/src/input-spec/*.json files
# Generate group-version-kind-map.json
.PHONY: prepare-schema
prepare-schema:
@echo "Preparing Kubernetes schema"
# Generate schemas.json
.PHONY: parse-schema
parse-schema:
@cd packages/cli && \
echo ${PWD}; bun run src/prepareSchemas.ts
npx tsx src/parseSchemas.ts


# Generate packages/cli/files/gen/models/*.ts files
# Generate packages/cli/gen/models/*.ts files
.PHONY: models
models: prepare-schema
models:
@echo "Generating Kubernetes models"
@cd packages/cli && \
pnpm gen && \
rsync -a --delete files/gen/models/ ../core/src/models/
@cd packages/cli && pnpm gen


.PHONY: restore-models
restore-models:
@echo "Restoring Kubernetes models"
@rsync -a --delete packages/cli/files/gen/models/ packages/core/src/models/
.PHONY: copy-models
copy-models:
@echo "Copying Kubernetes models"
@rsync -a --delete packages/cli/gen/models/ packages/core/src/models/


# Generate packages/core/src/models/*.ts files
# Update packages/core/src/models/*.ts files
.PHONY: core
core: restore-models
core: copy-models
@echo "Generating @k8skonf/core package"
@cd packages/cli && \
bun src/generateCore.ts && \
cd ../core && \
pnpm lint && \
pnpm tsc --noEmit
@cd packages/cli && npx tsx src/generateCore.ts
@cd packages/core && pnpm lint && pnpm tsc --noEmit
Loading

0 comments on commit 432f6a0

Please sign in to comment.