-
Notifications
You must be signed in to change notification settings - Fork 0
fix scaffolding #12
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
fix scaffolding #12
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1727,6 +1727,8 @@ export async function syncManagedDriverDependencies( | |
| const cachePackageInstalled = typeof dependencies['@holo-js/cache'] !== 'undefined' | ||
| || typeof devDependencies['@holo-js/cache'] !== 'undefined' | ||
|
|
||
| requiredPackages.add('@holo-js/core') | ||
|
|
||
| for (const connection of Object.values(loaded.database.connections)) { | ||
| const inferredDriver = inferConnectionDriver(connection) | ||
| if (inferredDriver) { | ||
|
|
@@ -1849,6 +1851,7 @@ export async function syncManagedDriverDependencies( | |
| let changed = false | ||
| const nextVersion = `^${HOLO_PACKAGE_VERSION}` | ||
| const removableManagedPackages = new Set<string>([ | ||
| '@holo-js/core', | ||
| ...Object.values(DB_DRIVER_PACKAGE_NAMES), | ||
| '@holo-js/auth', | ||
| '@holo-js/auth-clerk', | ||
|
|
@@ -3352,7 +3355,7 @@ function renderFrameworkRunner(options: Pick<ProjectScaffoldOptions, 'framework' | |
| ' ])', | ||
| ' : new Set()', | ||
| '', | ||
| 'function pipeOutput(stream, target) {', | ||
| 'function pipeOutput(stream, target, onLine) {', | ||
| ' if (!stream) {', | ||
| ' return', | ||
| ' }', | ||
|
|
@@ -3363,36 +3366,87 @@ function renderFrameworkRunner(options: Pick<ProjectScaffoldOptions, 'framework' | |
| ' const lines = buffered.split(/\\r?\\n/)', | ||
| ' buffered = lines.pop() ?? \'\'', | ||
| ' for (const line of lines) {', | ||
| ' onLine?.(line)', | ||
| ' if (!suppressedOutput.has(line)) {', | ||
| ' target.write(`${line}\\n`)', | ||
| ' }', | ||
| ' }', | ||
| ' })', | ||
| '', | ||
| ' stream.on(\'end\', () => {', | ||
| ' if (buffered.length > 0) {', | ||
| ' onLine?.(buffered)', | ||
| ' }', | ||
| ' if (buffered.length > 0 && !suppressedOutput.has(buffered)) {', | ||
| ' target.write(buffered)', | ||
| ' }', | ||
| ' })', | ||
| '}', | ||
| '', | ||
| 'function extractNextConflictPid(lines) {', | ||
| ' if (framework !== \'next\' || mode !== \'dev\') {', | ||
| ' return undefined', | ||
| ' }', | ||
| '', | ||
| ' if (!lines.some(line => line.includes(\'Another next dev server is already running.\'))) {', | ||
| ' return undefined', | ||
| ' }', | ||
| '', | ||
| ' for (const line of lines) {', | ||
| ' const match = line.match(/^- PID:\\s+(\\d+)\\s*$/)', | ||
| ' if (match) {', | ||
| ' return Number.parseInt(match[1], 10)', | ||
| ' }', | ||
| ' }', | ||
| '', | ||
| ' return undefined', | ||
| '}', | ||
| '', | ||
| 'async function waitForProcessExit(pid, timeoutMs = 5000) {', | ||
| ' const deadline = Date.now() + timeoutMs', | ||
| ' while (Date.now() < deadline) {', | ||
| ' try {', | ||
| ' process.kill(pid, 0)', | ||
| ' } catch (error) {', | ||
| ' if (error && typeof error === \'object\' && \'code\' in error && error.code === \'ESRCH\') {', | ||
| ' return true', | ||
| ' }', | ||
| ' throw error', | ||
| ' }', | ||
| '', | ||
| ' await new Promise(resolve => setTimeout(resolve, 100))', | ||
| ' }', | ||
| '', | ||
| ' return false', | ||
| '}', | ||
| '', | ||
| 'async function stopStaleNextDevServer(pid) {', | ||
| ' if (!Number.isInteger(pid) || pid <= 0 || pid === process.pid) {', | ||
| ' return false', | ||
| ' }', | ||
| '', | ||
| ' try {', | ||
| ' process.kill(pid, \'SIGTERM\')', | ||
| ' } catch (error) {', | ||
| ' if (error && typeof error === \'object\' && \'code\' in error && error.code === \'ESRCH\') {', | ||
| ' return true', | ||
| ' }', | ||
| ' return false', | ||
| ' }', | ||
| '', | ||
| ' return waitForProcessExit(pid)', | ||
|
Comment on lines
+3374
to
+3388
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. Don't treat any live Next PID as stale.
🤖 Prompt for AI Agents |
||
| '}', | ||
| '', | ||
| 'if (!existsSync(binaryPath)) {', | ||
| ' console.error(`[holo] Missing framework binary "${commandName}" for "${framework}". Run your package manager install first.`)', | ||
| ' process.exit(1)', | ||
| '}', | ||
| '', | ||
| 'const child = spawn(binaryPath, commandArgs, {', | ||
| ' cwd: projectRoot,', | ||
| ' env: process.env,', | ||
| ' stdio: [\'inherit\', \'pipe\', \'pipe\'],', | ||
| '})', | ||
| 'let child = null', | ||
| 'let forwardedSignal = null', | ||
| '', | ||
| 'pipeOutput(child.stdout, process.stdout)', | ||
| 'pipeOutput(child.stderr, process.stderr)', | ||
| '', | ||
| 'function forwardSignal(signal) {', | ||
| ' if (forwardedSignal || child.exitCode !== null) {', | ||
| ' if (forwardedSignal || !child || child.exitCode !== null) {', | ||
| ' return', | ||
| ' }', | ||
| '', | ||
|
|
@@ -3408,15 +3462,51 @@ function renderFrameworkRunner(options: Pick<ProjectScaffoldOptions, 'framework' | |
| ' forwardSignal(\'SIGTERM\')', | ||
| '})', | ||
| '', | ||
| 'child.on(\'error\', (error) => {', | ||
| 'async function run() {', | ||
| ' let restartedAfterConflict = false', | ||
| '', | ||
| ' while (true) {', | ||
| ' const stderrLines = []', | ||
| ' child = spawn(binaryPath, commandArgs, {', | ||
| ' cwd: projectRoot,', | ||
| ' env: process.env,', | ||
| ' stdio: [\'inherit\', \'pipe\', \'pipe\'],', | ||
| ' })', | ||
| ' forwardedSignal = null', | ||
| '', | ||
| ' pipeOutput(child.stdout, process.stdout)', | ||
| ' pipeOutput(child.stderr, process.stderr, line => {', | ||
| ' stderrLines.push(line)', | ||
| ' })', | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| '', | ||
| ' const code = await new Promise((resolve, reject) => {', | ||
| ' child.on(\'error\', reject)', | ||
| ' child.on(\'close\', resolve)', | ||
| ' })', | ||
| '', | ||
| ' if (code === 0) {', | ||
| ' process.exit(0)', | ||
| ' }', | ||
| '', | ||
| ' const conflictPid = extractNextConflictPid(stderrLines)', | ||
| ' if (!restartedAfterConflict && typeof conflictPid === \'number\') {', | ||
| ' const stopped = await stopStaleNextDevServer(conflictPid)', | ||
| ' if (stopped) {', | ||
| ' restartedAfterConflict = true', | ||
| ' console.error(`[holo] Stopped stale Next dev server ${conflictPid}. Restarting dev server.`)', | ||
| ' continue', | ||
| ' }', | ||
| ' }', | ||
| '', | ||
| ' process.exit(code ?? 1)', | ||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||
| ' }', | ||
| '}', | ||
| '', | ||
| 'run().catch((error) => {', | ||
| ' console.error(error instanceof Error ? error.message : String(error))', | ||
| ' process.exit(1)', | ||
| '})', | ||
| '', | ||
| 'child.on(\'close\', (code) => {', | ||
| ' process.exit(code ?? 1)', | ||
| '})', | ||
| '', | ||
| ].join('\n') | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.