bugwatch-cli 0.4.0 → 0.5.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/README.md +14 -2
- package/dist/{chunk-TL4HJZ2T.js → chunk-A3FVZYMN.js} +7 -3
- package/dist/{chunk-IV4JMH5O.js → chunk-TI67SCUE.js} +127 -17
- package/dist/{chunk-YJQR3ZHX.js → chunk-TIAPESCR.js} +1 -1
- package/dist/cli.js +3 -3
- package/dist/index.d.ts +13 -2
- package/dist/index.js +4 -2
- package/dist/main.js +3 -3
- package/dist/vite.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -39,13 +39,24 @@ It:
|
|
|
39
39
|
- **Vite** / **Create React App** / others: `src/bugwatch.ts` (or
|
|
40
40
|
`.js`), imported first in your entry file (Vite's `index.html`
|
|
41
41
|
module script, else `src/main.*` / `src/index.*`)
|
|
42
|
-
4.
|
|
42
|
+
4. **Next.js 15+** (0.5.0+): also the server side, `instrumentation.ts`
|
|
43
|
+
next to `instrumentation-client` (same folder), with
|
|
44
|
+
[`bugwatch/node`](../README.md#nodejs) and the same key, so errors in
|
|
45
|
+
Server Components, route handlers, and server actions are reported.
|
|
46
|
+
An existing `instrumentation.ts` keeps its code: the import goes
|
|
47
|
+
first, the init and `onRequestError` at the end (if the file already
|
|
48
|
+
exports `onRequestError`, it warns you to call
|
|
49
|
+
`Bugwatch.nextOnRequestError` from yours). A `bugwatch` older than
|
|
50
|
+
0.5.0 is upgraded, since `bugwatch/node` needs it. `--skip-server`
|
|
51
|
+
leaves the server out
|
|
52
|
+
5. writes `.bugwatch.json` at the git root. Bugwatch reads it to verify
|
|
43
53
|
the setup; it holds the setup id, never the setup code or a secret
|
|
44
54
|
|
|
45
55
|
It **never commits or pushes**. Review the changes, commit, and push,
|
|
46
56
|
then press **Verify** in Bugwatch: it checks the branch (the default
|
|
47
57
|
branch unless you enter another) and creates the project. Running it
|
|
48
|
-
again is safe: it updates the API key and does not add a
|
|
58
|
+
again is safe: it updates the API key (in both files) and does not add a
|
|
59
|
+
second import.
|
|
49
60
|
|
|
50
61
|
| Option | Description |
|
|
51
62
|
| --- | --- |
|
|
@@ -53,6 +64,7 @@ again is safe: it updates the API key and does not add a second import.
|
|
|
53
64
|
| `--api-url <url>` | Bugwatch API (default: `$BUGWATCH_API_URL` or the hosted API); the command Bugwatch shows includes it when needed |
|
|
54
65
|
| `--entry <file>` | Your app's entry file, when it can't be detected |
|
|
55
66
|
| `--skip-install` | Add `bugwatch` to `package.json` without running the package manager |
|
|
67
|
+
| `--skip-server` | Next.js: don't write the server setup (`instrumentation.ts`) |
|
|
56
68
|
| `--dry-run` | Show what would change; installs and writes nothing |
|
|
57
69
|
|
|
58
70
|
The API key ends up in your browser bundle; that is expected (it can
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
initProject
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-TI67SCUE.js";
|
|
4
4
|
import {
|
|
5
5
|
DEFAULT_API_URL,
|
|
6
6
|
DEFAULT_URL_PREFIX,
|
|
@@ -12,14 +12,15 @@ import {
|
|
|
12
12
|
isCiToken,
|
|
13
13
|
isDeprecatedUploadToken,
|
|
14
14
|
uploadSourceMaps
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-TIAPESCR.js";
|
|
16
16
|
|
|
17
17
|
// src/main.ts
|
|
18
18
|
import { parseArgs } from "util";
|
|
19
19
|
var INIT_USAGE = `Usage: bugwatch-cli init --setup <code> [options]
|
|
20
20
|
|
|
21
21
|
Adds Bugwatch to this app for "Add from GitHub": installs the bugwatch SDK,
|
|
22
|
-
writes the Bugwatch.init code with the project's API key
|
|
22
|
+
writes the Bugwatch.init code with the project's API key (for Next.js 15+
|
|
23
|
+
also the server side, instrumentation.ts with bugwatch/node), and writes
|
|
23
24
|
.bugwatch.json at the git root. It never commits or pushes: review, commit,
|
|
24
25
|
and push the changes, then press Verify in Bugwatch.
|
|
25
26
|
|
|
@@ -28,6 +29,7 @@ Options:
|
|
|
28
29
|
--api-url <url> Bugwatch API (default: $BUGWATCH_API_URL or ${DEFAULT_API_URL})
|
|
29
30
|
--entry <file> Your app's entry file, when it can't be detected
|
|
30
31
|
--skip-install Add bugwatch to package.json instead of running the package manager
|
|
32
|
+
--skip-server Next.js: don't write the server setup (instrumentation.ts)
|
|
31
33
|
--dry-run Show what would change; installs and writes nothing
|
|
32
34
|
-h, --help Show this help
|
|
33
35
|
|
|
@@ -71,6 +73,7 @@ async function main(argv, env = process.env, out = (line) => process.stdout.writ
|
|
|
71
73
|
setup: { type: "string" },
|
|
72
74
|
entry: { type: "string" },
|
|
73
75
|
"skip-install": { type: "boolean" },
|
|
76
|
+
"skip-server": { type: "boolean" },
|
|
74
77
|
help: { type: "boolean", short: "h" },
|
|
75
78
|
version: { type: "boolean", short: "v" }
|
|
76
79
|
}
|
|
@@ -101,6 +104,7 @@ ${USAGE}`);
|
|
|
101
104
|
apiUrl: values["api-url"] || env.BUGWATCH_API_URL || DEFAULT_API_URL,
|
|
102
105
|
...values.entry ? { entry: values.entry } : {},
|
|
103
106
|
skipInstall: values["skip-install"] === true,
|
|
107
|
+
skipServer: values["skip-server"] === true,
|
|
104
108
|
dryRun: values["dry-run"] === true,
|
|
105
109
|
out,
|
|
106
110
|
err
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
DEFAULT_API_URL,
|
|
3
3
|
UsageError,
|
|
4
4
|
VERSION
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-TIAPESCR.js";
|
|
6
6
|
|
|
7
7
|
// src/init.ts
|
|
8
8
|
import { execFile, spawn } from "child_process";
|
|
@@ -11,8 +11,9 @@ import { readFile, writeFile } from "fs/promises";
|
|
|
11
11
|
import { dirname, join, posix, relative, resolve, sep } from "path";
|
|
12
12
|
var MARKER_FILE = ".bugwatch.json";
|
|
13
13
|
var DEFAULT_INGEST_URL = `${DEFAULT_API_URL}/api/ingest`;
|
|
14
|
-
var SDK_VERSION_RANGE = "^0.
|
|
15
|
-
var FETCH_TIMEOUT_MS =
|
|
14
|
+
var SDK_VERSION_RANGE = "^0.5.0";
|
|
15
|
+
var FETCH_TIMEOUT_MS = 9e4;
|
|
16
|
+
var SLOW_NOTICE_MS = 5e3;
|
|
16
17
|
var SETUP_CODE = /^bws_[0-9a-f]{32}$/;
|
|
17
18
|
var ENTRY_EXTENSIONS = ["tsx", "ts", "jsx", "js", "mts", "mjs"];
|
|
18
19
|
function setupCodeProblem(code) {
|
|
@@ -67,9 +68,21 @@ function detectPackageManager(packageDir, gitRoot) {
|
|
|
67
68
|
}
|
|
68
69
|
}
|
|
69
70
|
function installCommand(pm) {
|
|
70
|
-
|
|
71
|
-
return { command:
|
|
71
|
+
const spec = `bugwatch@${SDK_VERSION_RANGE}`;
|
|
72
|
+
if (pm === "npm") return { command: "npm", args: ["install", spec] };
|
|
73
|
+
return { command: pm, args: ["add", spec] };
|
|
72
74
|
}
|
|
75
|
+
function sdkTooOld(range) {
|
|
76
|
+
if (!range) return false;
|
|
77
|
+
const match = /(\d+)\.(\d+)/.exec(range);
|
|
78
|
+
if (!match) return false;
|
|
79
|
+
return Number(match[1]) === 0 && Number(match[2]) < 5;
|
|
80
|
+
}
|
|
81
|
+
function nextMajor(pkg) {
|
|
82
|
+
const match = /(\d+)\./.exec(deps(pkg).next ?? "");
|
|
83
|
+
return match ? Number(match[1]) : null;
|
|
84
|
+
}
|
|
85
|
+
var ON_REQUEST_ERROR_EXPORT = /export\s+(?:const|let|var|function|async\s+function)\s+onRequestError\b|export\s*\{[^}]*\bonRequestError\b/;
|
|
73
86
|
function defaultRunInstall(command, args, cwd) {
|
|
74
87
|
return new Promise((done) => {
|
|
75
88
|
const child = spawn(command, args, { cwd, stdio: "inherit", shell: process.platform === "win32" });
|
|
@@ -77,23 +90,34 @@ function defaultRunInstall(command, args, cwd) {
|
|
|
77
90
|
child.on("close", (code) => done(code ?? 1));
|
|
78
91
|
});
|
|
79
92
|
}
|
|
80
|
-
async function fetchSetup(apiUrl, setupCode) {
|
|
93
|
+
async function fetchSetup(apiUrl, setupCode, notice, timeouts = {}) {
|
|
81
94
|
const url = `${apiUrl.replace(/\/+$/, "")}/api/cli/setup`;
|
|
95
|
+
const fetchMs = timeouts.fetchMs ?? FETCH_TIMEOUT_MS;
|
|
96
|
+
const slow = setTimeout(
|
|
97
|
+
() => notice("Waiting for Bugwatch to answer (a sleeping server can take up to a minute to wake up)\u2026"),
|
|
98
|
+
timeouts.slowNoticeMs ?? SLOW_NOTICE_MS
|
|
99
|
+
);
|
|
82
100
|
let response;
|
|
101
|
+
let body = {};
|
|
83
102
|
try {
|
|
84
103
|
response = await fetch(url, {
|
|
85
104
|
method: "POST",
|
|
86
105
|
headers: { "Content-Type": "application/json", "User-Agent": `bugwatch-cli/${VERSION}` },
|
|
87
106
|
body: JSON.stringify({ setupCode }),
|
|
88
|
-
signal: AbortSignal.timeout(
|
|
107
|
+
signal: AbortSignal.timeout(fetchMs)
|
|
89
108
|
});
|
|
109
|
+
try {
|
|
110
|
+
body = await response.json();
|
|
111
|
+
} catch {
|
|
112
|
+
}
|
|
90
113
|
} catch (error) {
|
|
114
|
+
const name = error?.name;
|
|
115
|
+
if (name === "TimeoutError" || name === "AbortError") {
|
|
116
|
+
throw new Error(`Bugwatch at ${apiUrl} did not answer within ${Math.ceil(fetchMs / 1e3)} s. Try again in a minute`);
|
|
117
|
+
}
|
|
91
118
|
throw new Error(`Could not reach Bugwatch at ${apiUrl}: ${error instanceof Error ? error.message : String(error)}`);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
try {
|
|
95
|
-
body = await response.json();
|
|
96
|
-
} catch {
|
|
119
|
+
} finally {
|
|
120
|
+
clearTimeout(slow);
|
|
97
121
|
}
|
|
98
122
|
if (!response.ok || !body.ok || !body.data) {
|
|
99
123
|
const message = body.error?.message ?? `Bugwatch answered ${response.status}`;
|
|
@@ -143,6 +167,42 @@ function initSource(setup) {
|
|
|
143
167
|
``
|
|
144
168
|
].join("\n");
|
|
145
169
|
}
|
|
170
|
+
function serverSource(setup) {
|
|
171
|
+
const endpoint = setup.ingestUrl !== DEFAULT_INGEST_URL ? `
|
|
172
|
+
endpoint: ${JSON.stringify(setup.ingestUrl)},` : "";
|
|
173
|
+
return [
|
|
174
|
+
`import { Bugwatch } from "bugwatch/node";`,
|
|
175
|
+
``,
|
|
176
|
+
`// Bugwatch on the server for the project ${JSON.stringify(setup.projectName)} (added by bugwatch-cli init):`,
|
|
177
|
+
`// errors in Server Components, route handlers, and server actions. Same key as`,
|
|
178
|
+
`// instrumentation-client: it is public and can only send errors to this project.`,
|
|
179
|
+
`export function register() {`,
|
|
180
|
+
` if (process.env.NEXT_RUNTIME === "nodejs") {`,
|
|
181
|
+
` Bugwatch.init({`,
|
|
182
|
+
` apiKey: ${JSON.stringify(setup.apiKey)},${endpoint}`,
|
|
183
|
+
` });`,
|
|
184
|
+
` }`,
|
|
185
|
+
`}`,
|
|
186
|
+
``,
|
|
187
|
+
`export const onRequestError = Bugwatch.nextOnRequestError;`,
|
|
188
|
+
``
|
|
189
|
+
].join("\n");
|
|
190
|
+
}
|
|
191
|
+
function addServerSetup(current, setup) {
|
|
192
|
+
const endpoint = setup.ingestUrl !== DEFAULT_INGEST_URL ? `, endpoint: ${JSON.stringify(setup.ingestUrl)}` : "";
|
|
193
|
+
const ownOnRequestError = ON_REQUEST_ERROR_EXPORT.test(current);
|
|
194
|
+
const tail = [
|
|
195
|
+
``,
|
|
196
|
+
`// Bugwatch on the server for the project ${JSON.stringify(setup.projectName)} (added by bugwatch-cli init).`,
|
|
197
|
+
`if (process.env.NEXT_RUNTIME === "nodejs") {`,
|
|
198
|
+
` Bugwatch.init({ apiKey: ${JSON.stringify(setup.apiKey)}${endpoint} });`,
|
|
199
|
+
`}`,
|
|
200
|
+
...ownOnRequestError ? [] : [``, `export const onRequestError = Bugwatch.nextOnRequestError;`],
|
|
201
|
+
``
|
|
202
|
+
].join("\n");
|
|
203
|
+
return { content: `import { Bugwatch } from "bugwatch/node";
|
|
204
|
+
${current.replace(/\s*$/, "\n")}${tail}`, ownOnRequestError };
|
|
205
|
+
}
|
|
146
206
|
function replaceApiKey(text, apiKey) {
|
|
147
207
|
const pattern = /(apiKey\s*:\s*)(["'`])bw_[^"'`]*\2/;
|
|
148
208
|
return pattern.test(text) ? text.replace(pattern, `$1$2${apiKey}$2`) : null;
|
|
@@ -165,7 +225,7 @@ function detectIndent(text) {
|
|
|
165
225
|
const match = /^[ \t]+(?=")/m.exec(text);
|
|
166
226
|
return match ? match[0] : 2;
|
|
167
227
|
}
|
|
168
|
-
async function plan(packageDir, pkg, setup, entryOverride, cwd) {
|
|
228
|
+
async function plan(packageDir, pkg, setup, entryOverride, cwd, skipServer) {
|
|
169
229
|
const framework = detectFramework(pkg);
|
|
170
230
|
const typescript = existsSync(join(packageDir, "tsconfig.json"));
|
|
171
231
|
const ext = typescript ? "ts" : "js";
|
|
@@ -227,7 +287,40 @@ ${current}`;
|
|
|
227
287
|
const updated = addImport(text, importSpecifier(entryFile, initFile));
|
|
228
288
|
if (updated !== null) entry = { file: entryFile, content: updated };
|
|
229
289
|
}
|
|
230
|
-
|
|
290
|
+
let server;
|
|
291
|
+
if (framework === "nextjs" && !entryOverride && !skipServer) {
|
|
292
|
+
const major = nextMajor(pkg);
|
|
293
|
+
if (major !== null && major < 15) {
|
|
294
|
+
warnings.push(`Next.js ${major} has no onRequestError (needs 15+): server errors are not set up. See the bugwatch/node docs`);
|
|
295
|
+
} else {
|
|
296
|
+
const dir = posix.dirname(initFile) === "." ? "" : `${posix.dirname(initFile)}/`;
|
|
297
|
+
const file = existing(packageDir, `${dir}instrumentation`) ?? `${dir}instrumentation.${ext}`;
|
|
298
|
+
const path = join(packageDir, file);
|
|
299
|
+
if (!existsSync(path)) {
|
|
300
|
+
server = { file, content: serverSource(setup), action: "create" };
|
|
301
|
+
} else {
|
|
302
|
+
const current = await readFile(path, "utf8");
|
|
303
|
+
if (current.includes("bugwatch/node")) {
|
|
304
|
+
const replaced = replaceApiKey(current, setup.apiKey);
|
|
305
|
+
if (replaced === null) {
|
|
306
|
+
warnings.push(`${file} already uses bugwatch/node without an apiKey string; check it uses ${setup.apiKey}`);
|
|
307
|
+
server = { file, content: current, action: "keep" };
|
|
308
|
+
} else {
|
|
309
|
+
server = { file, content: replaced, action: replaced === current ? "keep" : "update" };
|
|
310
|
+
}
|
|
311
|
+
} else {
|
|
312
|
+
const added = addServerSetup(current, setup);
|
|
313
|
+
server = { file, content: added.content, action: "update" };
|
|
314
|
+
if (added.ownOnRequestError) {
|
|
315
|
+
warnings.push(
|
|
316
|
+
`${file} already exports onRequestError: call Bugwatch.nextOnRequestError(error, request, context) inside it to report server errors`
|
|
317
|
+
);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
return { framework, initFile, initContent, initAction, ...entry ? { entry } : {}, ...server ? { server } : {}, warnings };
|
|
231
324
|
}
|
|
232
325
|
async function initProject(options) {
|
|
233
326
|
const out = options.out ?? ((line) => process.stdout.write(`${line}
|
|
@@ -243,7 +336,7 @@ async function initProject(options) {
|
|
|
243
336
|
if (!gitRoot) throw new UsageError("Run this inside your project's git repository (no .git folder found)");
|
|
244
337
|
const packageDir = findUp(cwd, "package.json", gitRoot);
|
|
245
338
|
if (!packageDir) throw new UsageError("No package.json found. Run this in your JavaScript app's folder");
|
|
246
|
-
const setup = await fetchSetup(apiUrl, options.setupCode);
|
|
339
|
+
const setup = await fetchSetup(apiUrl, options.setupCode, err, options.timeouts);
|
|
247
340
|
out(`Bugwatch project "${setup.projectName}" for ${setup.repo.fullName}`);
|
|
248
341
|
const warnings = [];
|
|
249
342
|
const remote = await gitRemote(gitRoot);
|
|
@@ -254,21 +347,26 @@ async function initProject(options) {
|
|
|
254
347
|
const pkgPath = join(packageDir, "package.json");
|
|
255
348
|
const pkgText = await readFile(pkgPath, "utf8");
|
|
256
349
|
const pkg = await readJson(pkgPath);
|
|
257
|
-
const steps = await plan(packageDir, pkg, setup, options.entry, cwd);
|
|
350
|
+
const steps = await plan(packageDir, pkg, setup, options.entry, cwd, options.skipServer === true);
|
|
258
351
|
warnings.push(...steps.warnings);
|
|
259
352
|
const packageManager = detectPackageManager(packageDir, gitRoot);
|
|
260
|
-
const
|
|
353
|
+
const currentRange = deps(pkg).bugwatch;
|
|
354
|
+
const needsUpgrade = Boolean(steps.server) && sdkTooOld(currentRange);
|
|
355
|
+
const hasSdk = Boolean(currentRange) && !needsUpgrade;
|
|
261
356
|
const fromRoot = (file) => toPosix(relative(gitRoot, join(packageDir, file))) || ".";
|
|
262
357
|
const packageDirRel = toPosix(relative(gitRoot, packageDir)) || ".";
|
|
263
358
|
const changed = [];
|
|
264
359
|
let installed = false;
|
|
265
360
|
if (!hasSdk) {
|
|
266
361
|
const { command, args } = installCommand(packageManager);
|
|
362
|
+
if (needsUpgrade) out(`upgrade bugwatch ${currentRange} \u2192 ${SDK_VERSION_RANGE} (the server setup needs bugwatch/node)`);
|
|
267
363
|
if (dryRun) {
|
|
268
364
|
out(`would run ${options.skipInstall ? `(skipped) add bugwatch@${SDK_VERSION_RANGE} to package.json` : `${command} ${args.join(" ")}`}`);
|
|
269
365
|
} else if (options.skipInstall) {
|
|
270
366
|
const dependencies = typeof pkg.dependencies === "object" && pkg.dependencies !== null ? pkg.dependencies : {};
|
|
271
367
|
pkg.dependencies = { ...dependencies, bugwatch: SDK_VERSION_RANGE };
|
|
368
|
+
const devDependencies = pkg.devDependencies;
|
|
369
|
+
if (devDependencies && typeof devDependencies === "object" && devDependencies.bugwatch) delete devDependencies.bugwatch;
|
|
272
370
|
await writeFile(pkgPath, `${JSON.stringify(pkg, null, detectIndent(pkgText))}
|
|
273
371
|
`);
|
|
274
372
|
out(`added bugwatch@${SDK_VERSION_RANGE} to ${fromRoot("package.json")} (run ${command} install yourself)`);
|
|
@@ -298,12 +396,22 @@ async function initProject(options) {
|
|
|
298
396
|
out(`${verb}update`.padEnd(12) + `${fromRoot(steps.entry.file)} (imports the Bugwatch setup first)`);
|
|
299
397
|
changed.push(fromRoot(steps.entry.file));
|
|
300
398
|
}
|
|
399
|
+
if (steps.server) {
|
|
400
|
+
if (steps.server.action === "keep") {
|
|
401
|
+
out(`kept ${fromRoot(steps.server.file)} (server: already uses bugwatch/node)`);
|
|
402
|
+
} else {
|
|
403
|
+
if (!dryRun) await writeFile(join(packageDir, steps.server.file), steps.server.content);
|
|
404
|
+
out(`${verb}${steps.server.action}`.padEnd(12) + `${fromRoot(steps.server.file)} (server errors)`);
|
|
405
|
+
changed.push(fromRoot(steps.server.file));
|
|
406
|
+
}
|
|
407
|
+
}
|
|
301
408
|
const marker = {
|
|
302
409
|
$comment: "Written by bugwatch-cli init. Bugwatch reads this file to verify the setup; it holds no secrets.",
|
|
303
410
|
setupId: setup.setupId,
|
|
304
411
|
project: setup.projectName,
|
|
305
412
|
packageDir: packageDirRel,
|
|
306
413
|
initFile: steps.initFile,
|
|
414
|
+
...steps.server ? { serverFile: steps.server.file } : {},
|
|
307
415
|
framework: steps.framework
|
|
308
416
|
};
|
|
309
417
|
if (!dryRun) await writeFile(join(gitRoot, MARKER_FILE), `${JSON.stringify(marker, null, 2)}
|
|
@@ -329,6 +437,7 @@ async function initProject(options) {
|
|
|
329
437
|
packageManager,
|
|
330
438
|
packageDir: packageDirRel,
|
|
331
439
|
initFile: steps.initFile,
|
|
440
|
+
...steps.server ? { serverFile: steps.server.file } : {},
|
|
332
441
|
changed: [...new Set(changed)],
|
|
333
442
|
installed,
|
|
334
443
|
warnings
|
|
@@ -342,6 +451,7 @@ export {
|
|
|
342
451
|
detectFramework,
|
|
343
452
|
detectPackageManager,
|
|
344
453
|
installCommand,
|
|
454
|
+
sdkTooOld,
|
|
345
455
|
remoteRepo,
|
|
346
456
|
replaceApiKey,
|
|
347
457
|
importSpecifier,
|
package/dist/cli.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
main
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-A3FVZYMN.js";
|
|
5
|
+
import "./chunk-TI67SCUE.js";
|
|
6
|
+
import "./chunk-TIAPESCR.js";
|
|
7
7
|
|
|
8
8
|
// src/cli.ts
|
|
9
9
|
main(process.argv.slice(2)).then((code) => {
|
package/dist/index.d.ts
CHANGED
|
@@ -170,11 +170,18 @@ interface InitOptions {
|
|
|
170
170
|
entry?: string;
|
|
171
171
|
/** Do not run the package manager; add `bugwatch` to package.json instead. */
|
|
172
172
|
skipInstall?: boolean;
|
|
173
|
+
/** Next.js: do not write the server setup (`instrumentation.ts` with `bugwatch/node`). */
|
|
174
|
+
skipServer?: boolean;
|
|
173
175
|
dryRun?: boolean;
|
|
174
176
|
out?: (line: string) => void;
|
|
175
177
|
err?: (line: string) => void;
|
|
176
178
|
/** Runs the install command; returns its exit code. Tests replace it. */
|
|
177
179
|
runInstall?: (command: string, args: string[], cwd: string) => Promise<number>;
|
|
180
|
+
/** How long to wait for Bugwatch (default 90 s) and when to say it is waking up (default 5 s). Tests shorten them. */
|
|
181
|
+
timeouts?: {
|
|
182
|
+
fetchMs?: number;
|
|
183
|
+
slowNoticeMs?: number;
|
|
184
|
+
};
|
|
178
185
|
}
|
|
179
186
|
interface InitReport {
|
|
180
187
|
setup: CliSetup;
|
|
@@ -184,6 +191,8 @@ interface InitReport {
|
|
|
184
191
|
packageDir: string;
|
|
185
192
|
/** The file that calls Bugwatch.init, relative to packageDir. */
|
|
186
193
|
initFile: string;
|
|
194
|
+
/** Next.js: the server setup file (`instrumentation.ts`), relative to packageDir, when written or kept. */
|
|
195
|
+
serverFile?: string;
|
|
187
196
|
/** Files written or changed, relative to the git root. */
|
|
188
197
|
changed: string[];
|
|
189
198
|
installed: boolean;
|
|
@@ -196,6 +205,8 @@ declare function installCommand(pm: PackageManager): {
|
|
|
196
205
|
command: string;
|
|
197
206
|
args: string[];
|
|
198
207
|
};
|
|
208
|
+
/** True when a `bugwatch` range in package.json cannot include 0.5.0 (which adds `bugwatch/node`). */
|
|
209
|
+
declare function sdkTooOld(range: string | undefined): boolean;
|
|
199
210
|
/** `git@github.com:acme/shop.git` / `https://github.com/acme/shop` → `acme/shop`. */
|
|
200
211
|
declare function remoteRepo(remote: string): string | null;
|
|
201
212
|
/** Replaces the apiKey string literal in an existing init call; null when there is none to replace. */
|
|
@@ -208,6 +219,6 @@ declare function addImport(text: string, spec: string): string | null;
|
|
|
208
219
|
declare function initProject(options: InitOptions): Promise<InitReport>;
|
|
209
220
|
|
|
210
221
|
/** Keep in sync with package.json (a test checks it). */
|
|
211
|
-
declare const VERSION = "0.
|
|
222
|
+
declare const VERSION = "0.5.0";
|
|
212
223
|
|
|
213
|
-
export { CONCURRENCY, type CliSetup, DEFAULT_API_URL, DEFAULT_INGEST_URL, DEFAULT_URL_PREFIX, type FileResult, type Framework, type InitOptions, type InitReport, MARKER_FILE, MAX_MAP_BYTES, MAX_RETRIES, type Outcome, type PackageManager, type PlannedUpload, STOP_CODES, UPLOAD_TOKEN_DEPRECATED, type UploadOptions, type UploadReport, type UploadSummary, UsageError, VERSION, addImport, detectFramework, detectPackageManager, findMapOwners, findSourceMaps, formatBytes, formatResult, formatSummary, importSpecifier, initProject, installCommand, isCiToken, isCssMap, isDeprecatedUploadToken, mapName, planUploads, projectProblem, releaseProblem, remoteRepo, replaceApiKey, sendableMapFile, setupCodeProblem, sourceMappingUrlOf, uploadSourceMaps, urlPrefixProblem };
|
|
224
|
+
export { CONCURRENCY, type CliSetup, DEFAULT_API_URL, DEFAULT_INGEST_URL, DEFAULT_URL_PREFIX, type FileResult, type Framework, type InitOptions, type InitReport, MARKER_FILE, MAX_MAP_BYTES, MAX_RETRIES, type Outcome, type PackageManager, type PlannedUpload, STOP_CODES, UPLOAD_TOKEN_DEPRECATED, type UploadOptions, type UploadReport, type UploadSummary, UsageError, VERSION, addImport, detectFramework, detectPackageManager, findMapOwners, findSourceMaps, formatBytes, formatResult, formatSummary, importSpecifier, initProject, installCommand, isCiToken, isCssMap, isDeprecatedUploadToken, mapName, planUploads, projectProblem, releaseProblem, remoteRepo, replaceApiKey, sdkTooOld, sendableMapFile, setupCodeProblem, sourceMappingUrlOf, uploadSourceMaps, urlPrefixProblem };
|
package/dist/index.js
CHANGED
|
@@ -9,8 +9,9 @@ import {
|
|
|
9
9
|
installCommand,
|
|
10
10
|
remoteRepo,
|
|
11
11
|
replaceApiKey,
|
|
12
|
+
sdkTooOld,
|
|
12
13
|
setupCodeProblem
|
|
13
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-TI67SCUE.js";
|
|
14
15
|
import {
|
|
15
16
|
CONCURRENCY,
|
|
16
17
|
DEFAULT_API_URL,
|
|
@@ -37,7 +38,7 @@ import {
|
|
|
37
38
|
sourceMappingUrlOf,
|
|
38
39
|
uploadSourceMaps,
|
|
39
40
|
urlPrefixProblem
|
|
40
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-TIAPESCR.js";
|
|
41
42
|
export {
|
|
42
43
|
CONCURRENCY,
|
|
43
44
|
DEFAULT_API_URL,
|
|
@@ -70,6 +71,7 @@ export {
|
|
|
70
71
|
releaseProblem,
|
|
71
72
|
remoteRepo,
|
|
72
73
|
replaceApiKey,
|
|
74
|
+
sdkTooOld,
|
|
73
75
|
sendableMapFile,
|
|
74
76
|
setupCodeProblem,
|
|
75
77
|
sourceMappingUrlOf,
|
package/dist/main.js
CHANGED
package/dist/vite.js
CHANGED