feat(cli): probe remote build sources for issue #133 - #889
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a remote-source “probe” path to the CLI build command so --from <url> can be validated and summarized (status, content-type, final URL) without downloading the full build source.
Changes:
- Introduces
probeRemoteBuild()to probe--fromURLs viaHEAD, falling back to a 1-byte rangedGET. - Makes the
buildcommand action async and prints a remote build summary for URL inputs. - Adds Vitest coverage for the new probe behavior (HEAD, fallback, and error cases).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/cli/src/commands/build.ts | Adds remote URL probing and prints a summary for build --from <url>. |
| packages/cli/src/commands/build.test.ts | Adds unit tests for probeRemoteBuild() behavior and error handling. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| let response = await fetch(input.value, { method: 'HEAD', redirect: 'follow' }); | ||
| if (response.status === 405 || response.status === 501) { | ||
| response = await fetch(input.value, { | ||
| method: 'GET', | ||
| headers: { Range: 'bytes=0-0' }, | ||
| redirect: 'follow', | ||
| }); | ||
| } | ||
| if (!response.ok) { | ||
| throw new Error(`build source returned HTTP ${response.status}: ${input.value}`); | ||
| } | ||
|
|
||
| return { | ||
| sourceUrl: input.value, | ||
| finalUrl: response.url || input.value, | ||
| status: response.status, | ||
| contentType: response.headers.get('content-type') ?? undefined, | ||
| }; | ||
| } |
|
🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: |
|
Resolved the merge conflicts against public |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Suppressed comments (1)
packages/cli/src/commands/build.ts:145
probeRemoteBuilddoes not consume or cancel the response body. In Node/undici this can keep the underlying connection open, and for the fallbackGETit may still download a full response if the server ignoresRange, contradicting the intent of probing without downloading.
let response = await fetch(input.value, { method: 'HEAD', redirect: 'follow' });
if (response.status === 405 || response.status === 501) {
response = await fetch(input.value, {
method: 'GET',
headers: { Range: 'bytes=0-0' },
redirect: 'follow',
});
}
if (!response.ok) {
throw new Error(`build source returned HTTP ${response.status}: ${input.value}`);
}
return {
sourceUrl: input.value,
finalUrl: response.url || input.value,
status: response.status,
contentType: response.headers.get('content-type') ?? undefined,
};
}
|
All required GitHub checks are now green and the PR is |
|
🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: |
1 similar comment
|
🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: |
Summary
Closes #133
Verification