-
Notifications
You must be signed in to change notification settings - Fork 192
fix(cli): build SDK before native release artifacts #3795
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,8 @@ import { ensureNoUnknownFlags, isDirectExecution, repoRoot, runCommand } from '. | |
| const allowedFlags = new Set(['--types']); | ||
| const superdocRoot = path.join(repoRoot, 'packages/superdoc'); | ||
| const documentApiRoot = path.join(repoRoot, 'packages/document-api'); | ||
| const sdkWorkspaceRoot = path.join(repoRoot, 'packages/sdk'); | ||
| const nodeSdkRoot = path.join(sdkWorkspaceRoot, 'langs/node'); | ||
| const documentApiProject = path.relative(repoRoot, documentApiRoot); | ||
|
|
||
| /** | ||
|
|
@@ -16,9 +18,25 @@ export function ensureDocumentApiBuild(run = runCommand) { | |
| run('pnpm', ['exec', 'tsc', '-b', documentApiProject], 'Build document-api dist for CLI runtime'); | ||
| } | ||
|
|
||
| /** | ||
| * Ensures the Node SDK package resolves for CLI builds. | ||
| * | ||
| * The CLI imports `@superdoc-dev/sdk` for `doc.preset.*`; Bun resolves that | ||
| * package through its dist export while compiling native binaries. SDK | ||
| * generation exports the CLI contract first, which builds document-api dist | ||
| * for clean checkouts. | ||
| * | ||
| * @returns {void} | ||
| */ | ||
| export function ensureNodeSdkBuild(run = runCommand) { | ||
| run('pnpm', ['--prefix', sdkWorkspaceRoot, 'run', 'generate'], 'Generate SDK artifacts for CLI runtime'); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When any CLI lifecycle script that calls Useful? React with 👍 / 👎. |
||
| run('pnpm', ['--prefix', nodeSdkRoot, 'run', 'build'], 'Build Node SDK for CLI runtime'); | ||
| } | ||
|
Comment on lines
+31
to
+34
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 1. Sdk tools dir not prepared ensureNodeSdkBuild builds the Node SDK dist but never creates the package-level tools/ directory that the SDK presets read at runtime; doc.preset.* can throw TOOLS_ASSET_NOT_FOUND on clean checkouts/native binaries. This breaks CLI preset operations because the SDK resolves tool JSON relative to @superdoc-dev/sdk’s package root, while codegen writes tools to packages/sdk/tools instead. Agent Prompt
|
||
|
|
||
| /** | ||
| * Ensures the CLI's runtime dependencies are freshly built: | ||
| * - document-api contract/catalog dist consumed by CLI + SDK generation | ||
| * - document-api contract/catalog dist consumed by CLI metadata export | ||
| * - Node SDK dist consumed by `doc.preset.*` | ||
| * - packaged `superdoc` for the v1 runtime path | ||
| * | ||
| * `--types` performs the full published build so package type exports exist. | ||
|
|
@@ -32,7 +50,7 @@ export function ensureSuperdocBuild(options = {}, run = runCommand) { | |
| const scriptName = includeTypes ? 'build:es' : 'build:dev'; | ||
| const label = includeTypes ? 'Build packaged SuperDoc runtime and types' : 'Build packaged SuperDoc runtime'; | ||
|
|
||
| ensureDocumentApiBuild(run); | ||
| ensureNodeSdkBuild(run); | ||
| run('pnpm', ['--prefix', superdocRoot, 'run', scriptName], label); | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2. Os-dependent path assertions
🐞 Bug☼ ReliabilityThe new ensureNodeSdkBuild test hard-codes POSIX fragments ("/packages/sdk"), but production code uses path.join(...) for --prefix, which yields platform-specific separators. This will fail on Windows (and is fragile across path normalization differences).Agent Prompt
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools