sandboxbox 1.0.1 ā 1.0.2
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/cli.js +40 -17
- package/package.json +1 -1
package/cli.js
CHANGED
@@ -14,7 +14,8 @@ import { readFileSync, existsSync, writeFileSync, mkdirSync } from 'fs';
|
|
14
14
|
import { execSync } from 'child_process';
|
15
15
|
import { fileURLToPath } from 'url';
|
16
16
|
import { dirname, resolve } from 'path';
|
17
|
-
|
17
|
+
|
18
|
+
// We'll import bubblewrap later, only on Linux systems
|
18
19
|
|
19
20
|
const __filename = fileURLToPath(import.meta.url);
|
20
21
|
const __dirname = dirname(__filename);
|
@@ -66,19 +67,26 @@ function showHelp() {
|
|
66
67
|
console.log(color('magenta', 'š 8ms startup ⢠True isolation ⢠Playwright ready'));
|
67
68
|
}
|
68
69
|
|
69
|
-
function checkBubblewrap() {
|
70
|
-
|
71
|
-
|
70
|
+
async function checkBubblewrap() {
|
71
|
+
try {
|
72
|
+
const { bubblewrap } = await import('./lib/bubblewrap.js');
|
72
73
|
|
73
|
-
if (
|
74
|
-
console.log(color('
|
75
|
-
|
76
|
-
|
77
|
-
|
74
|
+
if (bubblewrap.isAvailable()) {
|
75
|
+
console.log(color('green', `ā
Bubblewrap found: ${bubblewrap.getVersion()}`));
|
76
|
+
|
77
|
+
if (!bubblewrap.checkUserNamespaces()) {
|
78
|
+
console.log(color('yellow', 'ā ļø User namespaces not available'));
|
79
|
+
console.log(color('yellow', ' Try: sudo sysctl kernel.unprivileged_userns_clone=1'));
|
80
|
+
console.log(color('yellow', ' Or: echo 1 | sudo tee /proc/sys/kernel/unprivileged_userns_clone'));
|
81
|
+
}
|
78
82
|
|
79
|
-
|
80
|
-
|
81
|
-
|
83
|
+
return true;
|
84
|
+
} else {
|
85
|
+
console.log(color('red', bubblewrap.findBubblewrap().message));
|
86
|
+
return false;
|
87
|
+
}
|
88
|
+
} catch (error) {
|
89
|
+
console.log(color('red', `ā Failed to load bubblewrap manager: ${error.message}`));
|
82
90
|
return false;
|
83
91
|
}
|
84
92
|
}
|
@@ -128,6 +136,21 @@ CMD ["npm", "test"]
|
|
128
136
|
}
|
129
137
|
|
130
138
|
async function main() {
|
139
|
+
// Check platform first
|
140
|
+
if (process.platform !== 'linux') {
|
141
|
+
console.log(color('red', 'ā SandboxBox only works on Linux systems'));
|
142
|
+
console.log(color('yellow', 'š§ Required: Linux with bubblewrap (bwrap)'));
|
143
|
+
console.log('');
|
144
|
+
console.log(color('cyan', 'š” Alternatives for Windows users:'));
|
145
|
+
console.log(' ⢠Use WSL2 (Windows Subsystem for Linux 2)');
|
146
|
+
console.log(' ⢠Use Docker Desktop with Linux containers');
|
147
|
+
console.log(' ⢠Use GitHub Actions (ubuntu-latest runners)');
|
148
|
+
console.log(' ⢠Use a cloud Linux instance (AWS, GCP, Azure)');
|
149
|
+
console.log('');
|
150
|
+
console.log(color('green', 'ā
On Linux/WSL2, simply run: npx sandboxbox --help'));
|
151
|
+
process.exit(1);
|
152
|
+
}
|
153
|
+
|
131
154
|
const args = process.argv.slice(2);
|
132
155
|
|
133
156
|
showBanner();
|
@@ -143,7 +166,7 @@ async function main() {
|
|
143
166
|
switch (command) {
|
144
167
|
case 'setup':
|
145
168
|
console.log(color('blue', 'šļø Setting up Alpine Linux environment...'));
|
146
|
-
if (!checkBubblewrap()) process.exit(1);
|
169
|
+
if (!(await checkBubblewrap())) process.exit(1);
|
147
170
|
runScript('./container.js', ['setup']);
|
148
171
|
break;
|
149
172
|
|
@@ -154,21 +177,21 @@ async function main() {
|
|
154
177
|
process.exit(1);
|
155
178
|
}
|
156
179
|
console.log(color('blue', 'šļø Building container...'));
|
157
|
-
if (!checkBubblewrap()) process.exit(1);
|
180
|
+
if (!(await checkBubblewrap())) process.exit(1);
|
158
181
|
runScript('./container.js', ['build', commandArgs[0]]);
|
159
182
|
break;
|
160
183
|
|
161
184
|
case 'run':
|
162
185
|
const projectDir = commandArgs[0] || '.';
|
163
186
|
console.log(color('blue', 'š Running Playwright tests...'));
|
164
|
-
if (!checkBubblewrap()) process.exit(1);
|
187
|
+
if (!(await checkBubblewrap())) process.exit(1);
|
165
188
|
runScript('./container.js', ['run', projectDir]);
|
166
189
|
break;
|
167
190
|
|
168
191
|
case 'shell':
|
169
192
|
const shellDir = commandArgs[0] || '.';
|
170
193
|
console.log(color('blue', 'š Starting interactive shell...'));
|
171
|
-
if (!checkBubblewrap()) process.exit(1);
|
194
|
+
if (!(await checkBubblewrap())) process.exit(1);
|
172
195
|
runScript('./container.js', ['shell', shellDir]);
|
173
196
|
break;
|
174
197
|
|
@@ -181,7 +204,7 @@ async function main() {
|
|
181
204
|
const sampleDockerfile = createSampleDockerfile(testDir);
|
182
205
|
|
183
206
|
// Check for bubblewrap before proceeding
|
184
|
-
if (!checkBubblewrap()) {
|
207
|
+
if (!(await checkBubblewrap())) {
|
185
208
|
console.log(color('yellow', '\nš Sample Dockerfile created successfully!'));
|
186
209
|
console.log(color('yellow', 'To run tests, install bubblewrap and try again:'));
|
187
210
|
console.log(color('cyan', ` npx sandboxbox build "${sampleDockerfile}"`));
|