-
Notifications
You must be signed in to change notification settings - Fork 60
Expand file tree
/
Copy pathinstall-bridge.js
More file actions
123 lines (112 loc) · 4.59 KB
/
install-bridge.js
File metadata and controls
123 lines (112 loc) · 4.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
// install-bridge.js
// Script to install the After Effects MCP Bridge to the ScriptUI Panels folder
import { execSync } from 'child_process';
import * as fs from 'fs';
import * as path from 'path';
import { fileURLToPath } from 'url';
// ES Modules replacement for __dirname
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
// Detect platform
const isMac = process.platform === 'darwin';
const isWindows = process.platform === 'win32';
// Possible After Effects installation paths (common locations)
const possiblePaths = isMac
? [
'/Applications/Adobe After Effects 2026',
'/Applications/Adobe After Effects 2025',
'/Applications/Adobe After Effects 2024',
'/Applications/Adobe After Effects 2023',
'/Applications/Adobe After Effects 2022',
'/Applications/Adobe After Effects 2021'
]
: [
'C:\\Program Files\\Adobe\\Adobe After Effects 2026',
'C:\\Program Files\\Adobe\\Adobe After Effects 2025',
'C:\\Program Files\\Adobe\\Adobe After Effects 2024',
'C:\\Program Files\\Adobe\\Adobe After Effects 2023',
'C:\\Program Files\\Adobe\\Adobe After Effects 2022',
'C:\\Program Files\\Adobe\\Adobe After Effects 2021'
];
// Find valid After Effects installation
let afterEffectsPath = null;
for (const testPath of possiblePaths) {
if (fs.existsSync(testPath)) {
afterEffectsPath = testPath;
break;
}
}
if (!afterEffectsPath) {
console.error('Error: Could not find After Effects installation.');
console.error('Please manually copy the bridge script to your After Effects ScriptUI Panels folder.');
console.error('Source: build/scripts/mcp-bridge-auto.jsx');
if (isMac) {
console.error('Target: /Applications/Adobe After Effects [VERSION]/Scripts/ScriptUI Panels/');
} else {
console.error('Target: C:\\Program Files\\Adobe\\Adobe After Effects [VERSION]\\Support Files\\Scripts\\ScriptUI Panels\\');
}
process.exit(1);
}
// Define source and destination paths
const sourceScript = path.join(__dirname, 'build', 'scripts', 'mcp-bridge-auto.jsx');
const destinationFolder = isMac
? path.join(afterEffectsPath, 'Scripts', 'ScriptUI Panels')
: path.join(afterEffectsPath, 'Support Files', 'Scripts', 'ScriptUI Panels');
const destinationScript = path.join(destinationFolder, 'mcp-bridge-auto.jsx');
// Ensure source script exists
if (!fs.existsSync(sourceScript)) {
console.error(`Error: Source script not found at ${sourceScript}`);
console.error('Please run "npm run build" first to generate the script.');
process.exit(1);
}
// Create destination folder if it doesn't exist
if (!fs.existsSync(destinationFolder)) {
try {
fs.mkdirSync(destinationFolder, { recursive: true });
} catch (error) {
console.error(`Error creating destination folder: ${error.message}`);
console.error('You may need administrative privileges to install the script.');
process.exit(1);
}
}
// Copy the script
try {
console.log(`Installing bridge script to ${destinationScript}...`);
if (isMac) {
// On Mac, try direct copy first, then sudo if needed
try {
fs.copyFileSync(sourceScript, destinationScript);
} catch {
// If direct copy fails, try with sudo
execSync(`sudo cp "${sourceScript}" "${destinationScript}"`, { stdio: 'inherit' });
}
} else {
// Try to use PowerShell with elevated privileges on Windows
const command = `
Start-Process PowerShell -Verb RunAs -ArgumentList "-Command Copy-Item -Path '${sourceScript.replace(/\\/g, '\\\\')}' -Destination '${destinationScript.replace(/\\/g, '\\\\')}' -Force"
`;
execSync(`powershell -Command "${command}"`, { stdio: 'inherit' });
}
console.log('Bridge script installed successfully!');
console.log('\nImportant next steps:');
console.log('1. Open After Effects');
if (isMac) {
console.log('2. Go to After Effects > Settings > Scripting & Expressions');
} else {
console.log('2. Go to Edit > Preferences > Scripting & Expressions');
}
console.log('3. Enable "Allow Scripts to Write Files and Access Network"');
console.log('4. Restart After Effects');
console.log('5. Open the bridge panel: Window > mcp-bridge-auto.jsx');
} catch (error) {
console.error(`Error installing script: ${error.message}`);
console.error('\nPlease try manual installation:');
console.error(`1. Copy: ${sourceScript}`);
console.error(`2. To: ${destinationScript}`);
if (isMac) {
console.error('3. You may need to run with sudo or copy manually via Finder');
} else {
console.error('3. You may need to run as administrator or use File Explorer with admin rights');
}
process.exit(1);
}