mirror of
https://github.com/samsonjs/vibetunnel.git
synced 2026-06-29 05:39:31 +00:00
Modify Xcode script to be reliable on recompiles
This commit is contained in:
parent
a06b6dae8d
commit
a507376596
2 changed files with 47 additions and 21 deletions
|
|
@ -98,6 +98,12 @@ cd "${WEB_DIR}"
|
||||||
echo "Cleaning build artifacts..."
|
echo "Cleaning build artifacts..."
|
||||||
rm -rf dist public/bundle public/output.css native
|
rm -rf dist public/bundle public/output.css native
|
||||||
|
|
||||||
|
# Clean native modules to ensure fresh build
|
||||||
|
echo "Cleaning native modules for fresh build..."
|
||||||
|
rm -rf node_modules/@serialport
|
||||||
|
rm -rf node_modules/node-pty
|
||||||
|
rm -rf node_modules/authenticate-pam
|
||||||
|
|
||||||
# Install dependencies
|
# Install dependencies
|
||||||
echo "Installing dependencies..."
|
echo "Installing dependencies..."
|
||||||
# For Xcode builds, ensure C++20 standard for native modules
|
# For Xcode builds, ensure C++20 standard for native modules
|
||||||
|
|
|
||||||
|
|
@ -254,10 +254,9 @@ function patchNodePty() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only patch if not already patched
|
// Always re-patch to ensure compatibility with current build
|
||||||
if (alreadyPatched) {
|
if (alreadyPatched) {
|
||||||
console.log('✓ node-pty already patched for SEA, skipping patch step');
|
console.log('⚠️ node-pty appears to be patched, but re-patching to ensure compatibility...');
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('Patching node-pty for SEA build...');
|
console.log('Patching node-pty for SEA build...');
|
||||||
|
|
@ -345,20 +344,42 @@ exports.default = pty;
|
||||||
if (fs.existsSync(unixTerminalFile)) {
|
if (fs.existsSync(unixTerminalFile)) {
|
||||||
let content = fs.readFileSync(unixTerminalFile, 'utf8');
|
let content = fs.readFileSync(unixTerminalFile, 'utf8');
|
||||||
|
|
||||||
// Check if already patched (contains our SEA comment)
|
// Always re-patch to ensure consistency
|
||||||
if (content.includes('// For SEA, use spawn-helper from environment')) {
|
if (content.includes('// For SEA, use spawn-helper from environment')) {
|
||||||
console.log('unixTerminal.js already patched, skipping...');
|
console.log('Re-patching unixTerminal.js for consistency...');
|
||||||
} else {
|
// Find where helperPath is originally declared
|
||||||
// Find where helperPath is defined
|
const helperPathDecl = content.match(/var helperPath[^;]*;/);
|
||||||
const helperPathMatch = content.match(/var helperPath[^;]*;/);
|
if (helperPathDecl) {
|
||||||
if (!helperPathMatch) {
|
// Replace everything from the declaration to the next var/const/let/function
|
||||||
console.log('Warning: Could not find helperPath declaration in unixTerminal.js');
|
const startPos = content.indexOf(helperPathDecl[0]);
|
||||||
} else {
|
const afterDecl = startPos + helperPathDecl[0].length;
|
||||||
// Find the position right after var helperPath;
|
|
||||||
const insertPosition = content.indexOf(helperPathMatch[0]) + helperPathMatch[0].length;
|
|
||||||
|
|
||||||
// Insert our patch
|
// Find the next major declaration or class definition
|
||||||
const helperPathPatch = `
|
const nextDeclMatch = content.substring(afterDecl).match(/^(var|const|let|function|class|\nvar|\nconst|\nlet|\nfunction|\nclass)/m);
|
||||||
|
let endPos;
|
||||||
|
if (nextDeclMatch) {
|
||||||
|
endPos = afterDecl + nextDeclMatch.index;
|
||||||
|
} else {
|
||||||
|
// Fallback: just remove up to DEFAULT_FILE declaration which we know exists
|
||||||
|
const defaultFilePos = content.indexOf('var DEFAULT_FILE');
|
||||||
|
endPos = defaultFilePos > startPos ? defaultFilePos : content.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Restore to just the original declaration
|
||||||
|
content = content.substring(0, afterDecl) + '\n' + content.substring(endPos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find where helperPath is defined
|
||||||
|
const helperPathMatch = content.match(/var helperPath[^;]*;/);
|
||||||
|
if (!helperPathMatch) {
|
||||||
|
console.log('Warning: Could not find helperPath declaration in unixTerminal.js');
|
||||||
|
} else {
|
||||||
|
// Find the position right after var helperPath;
|
||||||
|
const insertPosition = content.indexOf(helperPathMatch[0]) + helperPathMatch[0].length;
|
||||||
|
|
||||||
|
// Insert our patch
|
||||||
|
const helperPathPatch = `
|
||||||
// For SEA, use spawn-helper from environment or next to executable
|
// For SEA, use spawn-helper from environment or next to executable
|
||||||
if (process.env.NODE_PTY_SPAWN_HELPER_PATH) {
|
if (process.env.NODE_PTY_SPAWN_HELPER_PATH) {
|
||||||
helperPath = process.env.NODE_PTY_SPAWN_HELPER_PATH;
|
helperPath = process.env.NODE_PTY_SPAWN_HELPER_PATH;
|
||||||
|
|
@ -377,11 +398,10 @@ if (process.env.NODE_PTY_SPAWN_HELPER_PATH) {
|
||||||
}
|
}
|
||||||
}`;
|
}`;
|
||||||
|
|
||||||
// Insert the patch after the helperPath declaration
|
// Insert the patch after the helperPath declaration
|
||||||
content = content.substring(0, insertPosition) + helperPathPatch + content.substring(insertPosition);
|
content = content.substring(0, insertPosition) + helperPathPatch + content.substring(insertPosition);
|
||||||
|
|
||||||
fs.writeFileSync(unixTerminalFile, content);
|
fs.writeFileSync(unixTerminalFile, content);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue