n8n-nodes-sb-render 1.2.0 ā 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/scripts/fix-ffprobe-permissions.js +116 -21
package/package.json
CHANGED
|
@@ -1,19 +1,89 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Post-install script for n8n-nodes-sb-render
|
|
5
|
+
*
|
|
6
|
+
* This script:
|
|
7
|
+
* 1. Tries to install system ffmpeg/ffprobe (Docker/Linux only)
|
|
8
|
+
* 2. Sets execute permissions on npm-installed binaries
|
|
9
|
+
* 3. Provides helpful guidance for manual setup
|
|
6
10
|
*/
|
|
7
11
|
|
|
8
12
|
const { chmodSync, existsSync, statSync } = require('fs');
|
|
13
|
+
const { execSync } = require('child_process');
|
|
9
14
|
const { resolve, join } = require('path');
|
|
10
15
|
const os = require('os');
|
|
11
16
|
|
|
12
17
|
// Detect current platform
|
|
13
18
|
const platform = os.platform();
|
|
14
19
|
const arch = os.arch();
|
|
20
|
+
const isDocker = existsSync('/.dockerenv') || existsSync('/run/.containerenv');
|
|
15
21
|
|
|
16
22
|
console.log(`š Platform detected: ${platform}-${arch}`);
|
|
23
|
+
if (isDocker) {
|
|
24
|
+
console.log('š³ Docker/Container environment detected');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Try to install system ffmpeg (Docker/Linux only)
|
|
29
|
+
* Returns true if successful or already installed
|
|
30
|
+
*/
|
|
31
|
+
function tryInstallSystemFFmpeg() {
|
|
32
|
+
if (platform !== 'linux' || process.getuid?.() !== 0) {
|
|
33
|
+
return false; // Only try on Linux as root
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
try {
|
|
37
|
+
// Check if already installed
|
|
38
|
+
execSync('which ffmpeg', { stdio: 'ignore' });
|
|
39
|
+
console.log('ā
System ffmpeg already installed');
|
|
40
|
+
return true;
|
|
41
|
+
} catch {
|
|
42
|
+
// Not installed, try to install
|
|
43
|
+
console.log('š¦ Attempting to install system ffmpeg...');
|
|
44
|
+
|
|
45
|
+
try {
|
|
46
|
+
// Detect package manager and install
|
|
47
|
+
if (existsSync('/usr/bin/apk')) {
|
|
48
|
+
// Alpine (n8n official Docker image)
|
|
49
|
+
execSync('apk add --no-cache ffmpeg', { stdio: 'inherit' });
|
|
50
|
+
console.log('ā
Installed ffmpeg via apk (Alpine)');
|
|
51
|
+
return true;
|
|
52
|
+
} else if (existsSync('/usr/bin/apt-get')) {
|
|
53
|
+
// Debian/Ubuntu
|
|
54
|
+
execSync('apt-get update && apt-get install -y ffmpeg', { stdio: 'inherit' });
|
|
55
|
+
console.log('ā
Installed ffmpeg via apt-get (Debian/Ubuntu)');
|
|
56
|
+
return true;
|
|
57
|
+
} else if (existsSync('/usr/bin/yum')) {
|
|
58
|
+
// RedHat/CentOS
|
|
59
|
+
execSync('yum install -y ffmpeg', { stdio: 'inherit' });
|
|
60
|
+
console.log('ā
Installed ffmpeg via yum (RedHat/CentOS)');
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
} catch (installError) {
|
|
64
|
+
console.warn('ā ļø Could not auto-install ffmpeg:', installError.message);
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Try to install system ffmpeg in Docker environments
|
|
73
|
+
if (isDocker && platform === 'linux') {
|
|
74
|
+
console.log('\nš Auto-install attempt (Docker environment)...');
|
|
75
|
+
const installed = tryInstallSystemFFmpeg();
|
|
76
|
+
|
|
77
|
+
if (installed) {
|
|
78
|
+
console.log('⨠System ffmpeg is ready! No additional setup needed.');
|
|
79
|
+
console.log(' sb-render will automatically use system binaries.\n');
|
|
80
|
+
} else {
|
|
81
|
+
console.log('ā¹ļø Auto-install not available (requires root or manual setup)');
|
|
82
|
+
console.log(' Falling back to npm packages with permission fix...\n');
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
console.log(`š§ Setting up npm ffmpeg/ffprobe binaries...`);
|
|
17
87
|
|
|
18
88
|
// Platform-specific binary paths
|
|
19
89
|
const getPlatformPath = () => {
|
|
@@ -89,26 +159,51 @@ for (const ffprobePath of possiblePaths) {
|
|
|
89
159
|
}
|
|
90
160
|
|
|
91
161
|
// Summary and recommendations
|
|
92
|
-
console.log('\nš Summary:');
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
162
|
+
console.log('\nš Post-install Summary:');
|
|
163
|
+
|
|
164
|
+
// Check if system ffmpeg is available
|
|
165
|
+
let hasSystemFFmpeg = false;
|
|
166
|
+
try {
|
|
167
|
+
execSync('which ffmpeg', { stdio: 'ignore' });
|
|
168
|
+
hasSystemFFmpeg = true;
|
|
169
|
+
} catch {
|
|
170
|
+
hasSystemFFmpeg = false;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if (hasSystemFFmpeg) {
|
|
174
|
+
console.log('š Setup Complete - Ready to use!');
|
|
175
|
+
console.log(' ā
System ffmpeg/ffprobe detected');
|
|
176
|
+
console.log(' ā
sb-render will use system binaries (best option)');
|
|
177
|
+
console.log(' ā
No additional configuration needed\n');
|
|
99
178
|
} else if (successCount > 0) {
|
|
100
|
-
console.log(
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
179
|
+
console.log('ā
Setup Complete - npm binaries ready');
|
|
180
|
+
console.log(` ā
Fixed permissions on ${successCount} binary(ies)`);
|
|
181
|
+
console.log(' ā ļø Using npm binaries (fallback option)');
|
|
182
|
+
console.log('\nš” For better performance in Docker/n8n:');
|
|
183
|
+
console.log(' Install system ffmpeg: docker exec <container> apk add ffmpeg');
|
|
184
|
+
console.log(' OR: docker exec <container> apt-get install -y ffmpeg\n');
|
|
185
|
+
} else if (successCount === 0 && errorCount === 0) {
|
|
186
|
+
console.warn('ā ļø No ffmpeg binaries found');
|
|
187
|
+
console.warn(' This is normal if optional dependencies failed to install.');
|
|
188
|
+
console.warn('\nš¦ Recommended setup for your environment:');
|
|
189
|
+
|
|
190
|
+
if (isDocker || platform === 'linux') {
|
|
191
|
+
console.warn(' 1. Install system ffmpeg (recommended):');
|
|
192
|
+
console.warn(' ⢠Alpine: apk add ffmpeg');
|
|
193
|
+
console.warn(' ⢠Debian/Ubuntu: apt-get install -y ffmpeg');
|
|
194
|
+
console.warn(' ⢠RedHat/CentOS: yum install -y ffmpeg');
|
|
195
|
+
} else {
|
|
196
|
+
console.warn(' 1. Install system ffmpeg:');
|
|
197
|
+
console.warn(' ⢠macOS: brew install ffmpeg');
|
|
198
|
+
console.warn(' ⢠Windows: choco install ffmpeg');
|
|
107
199
|
}
|
|
200
|
+
console.warn(' 2. OR reinstall with: npm install --include=optional\n');
|
|
108
201
|
} else {
|
|
109
|
-
console.error('ā
|
|
110
|
-
console.error('\nš§ Manual
|
|
111
|
-
console.error(' 1
|
|
112
|
-
console.error(' 2
|
|
113
|
-
console.error(' 3
|
|
202
|
+
console.error('ā Permission fix failed');
|
|
203
|
+
console.error('\nš§ Manual setup required:');
|
|
204
|
+
console.error(' Option 1 (Recommended): Install system ffmpeg');
|
|
205
|
+
console.error(' Option 2: chmod +x node_modules/@ffprobe-installer/*/ffprobe');
|
|
206
|
+
console.error(' Option 3: Use Docker with proper permissions\n');
|
|
114
207
|
}
|
|
208
|
+
|
|
209
|
+
console.log('š Documentation: https://github.com/choisb87/sb-render#prerequisites');
|