bugproof 0.1.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/CHANGELOG.md +65 -0
- package/README.md +256 -0
- package/assets/icon-16x16.png +0 -0
- package/assets/icon-32x32.png +0 -0
- package/assets/icon-512x512.png +0 -0
- package/dist/capture/engine.d.ts +12 -0
- package/dist/capture/engine.d.ts.map +1 -0
- package/dist/capture/engine.js +129 -0
- package/dist/capture/engine.js.map +1 -0
- package/dist/capture/packager.d.ts +39 -0
- package/dist/capture/packager.d.ts.map +1 -0
- package/dist/capture/packager.js +145 -0
- package/dist/capture/packager.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +538 -0
- package/dist/cli.js.map +1 -0
- package/dist/diff/engine.d.ts +28 -0
- package/dist/diff/engine.d.ts.map +1 -0
- package/dist/diff/engine.js +88 -0
- package/dist/diff/engine.js.map +1 -0
- package/dist/replay/engine.d.ts +41 -0
- package/dist/replay/engine.d.ts.map +1 -0
- package/dist/replay/engine.js +69 -0
- package/dist/replay/engine.js.map +1 -0
- package/dist/replay/sandbox.d.ts +33 -0
- package/dist/replay/sandbox.d.ts.map +1 -0
- package/dist/replay/sandbox.js +167 -0
- package/dist/replay/sandbox.js.map +1 -0
- package/dist/replay/verdict.d.ts +8 -0
- package/dist/replay/verdict.d.ts.map +1 -0
- package/dist/replay/verdict.js +32 -0
- package/dist/replay/verdict.js.map +1 -0
- package/dist/sandbox/bugbox.d.ts +38 -0
- package/dist/sandbox/bugbox.d.ts.map +1 -0
- package/dist/sandbox/bugbox.js +122 -0
- package/dist/sandbox/bugbox.js.map +1 -0
- package/dist/sandbox/capabilities.d.ts +33 -0
- package/dist/sandbox/capabilities.d.ts.map +1 -0
- package/dist/sandbox/capabilities.js +53 -0
- package/dist/sandbox/capabilities.js.map +1 -0
- package/dist/sandbox/filesystem.d.ts +50 -0
- package/dist/sandbox/filesystem.d.ts.map +1 -0
- package/dist/sandbox/filesystem.js +134 -0
- package/dist/sandbox/filesystem.js.map +1 -0
- package/dist/sandbox/network.d.ts +68 -0
- package/dist/sandbox/network.d.ts.map +1 -0
- package/dist/sandbox/network.js +136 -0
- package/dist/sandbox/network.js.map +1 -0
- package/dist/sandbox/process.d.ts +17 -0
- package/dist/sandbox/process.d.ts.map +1 -0
- package/dist/sandbox/process.js +30 -0
- package/dist/sandbox/process.js.map +1 -0
- package/dist/sandbox/resources.d.ts +21 -0
- package/dist/sandbox/resources.d.ts.map +1 -0
- package/dist/sandbox/resources.js +60 -0
- package/dist/sandbox/resources.js.map +1 -0
- package/dist/types/artifact.d.ts +57 -0
- package/dist/types/artifact.d.ts.map +1 -0
- package/dist/types/artifact.js +2 -0
- package/dist/types/artifact.js.map +1 -0
- package/dist/types/failure.d.ts +12 -0
- package/dist/types/failure.d.ts.map +1 -0
- package/dist/types/failure.js +2 -0
- package/dist/types/failure.js.map +1 -0
- package/dist/utils/archive.d.ts +13 -0
- package/dist/utils/archive.d.ts.map +1 -0
- package/dist/utils/archive.js +39 -0
- package/dist/utils/archive.js.map +1 -0
- package/dist/utils/associations.d.ts +10 -0
- package/dist/utils/associations.d.ts.map +1 -0
- package/dist/utils/associations.js +46 -0
- package/dist/utils/associations.js.map +1 -0
- package/dist/utils/exclude.d.ts +12 -0
- package/dist/utils/exclude.d.ts.map +1 -0
- package/dist/utils/exclude.js +42 -0
- package/dist/utils/exclude.js.map +1 -0
- package/dist/utils/fingerprint.d.ts +16 -0
- package/dist/utils/fingerprint.d.ts.map +1 -0
- package/dist/utils/fingerprint.js +72 -0
- package/dist/utils/fingerprint.js.map +1 -0
- package/dist/utils/git.d.ts +13 -0
- package/dist/utils/git.d.ts.map +1 -0
- package/dist/utils/git.js +41 -0
- package/dist/utils/git.js.map +1 -0
- package/dist/utils/json-output.d.ts +36 -0
- package/dist/utils/json-output.d.ts.map +1 -0
- package/dist/utils/json-output.js +49 -0
- package/dist/utils/json-output.js.map +1 -0
- package/dist/utils/paths.d.ts +19 -0
- package/dist/utils/paths.d.ts.map +1 -0
- package/dist/utils/paths.js +43 -0
- package/dist/utils/paths.js.map +1 -0
- package/dist/utils/secrets.d.ts +13 -0
- package/dist/utils/secrets.d.ts.map +1 -0
- package/dist/utils/secrets.js +52 -0
- package/dist/utils/secrets.js.map +1 -0
- package/dist/utils/security.d.ts +27 -0
- package/dist/utils/security.d.ts.map +1 -0
- package/dist/utils/security.js +75 -0
- package/dist/utils/security.js.map +1 -0
- package/dist/utils/ui.d.ts +31 -0
- package/dist/utils/ui.d.ts.map +1 -0
- package/dist/utils/ui.js +54 -0
- package/dist/utils/ui.js.map +1 -0
- package/package.json +80 -0
- package/scripts/bugproof-file-association-linux.sh +80 -0
- package/scripts/bugproof-file-association-macos.sh +48 -0
- package/scripts/bugproof-file-association-windows.reg +44 -0
- package/scripts/postinstall.cjs +215 -0
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const os = require('os');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const { spawnSync } = require('child_process');
|
|
6
|
+
|
|
7
|
+
const rootDir = path.resolve(__dirname, '..');
|
|
8
|
+
const cliPath = path.join(rootDir, 'dist', 'cli.js');
|
|
9
|
+
const iconPath = path.join(rootDir, 'assets', 'icon-512x512.png');
|
|
10
|
+
|
|
11
|
+
function log(msg) {
|
|
12
|
+
console.log(`[bugproof postinstall] ${msg}`);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function isCommandAvailable(command) {
|
|
16
|
+
const result = spawnSync(command, ['--version'], { encoding: 'utf8', timeout: 5000 });
|
|
17
|
+
return result.status === 0;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function runCommand(command, args, timeout = 5000) {
|
|
21
|
+
return spawnSync(command, args, {
|
|
22
|
+
encoding: 'utf8',
|
|
23
|
+
timeout,
|
|
24
|
+
stdio: 'ignore',
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function checkNodeVersion() {
|
|
29
|
+
const major = Number(process.versions.node.split('.')[0]);
|
|
30
|
+
if (major < 18) {
|
|
31
|
+
log(`WARNING: Node.js ${process.version} detected. BugProof requires Node.js >= 18.`);
|
|
32
|
+
} else {
|
|
33
|
+
log(`Node.js requirement satisfied (${process.version}).`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function checkGit() {
|
|
38
|
+
if (isCommandAvailable('git')) {
|
|
39
|
+
log('Git requirement satisfied.');
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
log('WARNING: Git is not installed or not in PATH. Capture/replay workflows need Git.');
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function checkOptionalTooling() {
|
|
46
|
+
const optional = ['python', 'python3', 'java', 'gcc', 'g++', 'go', 'rustc'];
|
|
47
|
+
const available = optional.filter((tool) => isCommandAvailable(tool));
|
|
48
|
+
if (available.length > 0) {
|
|
49
|
+
log(`Optional language toolchains found: ${available.join(', ')}`);
|
|
50
|
+
} else {
|
|
51
|
+
log('Optional language toolchains not found. This is fine unless your bug command needs them.');
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function ensureParentDir(filePath) {
|
|
56
|
+
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function registerWindowsAssociation() {
|
|
60
|
+
if (process.platform !== 'win32') {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const reg = (args) => runCommand('reg', args, 5000);
|
|
65
|
+
|
|
66
|
+
const openCommand = `\"${process.execPath}\" \"${cliPath}\" replay \"%1\"`;
|
|
67
|
+
|
|
68
|
+
const outcomes = [];
|
|
69
|
+
|
|
70
|
+
outcomes.push(reg(['add', 'HKCU\\Software\\Classes\\.bug', '/ve', '/d', 'BugProof.Artifact', '/f']));
|
|
71
|
+
outcomes.push(reg([
|
|
72
|
+
'add',
|
|
73
|
+
'HKCU\\Software\\Classes\\BugProof.Artifact',
|
|
74
|
+
'/ve',
|
|
75
|
+
'/d',
|
|
76
|
+
'BugProof Artifact',
|
|
77
|
+
'/f',
|
|
78
|
+
]));
|
|
79
|
+
|
|
80
|
+
if (fs.existsSync(iconPath)) {
|
|
81
|
+
outcomes.push(reg([
|
|
82
|
+
'add',
|
|
83
|
+
'HKCU\\Software\\Classes\\BugProof.Artifact\\DefaultIcon',
|
|
84
|
+
'/ve',
|
|
85
|
+
'/d',
|
|
86
|
+
iconPath,
|
|
87
|
+
'/f',
|
|
88
|
+
]));
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
outcomes.push(reg([
|
|
92
|
+
'add',
|
|
93
|
+
'HKCU\\Software\\Classes\\BugProof.Artifact\\shell\\open\\command',
|
|
94
|
+
'/ve',
|
|
95
|
+
'/d',
|
|
96
|
+
openCommand,
|
|
97
|
+
'/f',
|
|
98
|
+
]));
|
|
99
|
+
|
|
100
|
+
const failed = outcomes.some((result) => result.status !== 0);
|
|
101
|
+
if (failed) {
|
|
102
|
+
log('WARNING: Windows .bug association setup partially failed. Run scripts/bugproof-file-association-windows.reg manually.');
|
|
103
|
+
} else {
|
|
104
|
+
log('Windows .bug file association registered (HKCU).');
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function quoteDesktopExecArg(value) {
|
|
109
|
+
return `"${value.replace(/(["\\`$])/g, '\\$1')}"`;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function registerLinuxAssociation() {
|
|
113
|
+
if (process.platform !== 'linux') {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const home = os.homedir();
|
|
118
|
+
const mimeDir = path.join(home, '.local', 'share', 'mime');
|
|
119
|
+
const mimePackagesDir = path.join(mimeDir, 'packages');
|
|
120
|
+
const appsDir = path.join(home, '.local', 'share', 'applications');
|
|
121
|
+
const iconsDir = path.join(home, '.local', 'share', 'icons', 'hicolor', '512x512', 'mimetypes');
|
|
122
|
+
const configDir = path.join(home, '.config');
|
|
123
|
+
|
|
124
|
+
const mimeXmlPath = path.join(mimePackagesDir, 'bugproof.xml');
|
|
125
|
+
const desktopPath = path.join(appsDir, 'bugproof.desktop');
|
|
126
|
+
const mimeAppsPath = path.join(configDir, 'mimeapps.list');
|
|
127
|
+
const iconTargetPath = path.join(iconsDir, 'application-x-bugproof.png');
|
|
128
|
+
|
|
129
|
+
const mimeXml = `<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<mime-info xmlns=\"http://www.freedesktop.org/standards/shared-mime-info\">\n <mime-type type=\"application/x-bugproof\">\n <comment>BugProof Artifact</comment>\n <glob pattern=\"*.bug\"/>\n </mime-type>\n</mime-info>\n`;
|
|
130
|
+
|
|
131
|
+
const desktopContent = `[Desktop Entry]\nName=BugProof Replay\nComment=Replay BugProof artifact\nExec=${quoteDesktopExecArg(process.execPath)} ${quoteDesktopExecArg(cliPath)} replay %f\nTerminal=true\nType=Application\nMimeType=application/x-bugproof;\nIcon=application-x-bugproof\nCategories=Development;Utility;\nNoDisplay=true\n`;
|
|
132
|
+
|
|
133
|
+
ensureParentDir(mimeXmlPath);
|
|
134
|
+
ensureParentDir(desktopPath);
|
|
135
|
+
ensureParentDir(iconTargetPath);
|
|
136
|
+
ensureParentDir(mimeAppsPath);
|
|
137
|
+
|
|
138
|
+
fs.writeFileSync(mimeXmlPath, mimeXml, 'utf8');
|
|
139
|
+
fs.writeFileSync(desktopPath, desktopContent, 'utf8');
|
|
140
|
+
fs.chmodSync(desktopPath, 0o755);
|
|
141
|
+
|
|
142
|
+
if (fs.existsSync(iconPath)) {
|
|
143
|
+
fs.copyFileSync(iconPath, iconTargetPath);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const mimeAppsHeader = '[Default Applications]\n';
|
|
147
|
+
const mimeAssocLine = 'application/x-bugproof=bugproof.desktop\n';
|
|
148
|
+
if (!fs.existsSync(mimeAppsPath)) {
|
|
149
|
+
fs.writeFileSync(mimeAppsPath, `${mimeAppsHeader}${mimeAssocLine}`, 'utf8');
|
|
150
|
+
} else {
|
|
151
|
+
const existing = fs.readFileSync(mimeAppsPath, 'utf8');
|
|
152
|
+
if (!existing.includes(mimeAssocLine.trim())) {
|
|
153
|
+
if (!existing.includes('[Default Applications]')) {
|
|
154
|
+
fs.appendFileSync(mimeAppsPath, `\n${mimeAppsHeader}${mimeAssocLine}`, 'utf8');
|
|
155
|
+
} else {
|
|
156
|
+
fs.appendFileSync(mimeAppsPath, mimeAssocLine, 'utf8');
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if (isCommandAvailable('update-mime-database')) {
|
|
162
|
+
runCommand('update-mime-database', [mimeDir], 10000);
|
|
163
|
+
}
|
|
164
|
+
if (isCommandAvailable('update-desktop-database')) {
|
|
165
|
+
runCommand('update-desktop-database', [appsDir], 10000);
|
|
166
|
+
}
|
|
167
|
+
if (isCommandAvailable('xdg-mime')) {
|
|
168
|
+
runCommand('xdg-mime', ['default', 'bugproof.desktop', 'application/x-bugproof'], 10000);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
log('Linux .bug file association registered (user scope).');
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function registerMacAssociation() {
|
|
175
|
+
if (process.platform !== 'darwin') {
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const scriptPath = path.join(rootDir, 'scripts', 'bugproof-file-association-macos.sh');
|
|
180
|
+
if (!fs.existsSync(scriptPath)) {
|
|
181
|
+
log('macOS association script not found. Skipping file association setup.');
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
const result = spawnSync('bash', [scriptPath], { encoding: 'utf8', timeout: 15000 });
|
|
186
|
+
if (result.status === 0) {
|
|
187
|
+
log('macOS .bug file association registration attempted.');
|
|
188
|
+
} else {
|
|
189
|
+
log('WARNING: macOS file association setup failed. Run scripts/bugproof-file-association-macos.sh manually.');
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function main() {
|
|
194
|
+
try {
|
|
195
|
+
log('Starting install checks...');
|
|
196
|
+
checkNodeVersion();
|
|
197
|
+
checkGit();
|
|
198
|
+
checkOptionalTooling();
|
|
199
|
+
|
|
200
|
+
if (!fs.existsSync(cliPath)) {
|
|
201
|
+
log('WARNING: dist/cli.js not found. Build artifact missing; file association registration skipped.');
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
registerWindowsAssociation();
|
|
206
|
+
registerLinuxAssociation();
|
|
207
|
+
registerMacAssociation();
|
|
208
|
+
|
|
209
|
+
log('Install checks complete.');
|
|
210
|
+
} catch (err) {
|
|
211
|
+
log(`WARNING: postinstall completed with non-fatal error: ${err instanceof Error ? err.message : String(err)}`);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
main();
|