Skip to content

Conversation

kraenhansen
Copy link
Collaborator

@kraenhansen kraenhansen commented Sep 26, 2025

As part of #254 I wanted to use the CMake file API to read target information - this took me and my Copilot agent down a vibe-coding rabbit hole and this PR serves as proof of what was committed to the repo when I woke up the next morning 🫨

To be clear:

  1. There's a lot of code here ... I did however take very deliberate care to introduce it gradually as I established patterns along the way.
  2. This is total overkill for what I actually need right now ... But then again 🤷 This might make it easier to dig into the CMake internals for other future ideas to flourish 😊

What is this madness?

The CMake File API provides an interface for querying CMake's configuration and project information.

The API is based on files, where queries are written by client tools and read by CMake and replies are then written by CMake and read by client tools. The API is versioned, and the current version is v1 and these files are located in a directory named .cmake/api/v1 in the build directory.

This package provides a TypeScript interface to create query files and read replies and is intended to serve the same purpose to the TypeScript community that the cmake-file-api crate, serves to the Rust community.


Note

Introduce packages/cmake-file-api providing TS schemas and helpers to write CMake queries and read replies, plus repo config updates and VS Code task.

  • New package: packages/cmake-file-api
    • Schemas (Zod): ReplyIndexV1, CodemodelV2, TargetV2 (v2.0–2.8), CacheV2, CmakeFilesV1 (v1.0–1.1), ToolchainsV1, ConfigureLogV1 in src/schemas/**/*.
    • Query helpers (src/query.ts): createSharedStatelessQuery, createClientStatelessQuery, createClientStatefulQuery.
    • Reply readers (src/reply.ts): findCurrentReplyIndexPath, readReplyIndex, isReplyErrorIndexPath, readReplyErrorIndex, readCodemodel, readCurrentSharedCodemodel, readCurrentTargets, readCurrentTargetsDeep, readTarget, readCache, readCmakeFiles, readToolchains, readConfigureLog.
    • Exports: surfaced via src/index.ts and src/schemas.ts.
    • Docs/Tests/Config: README.md, bundled CMake docs (docs/cmake-file-api.7.rst.txt), extensive tests (src/*.test.ts), package tsconfig.json and tsconfig.tests.json.
  • Repo configuration
    • Add workspace and TS project refs for cmake-file-api (root package.json, tsconfig.json).
    • VS Code task .vscode/tasks.json to run cmake-file-api tests.
    • New root and package Copilot instructions (.github/copilot-instructions.md, packages/cmake-file-api/copilot-instructions.md).
    • TS config tweaks: new configs/tsconfig.node-tests.json; broaden includes/excludes in configs/tsconfig.node.json; packages/cli-utils/tsconfig.json now extends configs/tsconfig.node.json.
    • Version bumps in workspace metadata (package-lock.json) aligning dependent package versions.

Written by Cursor Bugbot for commit 61303ee. This will update automatically on new commits. Configure here.

@kraenhansen kraenhansen self-assigned this Sep 26, 2025
@kraenhansen kraenhansen marked this pull request as ready for review September 26, 2025 23:45
@kraenhansen kraenhansen added the enhancement New feature or request label Sep 26, 2025
Comment on lines +1 to +17
{
"extends": "./tsconfig.node.json",
"compilerOptions": {
"composite": true,
"emitDeclarationOnly": true,
"declarationMap": false
},
"include": ["${configDir}/src/**/*.test.ts"],
"exclude": []
/*
"references": [
{
"path": "./tsconfig.json"
}
]
*/
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a drive-by refactor, I'm creating this tsconfig, which I intent to share from other packages of the repo.

@@ -0,0 +1,77 @@
# Copilot Instructions for React Native Node-API
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created this as part of my use of Copilot.

@kraenhansen kraenhansen force-pushed the kh/cmake-file-api-package branch from 57a5fbf to 898559b Compare September 26, 2025 23:53
@kraenhansen kraenhansen added Apple 🍎 Anything related to the Apple platform (iOS, macOS, Cocoapods, Xcode, XCFrameworks, etc.) Android 🤖 Anything related to the Android platform (Gradle, NDK, Android SDK) and removed Apple 🍎 Anything related to the Apple platform (iOS, macOS, Cocoapods, Xcode, XCFrameworks, etc.) Android 🤖 Anything related to the Android platform (Gradle, NDK, Android SDK) labels Sep 27, 2025
@kraenhansen kraenhansen merged commit 9c6d606 into main Sep 28, 2025
7 checks passed
@kraenhansen kraenhansen deleted the kh/cmake-file-api-package branch September 28, 2025 17:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant