n8n-nodes-sb-render 1.3.24 → 1.3.26

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.
@@ -1,209 +1,209 @@
1
- #!/usr/bin/env node
2
-
3
- /**
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
10
- */
11
-
12
- const { chmodSync, existsSync, statSync } = require('fs');
13
- const { execSync } = require('child_process');
14
- const { resolve, join } = require('path');
15
- const os = require('os');
16
-
17
- // Detect current platform
18
- const platform = os.platform();
19
- const arch = os.arch();
20
- const isDocker = existsSync('/.dockerenv') || existsSync('/run/.containerenv');
21
-
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...`);
87
-
88
- // Platform-specific binary paths
89
- const getPlatformPath = () => {
90
- const basePath = resolve(__dirname, '../node_modules/@ffprobe-installer');
91
-
92
- if (platform === 'win32') {
93
- return join(basePath, 'win32-x64/ffprobe.exe');
94
- } else if (platform === 'darwin') {
95
- if (arch === 'arm64') {
96
- return join(basePath, 'darwin-arm64/ffprobe');
97
- }
98
- return join(basePath, 'darwin-x64/ffprobe');
99
- } else if (platform === 'linux') {
100
- if (arch === 'arm64') {
101
- return join(basePath, 'linux-arm64/ffprobe');
102
- }
103
- return join(basePath, 'linux-x64/ffprobe');
104
- }
105
-
106
- return null;
107
- };
108
-
109
- // Try multiple possible paths where ffprobe might be installed
110
- const possiblePaths = [
111
- // Platform-specific path (primary)
112
- getPlatformPath(),
113
- // Fallback paths for different installations
114
- resolve(__dirname, '../node_modules/@ffprobe-installer/linux-x64/ffprobe'),
115
- resolve(__dirname, '../node_modules/@ffprobe-installer/darwin-x64/ffprobe'),
116
- resolve(__dirname, '../node_modules/@ffprobe-installer/darwin-arm64/ffprobe'),
117
- resolve(__dirname, '../node_modules/@ffprobe-installer/win32-x64/ffprobe.exe'),
118
- // Nested dependency paths
119
- resolve(__dirname, '../node_modules/@ffprobe-installer/ffprobe/node_modules/@ffprobe-installer/linux-x64/ffprobe'),
120
- ].filter(Boolean); // Remove null values
121
-
122
- let successCount = 0;
123
- let errorCount = 0;
124
-
125
- console.log('šŸ”§ Fixing ffprobe permissions...');
126
-
127
- for (const ffprobePath of possiblePaths) {
128
- if (existsSync(ffprobePath)) {
129
- try {
130
- const stats = statSync(ffprobePath);
131
- const currentMode = stats.mode;
132
-
133
- console.log(` šŸ“ Found: ${ffprobePath}`);
134
- console.log(` šŸ“Š Current mode: ${(currentMode & parseInt('777', 8)).toString(8)}`);
135
-
136
- // Set execute permissions (755 = rwxr-xr-x)
137
- if (platform !== 'win32') {
138
- chmodSync(ffprobePath, 0o755);
139
- console.log(` āœ… Set permissions to 755: ${ffprobePath}`);
140
- } else {
141
- console.log(` ā„¹ļø Windows detected, permissions already OK: ${ffprobePath}`);
142
- }
143
- successCount++;
144
- } catch (error) {
145
- console.warn(` āš ļø Could not set permissions for ${ffprobePath}:`, error.message);
146
-
147
- // Check if it's a permission error we can diagnose
148
- if (error.code === 'EACCES') {
149
- console.warn(' šŸ’” Suggestion: Try running as root/administrator or in Docker with proper permissions');
150
- } else if (error.code === 'ENOENT') {
151
- console.warn(' šŸ’” Suggestion: File may have been moved or deleted during installation');
152
- }
153
-
154
- errorCount++;
155
- }
156
- } else {
157
- console.log(` āŒ Not found: ${ffprobePath}`);
158
- }
159
- }
160
-
161
- // Summary and recommendations
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');
178
- } else if (successCount > 0) {
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');
199
- }
200
- console.warn(' 2. OR reinstall with: npm install --include=optional\n');
201
- } else {
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');
207
- }
208
-
209
- console.log('šŸ“š Documentation: https://github.com/choisb87/sb-render#prerequisites');
1
+ #!/usr/bin/env node
2
+
3
+ /**
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
10
+ */
11
+
12
+ const { chmodSync, existsSync, statSync } = require('fs');
13
+ const { execSync } = require('child_process');
14
+ const { resolve, join } = require('path');
15
+ const os = require('os');
16
+
17
+ // Detect current platform
18
+ const platform = os.platform();
19
+ const arch = os.arch();
20
+ const isDocker = existsSync('/.dockerenv') || existsSync('/run/.containerenv');
21
+
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...`);
87
+
88
+ // Platform-specific binary paths
89
+ const getPlatformPath = () => {
90
+ const basePath = resolve(__dirname, '../node_modules/@ffprobe-installer');
91
+
92
+ if (platform === 'win32') {
93
+ return join(basePath, 'win32-x64/ffprobe.exe');
94
+ } else if (platform === 'darwin') {
95
+ if (arch === 'arm64') {
96
+ return join(basePath, 'darwin-arm64/ffprobe');
97
+ }
98
+ return join(basePath, 'darwin-x64/ffprobe');
99
+ } else if (platform === 'linux') {
100
+ if (arch === 'arm64') {
101
+ return join(basePath, 'linux-arm64/ffprobe');
102
+ }
103
+ return join(basePath, 'linux-x64/ffprobe');
104
+ }
105
+
106
+ return null;
107
+ };
108
+
109
+ // Try multiple possible paths where ffprobe might be installed
110
+ const possiblePaths = [
111
+ // Platform-specific path (primary)
112
+ getPlatformPath(),
113
+ // Fallback paths for different installations
114
+ resolve(__dirname, '../node_modules/@ffprobe-installer/linux-x64/ffprobe'),
115
+ resolve(__dirname, '../node_modules/@ffprobe-installer/darwin-x64/ffprobe'),
116
+ resolve(__dirname, '../node_modules/@ffprobe-installer/darwin-arm64/ffprobe'),
117
+ resolve(__dirname, '../node_modules/@ffprobe-installer/win32-x64/ffprobe.exe'),
118
+ // Nested dependency paths
119
+ resolve(__dirname, '../node_modules/@ffprobe-installer/ffprobe/node_modules/@ffprobe-installer/linux-x64/ffprobe'),
120
+ ].filter(Boolean); // Remove null values
121
+
122
+ let successCount = 0;
123
+ let errorCount = 0;
124
+
125
+ console.log('šŸ”§ Fixing ffprobe permissions...');
126
+
127
+ for (const ffprobePath of possiblePaths) {
128
+ if (existsSync(ffprobePath)) {
129
+ try {
130
+ const stats = statSync(ffprobePath);
131
+ const currentMode = stats.mode;
132
+
133
+ console.log(` šŸ“ Found: ${ffprobePath}`);
134
+ console.log(` šŸ“Š Current mode: ${(currentMode & parseInt('777', 8)).toString(8)}`);
135
+
136
+ // Set execute permissions (755 = rwxr-xr-x)
137
+ if (platform !== 'win32') {
138
+ chmodSync(ffprobePath, 0o755);
139
+ console.log(` āœ… Set permissions to 755: ${ffprobePath}`);
140
+ } else {
141
+ console.log(` ā„¹ļø Windows detected, permissions already OK: ${ffprobePath}`);
142
+ }
143
+ successCount++;
144
+ } catch (error) {
145
+ console.warn(` āš ļø Could not set permissions for ${ffprobePath}:`, error.message);
146
+
147
+ // Check if it's a permission error we can diagnose
148
+ if (error.code === 'EACCES') {
149
+ console.warn(' šŸ’” Suggestion: Try running as root/administrator or in Docker with proper permissions');
150
+ } else if (error.code === 'ENOENT') {
151
+ console.warn(' šŸ’” Suggestion: File may have been moved or deleted during installation');
152
+ }
153
+
154
+ errorCount++;
155
+ }
156
+ } else {
157
+ console.log(` āŒ Not found: ${ffprobePath}`);
158
+ }
159
+ }
160
+
161
+ // Summary and recommendations
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');
178
+ } else if (successCount > 0) {
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');
199
+ }
200
+ console.warn(' 2. OR reinstall with: npm install --include=optional\n');
201
+ } else {
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');
207
+ }
208
+
209
+ console.log('šŸ“š Documentation: https://github.com/choisb87/sb-render#prerequisites');