sandboxbox 1.0.1 → 1.0.3

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.
Files changed (2) hide show
  1. package/cli.js +61 -17
  2. package/package.json +1 -1
package/cli.js CHANGED
@@ -10,11 +10,20 @@
10
10
  * npx sandboxbox shell <project> # Interactive shell
11
11
  */
12
12
 
13
+ // Debug: Make sure the script starts
14
+ console.log('šŸš€ SandboxBox starting...');
15
+ if (process.env.DEBUG) {
16
+ console.log(`šŸ”§ Debug: Platform: ${process.platform}`);
17
+ console.log(`šŸ”§ Debug: Node.js: ${process.version}`);
18
+ console.log(`šŸ”§ Debug: Args: ${process.argv.slice(2).join(' ')}`);
19
+ }
20
+
13
21
  import { readFileSync, existsSync, writeFileSync, mkdirSync } from 'fs';
14
22
  import { execSync } from 'child_process';
15
23
  import { fileURLToPath } from 'url';
16
24
  import { dirname, resolve } from 'path';
17
- import { bubblewrap } from './lib/bubblewrap.js';
25
+
26
+ // We'll import bubblewrap later, only on Linux systems
18
27
 
19
28
  const __filename = fileURLToPath(import.meta.url);
20
29
  const __dirname = dirname(__filename);
@@ -66,19 +75,26 @@ function showHelp() {
66
75
  console.log(color('magenta', 'šŸš€ 8ms startup • True isolation • Playwright ready'));
67
76
  }
68
77
 
69
- function checkBubblewrap() {
70
- if (bubblewrap.isAvailable()) {
71
- console.log(color('green', `āœ… Bubblewrap found: ${bubblewrap.getVersion()}`));
78
+ async function checkBubblewrap() {
79
+ try {
80
+ const { bubblewrap } = await import('./lib/bubblewrap.js');
72
81
 
73
- if (!bubblewrap.checkUserNamespaces()) {
74
- console.log(color('yellow', 'āš ļø User namespaces not available'));
75
- console.log(color('yellow', ' Try: sudo sysctl kernel.unprivileged_userns_clone=1'));
76
- console.log(color('yellow', ' Or: echo 1 | sudo tee /proc/sys/kernel/unprivileged_userns_clone'));
77
- }
82
+ if (bubblewrap.isAvailable()) {
83
+ console.log(color('green', `āœ… Bubblewrap found: ${bubblewrap.getVersion()}`));
84
+
85
+ if (!bubblewrap.checkUserNamespaces()) {
86
+ console.log(color('yellow', 'āš ļø User namespaces not available'));
87
+ console.log(color('yellow', ' Try: sudo sysctl kernel.unprivileged_userns_clone=1'));
88
+ console.log(color('yellow', ' Or: echo 1 | sudo tee /proc/sys/kernel/unprivileged_userns_clone'));
89
+ }
78
90
 
79
- return true;
80
- } else {
81
- console.log(color('red', bubblewrap.findBubblewrap().message));
91
+ return true;
92
+ } else {
93
+ console.log(color('red', bubblewrap.findBubblewrap().message));
94
+ return false;
95
+ }
96
+ } catch (error) {
97
+ console.log(color('red', `āŒ Failed to load bubblewrap manager: ${error.message}`));
82
98
  return false;
83
99
  }
84
100
  }
@@ -128,6 +144,21 @@ CMD ["npm", "test"]
128
144
  }
129
145
 
130
146
  async function main() {
147
+ // Check platform first
148
+ if (process.platform !== 'linux') {
149
+ console.log(color('red', 'āŒ SandboxBox only works on Linux systems'));
150
+ console.log(color('yellow', '🐧 Required: Linux with bubblewrap (bwrap)'));
151
+ console.log('');
152
+ console.log(color('cyan', 'šŸ’” Alternatives for Windows users:'));
153
+ console.log(' • Use WSL2 (Windows Subsystem for Linux 2)');
154
+ console.log(' • Use Docker Desktop with Linux containers');
155
+ console.log(' • Use GitHub Actions (ubuntu-latest runners)');
156
+ console.log(' • Use a cloud Linux instance (AWS, GCP, Azure)');
157
+ console.log('');
158
+ console.log(color('green', 'āœ… On Linux/WSL2, simply run: npx sandboxbox --help'));
159
+ process.exit(1);
160
+ }
161
+
131
162
  const args = process.argv.slice(2);
132
163
 
133
164
  showBanner();
@@ -143,7 +174,7 @@ async function main() {
143
174
  switch (command) {
144
175
  case 'setup':
145
176
  console.log(color('blue', 'šŸ”ļø Setting up Alpine Linux environment...'));
146
- if (!checkBubblewrap()) process.exit(1);
177
+ if (!(await checkBubblewrap())) process.exit(1);
147
178
  runScript('./container.js', ['setup']);
148
179
  break;
149
180
 
@@ -154,21 +185,21 @@ async function main() {
154
185
  process.exit(1);
155
186
  }
156
187
  console.log(color('blue', 'šŸ—ļø Building container...'));
157
- if (!checkBubblewrap()) process.exit(1);
188
+ if (!(await checkBubblewrap())) process.exit(1);
158
189
  runScript('./container.js', ['build', commandArgs[0]]);
159
190
  break;
160
191
 
161
192
  case 'run':
162
193
  const projectDir = commandArgs[0] || '.';
163
194
  console.log(color('blue', 'šŸš€ Running Playwright tests...'));
164
- if (!checkBubblewrap()) process.exit(1);
195
+ if (!(await checkBubblewrap())) process.exit(1);
165
196
  runScript('./container.js', ['run', projectDir]);
166
197
  break;
167
198
 
168
199
  case 'shell':
169
200
  const shellDir = commandArgs[0] || '.';
170
201
  console.log(color('blue', '🐚 Starting interactive shell...'));
171
- if (!checkBubblewrap()) process.exit(1);
202
+ if (!(await checkBubblewrap())) process.exit(1);
172
203
  runScript('./container.js', ['shell', shellDir]);
173
204
  break;
174
205
 
@@ -181,7 +212,7 @@ async function main() {
181
212
  const sampleDockerfile = createSampleDockerfile(testDir);
182
213
 
183
214
  // Check for bubblewrap before proceeding
184
- if (!checkBubblewrap()) {
215
+ if (!(await checkBubblewrap())) {
185
216
  console.log(color('yellow', '\nšŸ“‹ Sample Dockerfile created successfully!'));
186
217
  console.log(color('yellow', 'To run tests, install bubblewrap and try again:'));
187
218
  console.log(color('cyan', ` npx sandboxbox build "${sampleDockerfile}"`));
@@ -213,7 +244,20 @@ async function main() {
213
244
  // Run if called directly
214
245
  if (import.meta.url === `file://${process.argv[1]}`) {
215
246
  main().catch(error => {
247
+ console.error('āŒ SandboxBox failed to start:');
216
248
  console.error('Error:', error.message);
249
+ console.error('');
250
+ console.error('šŸ’” This might be because:');
251
+ console.error(' • You are not on Linux (SandboxBox requires Linux)');
252
+ console.error(' • Node.js version compatibility issue');
253
+ console.error(' • Missing dependencies during installation');
254
+ console.error('');
255
+ console.error('šŸ“‹ System information:');
256
+ console.error(` Platform: ${process.platform}`);
257
+ console.error(` Node.js: ${process.version}`);
258
+ console.error(` Architecture: ${process.arch}`);
259
+ console.error('');
260
+ console.error('šŸ”§ Try: npx sandboxbox --help');
217
261
  process.exit(1);
218
262
  });
219
263
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sandboxbox",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Zero-privilege container runner with Playwright support",
5
5
  "type": "module",
6
6
  "main": "index.js",