@spotlightjs/spotlight 2.6.3 → 2.8.0
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/bin/instrument.js +38 -0
- package/bin/run.js +95 -66
- package/dist/overlay/assets/main.js +124 -99
- package/dist/spotlight.cjs +44 -9
- package/package.json +6 -4
- package/bin/build.js +0 -144
- package/bin/entitlements.plist +0 -19
- package/dist/sea-config.json +0 -1
- package/dist/spotlight-darwin-arm64 +0 -0
- package/dist/spotlight-darwin-x64 +0 -0
- package/dist/spotlight-linux-arm64 +0 -0
- package/dist/spotlight-linux-x64 +0 -0
- package/dist/spotlight-win-x64.exe +0 -0
- package/dist/spotlight.blob +0 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { init } from '@sentry/node';
|
|
2
|
+
|
|
3
|
+
init({
|
|
4
|
+
dsn: 'https://51bcd92dba1128934afd1c5726c84442@o1.ingest.us.sentry.io/4508404727283713',
|
|
5
|
+
environment: process.env.NODE_ENV || 'development',
|
|
6
|
+
release: process.env.npm_package_version,
|
|
7
|
+
debug: Boolean(process.env.SENTRY_DEBUG),
|
|
8
|
+
|
|
9
|
+
tracesSampleRate: 1,
|
|
10
|
+
|
|
11
|
+
beforeSendTransaction: event => {
|
|
12
|
+
event.server_name = undefined; // Server name might contain PII
|
|
13
|
+
return event;
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
beforeSend: event => {
|
|
17
|
+
const exceptions = event.exception?.values;
|
|
18
|
+
if (!exceptions) {
|
|
19
|
+
return event;
|
|
20
|
+
}
|
|
21
|
+
for (const exception of exceptions) {
|
|
22
|
+
if (!exception.stacktrace) {
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
for (const frame of exception.stacktrace.frames) {
|
|
27
|
+
if (!frame.filename) {
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
frame.filename = frame.filename?.replace(process.env.HOME, '~');
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
event.server_name = undefined; // Server name might contain PII
|
|
36
|
+
return event;
|
|
37
|
+
},
|
|
38
|
+
});
|
package/bin/run.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { setContext, startSpan } from '@sentry/node';
|
|
2
3
|
import { setupSidecar } from '@spotlightjs/sidecar';
|
|
3
|
-
import { inflateRawSync } from 'node:zlib';
|
|
4
4
|
import { readFileSync } from 'node:fs';
|
|
5
|
+
import Module from 'node:module';
|
|
5
6
|
import { join } from 'node:path';
|
|
6
7
|
import { fileURLToPath } from 'node:url';
|
|
7
|
-
import
|
|
8
|
+
import { inflateRawSync } from 'node:zlib';
|
|
9
|
+
import './instrument.js';
|
|
8
10
|
const require = Module.createRequire(import.meta.url);
|
|
9
11
|
let sea = null;
|
|
10
12
|
try {
|
|
@@ -15,75 +17,102 @@ try {
|
|
|
15
17
|
sea = { isSea: () => false };
|
|
16
18
|
}
|
|
17
19
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
:
|
|
21
|
-
|
|
20
|
+
setContext('CLI', {
|
|
21
|
+
sea: sea.isSea(),
|
|
22
|
+
// TODO: Be less naive with path obscuring
|
|
23
|
+
argv: process.argv.map(arg => arg.replace(process.env.HOME, '~')),
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const withTracing =
|
|
27
|
+
(fn, spanArgs = {}) =>
|
|
28
|
+
(...args) =>
|
|
29
|
+
startSpan({ name: fn.name, attributes: { args }, ...spanArgs }, () => fn(...args));
|
|
30
|
+
|
|
31
|
+
const readAsset = withTracing(
|
|
32
|
+
sea.isSea()
|
|
33
|
+
? name => Buffer.from(sea.getRawAsset(name))
|
|
34
|
+
: (() => {
|
|
35
|
+
const ASSET_DIR = join(fileURLToPath(import.meta.url), '../../dist/overlay/');
|
|
36
|
+
|
|
37
|
+
return name => readFileSync(join(ASSET_DIR, name));
|
|
38
|
+
})(),
|
|
39
|
+
{ name: 'readAsset', op: 'cli.asset.read' },
|
|
40
|
+
);
|
|
22
41
|
|
|
23
|
-
|
|
24
|
-
|
|
42
|
+
startSpan({ name: 'Spotlight CLI', op: 'cli' }, () => {
|
|
43
|
+
startSpan({ name: 'ASCII Art', op: 'cli.art.ascii' }, () => {
|
|
44
|
+
const MAX_COLS = process.stdout.columns;
|
|
45
|
+
if (!process.stdout.isTTY || MAX_COLS < 35) return;
|
|
46
|
+
let stdoutBuffer = '';
|
|
25
47
|
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
48
|
+
const data = startSpan({ name: 'Inflate ASCII Art Data', op: 'cli.art.ascii.inflate' }, () =>
|
|
49
|
+
Uint8Array.from(
|
|
50
|
+
inflateRawSync(
|
|
51
|
+
Buffer.from(
|
|
52
|
+
'bY7LCgMxFEK9L5MwDDSL9P//1DJMKGXowoUcUaFZOk8dU2Op9+qZVkYQoFsaEqA6PZxxma1AoMG+TiONTgcfAd741YxxVf8gCzCgWcYB7OSj9sjW7t2/eKxKAxkIYv8NqL3FpVY25CmjrBSuDw==',
|
|
53
|
+
'base64',
|
|
54
|
+
),
|
|
55
|
+
),
|
|
33
56
|
),
|
|
34
|
-
)
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
57
|
+
);
|
|
58
|
+
const E = '\x1b[';
|
|
59
|
+
const C = `${E}38;5;`;
|
|
60
|
+
const M_COL = `${C}96m`;
|
|
61
|
+
const F_COL = `${C}61m`;
|
|
62
|
+
const BOLD = `${E}1m`;
|
|
63
|
+
const RESET = `${E}0m`;
|
|
64
|
+
const NL = `${RESET}\n`;
|
|
65
|
+
let factor = 0.22;
|
|
66
|
+
let c = 0;
|
|
67
|
+
let col = 0;
|
|
68
|
+
let line = 0;
|
|
69
|
+
let lim = 26;
|
|
70
|
+
let r = 0;
|
|
71
|
+
for (let p of data) {
|
|
72
|
+
if (p === 255) {
|
|
73
|
+
stdoutBuffer += NL;
|
|
74
|
+
c = col = 0;
|
|
75
|
+
if (line++ === 5) {
|
|
76
|
+
factor = factor / -3;
|
|
77
|
+
}
|
|
78
|
+
lim = Math.round(lim * (1 + factor));
|
|
79
|
+
r = Math.round(Math.random() * 18);
|
|
80
|
+
} else {
|
|
81
|
+
while (p-- >= 0 && col < MAX_COLS) {
|
|
82
|
+
if (col < lim - 1) {
|
|
83
|
+
stdoutBuffer += M_COL;
|
|
84
|
+
} else if (col === lim - 1) {
|
|
85
|
+
stdoutBuffer += F_COL;
|
|
86
|
+
} else if (col === lim + r) {
|
|
87
|
+
stdoutBuffer += `${RESET}${BOLD}`;
|
|
88
|
+
}
|
|
89
|
+
stdoutBuffer += c ? (col >= 35 ? '#' : 's') : ' ';
|
|
90
|
+
col++;
|
|
66
91
|
}
|
|
67
|
-
|
|
68
|
-
col++;
|
|
92
|
+
c = !c;
|
|
69
93
|
}
|
|
70
|
-
c = !c;
|
|
71
94
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
95
|
+
stdoutBuffer += NL;
|
|
96
|
+
process.stdout.write(stdoutBuffer);
|
|
97
|
+
});
|
|
75
98
|
|
|
76
|
-
|
|
77
|
-
const
|
|
78
|
-
const
|
|
79
|
-
const
|
|
80
|
-
const
|
|
99
|
+
startSpan({ name: 'Setup Sidecar', op: 'cli.setup.sidecar' }, () => {
|
|
100
|
+
const port = process.argv.length >= 3 ? Number(process.argv[2]) : undefined;
|
|
101
|
+
const MANIFEST_NAME = 'manifest.json';
|
|
102
|
+
const ENTRY_POINT_NAME = 'src/index.html';
|
|
103
|
+
const basePath = process.cwd();
|
|
104
|
+
const filesToServe = Object.create(null);
|
|
81
105
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
106
|
+
startSpan({ name: 'Setup Server Assets', op: 'cli.setup.sidecar.assets' }, () => {
|
|
107
|
+
// Following the guide here: https://vite.dev/guide/backend-integration.html
|
|
108
|
+
const manifest = JSON.parse(readAsset(MANIFEST_NAME));
|
|
109
|
+
filesToServe[ENTRY_POINT_NAME] = readAsset(ENTRY_POINT_NAME);
|
|
110
|
+
const entries = Object.values(manifest);
|
|
111
|
+
for (const entry of entries) {
|
|
112
|
+
filesToServe[entry.file] = readAsset(entry.file);
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
setupSidecar({ port, basePath, filesToServe });
|
|
117
|
+
});
|
|
118
|
+
});
|