-
Notifications
You must be signed in to change notification settings - Fork 1
Add Gomplate language tooling #176
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
base: main
Are you sure you want to change the base?
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 |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| import { createServer } from "node:net"; | ||
| import { describe, expect, it } from "vitest"; | ||
|
|
||
| import { findAvailablePort } from "../plugins/eval-server"; | ||
| import { createPlaygroundConfig } from "../vite.config"; | ||
|
|
||
| const SELECTED_EVAL_PORT = 49_153; | ||
|
|
||
| describe("playground Vite configuration", () => { | ||
| it.each([ | ||
| { command: "serve" as const, mode: "development", clickySourceAvailable: true, expected: true }, | ||
| { command: "serve" as const, mode: "test", clickySourceAvailable: true, expected: false }, | ||
| { command: "serve" as const, mode: "development", clickySourceAvailable: false, expected: false }, | ||
| { command: "build" as const, mode: "production", clickySourceAvailable: true, expected: false }, | ||
| ])( | ||
| "sets dependency re-optimization to $expected for command=$command mode=$mode source=$clickySourceAvailable", | ||
| ({ command, mode, clickySourceAvailable, expected }) => { | ||
| const config = createPlaygroundConfig({ | ||
| command, | ||
| mode, | ||
| clickySourceAvailable, | ||
| evalPort: SELECTED_EVAL_PORT, | ||
| }); | ||
|
|
||
| expect(config.optimizeDeps?.force).toBe(expected); | ||
| }, | ||
| ); | ||
|
|
||
| it("proxies API requests to the selected eval-server port", () => { | ||
| const config = createPlaygroundConfig({ | ||
| command: "serve", | ||
| mode: "development", | ||
| clickySourceAvailable: false, | ||
| evalPort: SELECTED_EVAL_PORT, | ||
| }); | ||
|
|
||
| expect(config.server?.proxy?.["/api"]).toMatchObject({ | ||
| target: `http://127.0.0.1:${SELECTED_EVAL_PORT}`, | ||
| }); | ||
| }); | ||
|
|
||
| it("selects another loopback port when the preferred port is occupied", async () => { | ||
| const occupied = createServer(); | ||
| await new Promise<void>((resolve, reject) => { | ||
| occupied.once("error", reject); | ||
| occupied.listen(0, "127.0.0.1", resolve); | ||
| }); | ||
|
|
||
| try { | ||
| const address = occupied.address(); | ||
| if (!address || typeof address === "string") throw new Error("test listener has no TCP port"); | ||
| const selectedPort = await findAvailablePort({ | ||
| host: "127.0.0.1", | ||
| preferredPort: address.port, | ||
| }); | ||
|
|
||
| expect(selectedPort).not.toBe(address.port); | ||
| } finally { | ||
| await new Promise<void>((resolve, reject) => { | ||
| occupied.close((error) => (error ? reject(error) : resolve())); | ||
| }); | ||
| } | ||
| }); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,5 +10,5 @@ | |
| "typecheck": "pnpm -r typecheck", | ||
| "dev:playground": "pnpm --filter gomplate-playground dev" | ||
| }, | ||
| "packageManager": "pnpm@10.34.5" | ||
| "packageManager": "pnpm@11.22.0+sha512.1ff870c4c6133dfd88fb2afc46dd13d47f09c9794b438c6fdb47ca98caf3bc16381ee0be93a091b8e3824cf01f889f46d7d9e20910fb0be1ab0fb5baa80dd621" | ||
|
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. 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win 🔎 Supported by static analysis🏁 Script executed: #!/bin/bash
printf '%s\n' '--- web/package.json ---'
cat -n web/package.json | sed -n '8,16p'
printf '%s\n' '--- .github/workflows/web.yml ---'
cat -n .github/workflows/web.yml | sed -n '24,42p'
printf '%s\n' '--- lockfile headers ---'
for f in web/pnpm-lock.yaml pnpm-lock.yaml; do
if [ -f "$f" ]; then
printf '%s\n' "--- $f ---"
sed -n '1,24p' "$f"
fi
doneRepository: flanksource/gomplate Length of output: 1951 🏁 Script executed: #!/bin/bash
cat -n .github/workflows/web.yml | sed -n '35,80p'
printf '%s\n' '--- package-manager references ---'
rg -n --glob '!web/pnpm-lock.yaml' 'packageManager|pnpm/action-setup|pnpm -C web|corepack|pnpm@' .github web/package.json package.json 2>/dev/nullRepository: flanksource/gomplate Length of output: 1499 Set CI’s pnpm version to
🤖 Prompt for AI Agents |
||
| } | ||
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.
🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift
Do not use a released probe as a port reservation.
Line 46 closes the selected port before the Go server binds it at Line 84. Another local process can bind that port during this interval. The Go server then exits with
EADDRINUSE, while Vite still proxies/apito the unavailable target.Start the evaluation server as part of port allocation and use its actual bound port for the Vite proxy. A probe that closes before
spawncannot prevent this conflict.Also applies to: 31-46
🧰 Tools
🪛 ast-grep (0.45.1)
[warning] Importing child_process exposes a command-execution surface; ensure any command/argument built from input is validated, and prefer execFile/spawn with an argument array over exec.
Context: import { spawn, type ChildProcess } from "node:child_process";
Note: [CWE-78] Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection').
(detect-child-process-typescript)
🤖 Prompt for AI Agents