Add deterministic dev port runner for multi-instance local workflows #20
Mergedjuliusmarmingemerged 1 commit into
main fromcodething/6df7db48merged by juliusmarminge View on GitHub- @@ -0,0 +34,21 @@34+ }35+ return hash >>> 0;36+}37+38+function resolveOffset() {39+ const explicitOffset = process.env.T3CODE_PORT_OFFSET?.trim();40+ if (explicitOffset) {41+ const parsed = parseInteger(explicitOffset, "T3CODE_PORT_OFFSET");42+ if (parsed < 0) {43+ throw new Error(`Invalid T3CODE_PORT_OFFSET: ${explicitOffset}`);44+ }45+ return { offset: parsed, source: `T3CODE_PORT_OFFSET=${explicitOffset}` };46+ }47+48+ const seed = process.env.T3CODE_DEV_INSTANCE?.trim();49+ if (!seed) {50+ return { offset: 0, source: "default ports" };51+ }52+53+ if (/^\d+$/.test(seed)) {54+ return { offset: Number(seed), source: `numeric T3CODE_DEV_INSTANCE=${seed}` };
- @@ -0,0 +47,21 @@47+48+ const seed = process.env.T3CODE_DEV_INSTANCE?.trim();49+ if (!seed) {50+ return { offset: 0, source: "default ports" };51+ }52+53+ if (/^\d+$/.test(seed)) {54+ return { offset: Number(seed), source: `numeric T3CODE_DEV_INSTANCE=${seed}` };55+ }56+57+ const offset = (hashSeed(seed) % MAX_HASH_OFFSET) + 1;58+ return { offset, source: `hashed T3CODE_DEV_INSTANCE=${seed}` };59+}60+61+function main() {62+ const mode = process.argv[2];63+ const isDryRun = process.argv.includes("--dry-run");64+ if (!mode || !(mode in MODE_ARGS)) {65+ const supportedModes = Object.keys(MODE_ARGS).join(", ");66+ throw new Error(`Usage: bun scripts/dev-runner.mjs <mode>. Supported modes: ${supportedModes}`);67+ }
juliusmarminge merged this15380f2
juliusmarminge closed this
Sign in to join this conversation.
Walkthrough#
This change introduces support for running multiple development instances with deterministic port shifting. A new dev-runner script orchestrates Turbo-based development workflows, calculating port offsets from environment variables. Development scripts are updated to delegate to this runner, and documentation is added explaining the feature with example usage.
Changes#
README.mdscripts/dev-runner.mjspackage.json,apps/server/package.jsonturbo.jsonEstimated code review effort#
🎯 3 (Moderate) | ⏱️ ~20 minutes
🚥 Pre-merge checks | ✅ 3 | ❌ 1
❌ Failed checks (1 warning)
✅ Passed checks (3 passed)
main✨ Finishing touches
🧪 Generate unit tests (beta)
Comment `@coderabbitai help` to get the list of available commands and usage tips.