Skip to content
Open
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
2 changes: 1 addition & 1 deletion .github/workflows/preview-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ permissions: {}
jobs:
publish:
# Skip for forks — they don't have write access needed by pkg-pr-new.
if: github.repository_owner == 'cloudflare'
if: github.repository_owner == 'cloudflare' || github.repository_owner == 'streamloop'
Comment on lines 13 to +14
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

find . -name "preview-release.yml" -type f

Repository: streamloop/vinext

Length of output: 100


🏁 Script executed:

cat -n .github/workflows/preview-release.yml

Repository: streamloop/vinext

Length of output: 696


🌐 Web query:

GitHub Actions pull_request event fork head.repo.full_name documentation

💡 Result:

In GitHub Actions workflows triggered by the pull_request event, the full name of the fork repository (head repository) is available in the github context as github.event.pull_request.head.repo.full_name. This is a string in the format "owner/repo" for the repository containing the head branch of the pull request. This property is particularly useful for distinguishing pull requests from forks. For example, to skip a job if the PR originates from a fork: jobs: example: if: github.event.pull_request.head.repo.full_name == github.repository runs-on: ubuntu-latest steps: - ... The github.event context mirrors the webhook payload for the pull_request event, where head.repo is a repository object containing full_name, fork (boolean), name, etc. Official GitHub documentation confirms github.event is the full event webhook payload, and community/official action docs reference this path explicitly for fork detection in pull_request events. Note: This is only populated for pull_request and pull_request_target events. For forks, head.repo.full_name differs from github.repository (the base repo).

Citations:


Skip fork PRs explicitly, not just non-owned repos.

For pull_request events, GitHub sends fork PR events to the base repository. The condition github.repository_owner == 'cloudflare' || github.repository_owner == 'streamloop' will always evaluate to true for PRs to this repository regardless of fork origin, because github.repository_owner refers to the base repository owner, not the PR's source. This means fork PRs still enter the publish job, contradicting the Line 13 comment intent.

To properly skip fork PRs, guard the job with both an owner check and a fork detection:

Suggested fix
-    if: github.repository_owner == 'cloudflare' || github.repository_owner == 'streamloop'
+    if: >
+      (github.repository_owner == 'cloudflare' || github.repository_owner == 'streamloop') &&
+      (
+        github.event_name != 'pull_request' ||
+        github.event.pull_request.head.repo.full_name == github.repository
+      )
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# Skip for forks — they don't have write access needed by pkg-pr-new.
if: github.repository_owner == 'cloudflare'
if: github.repository_owner == 'cloudflare' || github.repository_owner == 'streamloop'
# Skip for forks — they don't have write access needed by pkg-pr-new.
if: >
(github.repository_owner == 'cloudflare' || github.repository_owner == 'streamloop') &&
(
github.event_name != 'pull_request' ||
github.event.pull_request.head.repo.full_name == github.repository
)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/preview-release.yml around lines 13 - 14, The current
workflow condition only checks repository owner and therefore still runs for
forked PRs; update the job's if condition (the same guarded block that
references pkg-pr-new in the workflow) to additionally detect and skip forked
pull requests by requiring either that this is not a pull_request event or that
github.event.pull_request.head.repo.fork == false; in practice replace the
existing if with a combined expression that keeps the owner check
(github.repository_owner == 'cloudflare' || github.repository_owner ==
'streamloop') AND also requires (github.event_name != 'pull_request' ||
github.event.pull_request.head.repo.fork == false) so fork PRs are excluded.

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
Expand Down
737 changes: 736 additions & 1 deletion packages/vinext/README.md

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions packages/vinext/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"dev": "vp pack --watch"
},
"dependencies": {
"@capsizecss/metrics": "catalog:",
"@unpic/react": "catalog:",
"@vercel/og": "catalog:",
"magic-string": "catalog:",
Expand Down
67 changes: 67 additions & 0 deletions packages/vinext/src/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1360,6 +1360,73 @@ export async function deploy(options: DeployOptions): Promise<void> {
}
}

// Step 6c: Patch dist/server/wrangler.json with env configs from the user's
// wrangler.jsonc. The @cloudflare/vite-plugin strips env-specific sections
// when generating the output config, so `wrangler deploy --env <name>` can't
// resolve environment-specific vars/bindings from the generated file alone.
{
const distWranglerPath = path.join(root, "dist", "server", "wrangler.json");
if (fs.existsSync(distWranglerPath)) {
const userConfigPath = ["wrangler.jsonc", "wrangler.json", "wrangler.toml"]
.map((f) => path.join(root, f))
.find((f) => fs.existsSync(f));

if (userConfigPath && (userConfigPath.endsWith(".json") || userConfigPath.endsWith(".jsonc"))) {
try {
const userRaw = fs.readFileSync(userConfigPath, "utf-8");
// Strip JSONC comments while preserving strings (// inside "..." is not a comment)
let userClean = "";
let inString = false;
let i = 0;
while (i < userRaw.length) {
if (inString) {
if (userRaw[i] === "\\" && i + 1 < userRaw.length) {
userClean += userRaw[i] + userRaw[i + 1];
i += 2;
} else if (userRaw[i] === '"') {
userClean += '"';
inString = false;
i++;
} else {
userClean += userRaw[i];
i++;
}
} else if (userRaw[i] === '"') {
userClean += '"';
inString = true;
i++;
} else if (userRaw[i] === "/" && userRaw[i + 1] === "/") {
// Skip to end of line
while (i < userRaw.length && userRaw[i] !== "\n") i++;
} else if (userRaw[i] === "/" && userRaw[i + 1] === "*") {
i += 2;
while (i < userRaw.length && !(userRaw[i] === "*" && userRaw[i + 1] === "/")) i++;
i += 2;
} else {
userClean += userRaw[i];
i++;
}
}
// Remove trailing commas
userClean = userClean.replace(/,\s*([\]}])/g, "$1");
const userConfig = JSON.parse(userClean);

if (userConfig.env) {
const distConfig = JSON.parse(fs.readFileSync(distWranglerPath, "utf-8"));
distConfig.env = userConfig.env;
// Also ensure migrations are carried over
if (userConfig.migrations && !distConfig.migrations?.length) {
distConfig.migrations = userConfig.migrations;
}
fs.writeFileSync(distWranglerPath, JSON.stringify(distConfig));
}
} catch {
// Non-fatal — deploy will proceed with existing config
}
Comment on lines +1423 to +1425
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Add a warning log when env patching fails.

Silent error swallowing here could confuse users when wrangler deploy --env <name> subsequently fails due to missing env config. A warning helps diagnose issues.

🛠️ Proposed fix
-        } catch {
-          // Non-fatal — deploy will proceed with existing config
+        } catch (err) {
+          // Non-fatal — deploy will proceed with existing config
+          console.warn(`  Warning: Could not patch wrangler.json with env config: ${err instanceof Error ? err.message : err}`);
         }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
} catch {
// Non-fatal — deploy will proceed with existing config
}
} catch (err) {
// Non-fatal — deploy will proceed with existing config
console.warn(` Warning: Could not patch wrangler.json with env config: ${err instanceof Error ? err.message : err}`);
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/vinext/src/deploy.ts` around lines 1423 - 1425, The silent catch
after the env-patching try block should capture the error (change to catch
(err)) and emit a warning with context so users know env patching failed; e.g.,
call the existing logger (processLogger.warn or logger.warn) with a message like
"Failed to patch env for deploy --env <name>" and include err (or
err.message/stack) so the failure is visible while still allowing deploy to
proceed.

}
}
}

// Step 7: Deploy via wrangler
const url = runWranglerDeploy(root, {
preview: options.preview ?? false,
Expand Down
Loading