bugwatch-cli 0.6.0 → 0.7.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 +26 -0
- package/dist/{chunk-HO2KESIB.js → chunk-H3LKWUXE.js} +1 -1
- package/dist/{chunk-H6KZ37MK.js → chunk-NKLMUZBK.js} +66 -2
- package/dist/{chunk-VFCYFSZI.js → chunk-T4GRUZAC.js} +68 -3
- package/dist/cli.js +3 -3
- package/dist/index.d.ts +40 -2
- package/dist/index.js +12 -2
- package/dist/main.js +3 -3
- package/dist/vite.d.ts +10 -0
- package/dist/vite.js +22 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -131,6 +131,8 @@ Options:
|
|
|
131
131
|
| `deleteAfterUpload` | `true` | Delete the `.map` files from the build output after a fully successful upload |
|
|
132
132
|
| `deleteOld` | `false` | Delete the project's older source maps in Bugwatch after a fully successful upload. See [Keep only the latest deploy](#keep-only-the-latest-deploy) |
|
|
133
133
|
| `failOnError` | `false` | Fail `vite build` when an upload fails (default: log the error and continue) |
|
|
134
|
+
| `commits` | `true` | 0.7.0: after uploading, send the release's commit (see [Release commits](#release-commits)); nothing is sent when no commit is found, and a failure only warns |
|
|
135
|
+
| `commit` | detected | The commit to send: else `GITHUB_SHA`, `VERCEL_GIT_COMMIT_SHA`, `CI_COMMIT_SHA`, `COMMIT_REF`, `CF_PAGES_COMMIT_SHA`, `BITBUCKET_COMMIT`, or `git rev-parse HEAD` |
|
|
134
136
|
|
|
135
137
|
The plugin runs only for `vite build` (not the dev server), after the
|
|
136
138
|
bundle is written, on `build.outDir`. It warns and does nothing when
|
|
@@ -251,6 +253,29 @@ npx bugwatch-cli sourcemaps upload dist --release ${GITHUB_SHA} --delete-after-u
|
|
|
251
253
|
- Run it on deploys of one environment only: a staging deploy with
|
|
252
254
|
`--delete-old` deletes production's maps of the same project
|
|
253
255
|
|
|
256
|
+
## Release commits
|
|
257
|
+
|
|
258
|
+
Since 0.7.0. Tell Bugwatch which commit a release was built from, and it
|
|
259
|
+
reads the commits since the previous release from GitHub: issues then
|
|
260
|
+
show **suspect commits** (commits of the release that changed a file in
|
|
261
|
+
the error's stack), and stack frames link to the exact line of that
|
|
262
|
+
commit on GitHub. The project needs a GitHub repository in Bugwatch
|
|
263
|
+
(Settings → General → Repository; projects added from GitHub have one).
|
|
264
|
+
|
|
265
|
+
```sh
|
|
266
|
+
npx bugwatch-cli release commits --release "$RELEASE"
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
The commit is detected from CI variables (`GITHUB_SHA`,
|
|
270
|
+
`VERCEL_GIT_COMMIT_SHA`, `CI_COMMIT_SHA`, `COMMIT_REF`,
|
|
271
|
+
`CF_PAGES_COMMIT_SHA`, `BITBUCKET_COMMIT`) or `git rev-parse HEAD`; pass
|
|
272
|
+
`--commit <sha>` to choose it, and `--previous-commit <sha>` when the
|
|
273
|
+
release's commits should start somewhere other than the previous
|
|
274
|
+
release's commit. Same token and project options as the upload. The
|
|
275
|
+
Vite plugin does this after uploading (option `commits`). When the
|
|
276
|
+
release version is itself the commit SHA (e.g. `${{ github.sha }}`),
|
|
277
|
+
Bugwatch finds the commit without this step.
|
|
278
|
+
|
|
254
279
|
## CI example (GitHub Actions)
|
|
255
280
|
|
|
256
281
|
```yaml
|
|
@@ -263,6 +288,7 @@ npx bugwatch-cli sourcemaps upload dist --release ${GITHUB_SHA} --delete-after-u
|
|
|
263
288
|
BUGWATCH_PROJECT: 6735f0c2a1b2c3d4e5f60718 # the project id (not a secret)
|
|
264
289
|
# Without the Vite plugin:
|
|
265
290
|
# - run: npx bugwatch-cli sourcemaps upload dist --release ${{ github.sha }} --delete-after-upload --delete-old
|
|
291
|
+
# - run: npx bugwatch-cli release commits --release ${{ github.sha }}
|
|
266
292
|
# env:
|
|
267
293
|
# BUGWATCH_UPLOAD_TOKEN: ${{ secrets.BUGWATCH_UPLOAD_TOKEN }}
|
|
268
294
|
# BUGWATCH_PROJECT: 6735f0c2a1b2c3d4e5f60718
|
|
@@ -36,7 +36,7 @@ function formatSummary(summary, { dryRun, release, files, deleteOld = false }) {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
// src/version.ts
|
|
39
|
-
var VERSION = "0.
|
|
39
|
+
var VERSION = "0.7.0";
|
|
40
40
|
|
|
41
41
|
// src/upload.ts
|
|
42
42
|
import { open, readdir, readFile, stat, unlink } from "fs/promises";
|
|
@@ -403,6 +403,65 @@ async function uploadSourceMaps(options) {
|
|
|
403
403
|
return { results, summary };
|
|
404
404
|
}
|
|
405
405
|
|
|
406
|
+
// src/commits.ts
|
|
407
|
+
import { execFileSync } from "child_process";
|
|
408
|
+
var COMMIT_SHA = /^[0-9a-f]{7,40}$/i;
|
|
409
|
+
var COMMIT_ENV_VARS = ["GITHUB_SHA", "VERCEL_GIT_COMMIT_SHA", "CI_COMMIT_SHA", "COMMIT_REF", "CF_PAGES_COMMIT_SHA", "BITBUCKET_COMMIT"];
|
|
410
|
+
function detectCommit(env = process.env, cwd = process.cwd(), git = (dir) => execFileSync("git", ["rev-parse", "HEAD"], { cwd: dir, stdio: ["ignore", "pipe", "ignore"] }).toString()) {
|
|
411
|
+
for (const name of COMMIT_ENV_VARS) {
|
|
412
|
+
const value = env[name]?.trim();
|
|
413
|
+
if (value && COMMIT_SHA.test(value)) return value.toLowerCase();
|
|
414
|
+
}
|
|
415
|
+
try {
|
|
416
|
+
const head = git(cwd).trim();
|
|
417
|
+
return COMMIT_SHA.test(head) ? head.toLowerCase() : null;
|
|
418
|
+
} catch {
|
|
419
|
+
return null;
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
async function sendReleaseCommit(options) {
|
|
423
|
+
const releaseError = releaseProblem(options.release);
|
|
424
|
+
if (releaseError) throw new UsageError(releaseError);
|
|
425
|
+
if (!COMMIT_SHA.test(options.commit)) throw new UsageError("The commit must be a SHA (7\u201340 hex characters)");
|
|
426
|
+
if (options.previousCommit !== void 0 && !COMMIT_SHA.test(options.previousCommit)) {
|
|
427
|
+
throw new UsageError("The previous commit must be a SHA (7\u201340 hex characters)");
|
|
428
|
+
}
|
|
429
|
+
if (isCiToken(options.token)) {
|
|
430
|
+
if (!options.project) throw new UsageError("A CI token (bwc_\u2026) needs the project id: set BUGWATCH_PROJECT (or pass --project)");
|
|
431
|
+
const problem = projectProblem(options.project);
|
|
432
|
+
if (problem) throw new UsageError(problem);
|
|
433
|
+
}
|
|
434
|
+
const apiUrl = (options.apiUrl || DEFAULT_API_URL).replace(/\/+$/, "");
|
|
435
|
+
const route = isCiToken(options.token) ? `/api/projects/${encodeURIComponent(options.project)}/releases/${encodeURIComponent(options.release)}/commits` : `/api/releases/${encodeURIComponent(options.release)}/commits`;
|
|
436
|
+
const response = await (options.fetch ?? fetch)(`${apiUrl}${route}`, {
|
|
437
|
+
method: "POST",
|
|
438
|
+
headers: {
|
|
439
|
+
authorization: `Bearer ${options.token}`,
|
|
440
|
+
"content-type": "application/json",
|
|
441
|
+
"user-agent": `bugwatch-cli/${VERSION}`
|
|
442
|
+
},
|
|
443
|
+
body: JSON.stringify({
|
|
444
|
+
commit: options.commit.toLowerCase(),
|
|
445
|
+
...options.previousCommit ? { previousCommit: options.previousCommit.toLowerCase() } : {}
|
|
446
|
+
})
|
|
447
|
+
});
|
|
448
|
+
let payload = {};
|
|
449
|
+
try {
|
|
450
|
+
payload = await response.json();
|
|
451
|
+
} catch {
|
|
452
|
+
}
|
|
453
|
+
if (!response.ok || !payload.data) {
|
|
454
|
+
if (response.status === 404 && !payload.error) throw new Error("This Bugwatch API does not accept release commits yet (needs backend Step 144)");
|
|
455
|
+
throw new Error(payload.error?.message ?? `HTTP ${response.status}`);
|
|
456
|
+
}
|
|
457
|
+
return payload.data;
|
|
458
|
+
}
|
|
459
|
+
function formatCommitResult(result) {
|
|
460
|
+
const sha = result.commit?.sha.slice(0, 12) ?? "?";
|
|
461
|
+
if (result.commitsStatus === "failed") return `Release ${result.version}: commit ${sha} recorded, but ${result.commitsError ?? "its commits could not be read"}`;
|
|
462
|
+
return `Release ${result.version}: commit ${sha} recorded; Bugwatch is reading its commits from GitHub`;
|
|
463
|
+
}
|
|
464
|
+
|
|
406
465
|
export {
|
|
407
466
|
formatBytes,
|
|
408
467
|
formatResult,
|
|
@@ -428,5 +487,10 @@ export {
|
|
|
428
487
|
isCssMap,
|
|
429
488
|
planUploads,
|
|
430
489
|
sendableMapFile,
|
|
431
|
-
uploadSourceMaps
|
|
490
|
+
uploadSourceMaps,
|
|
491
|
+
COMMIT_SHA,
|
|
492
|
+
COMMIT_ENV_VARS,
|
|
493
|
+
detectCommit,
|
|
494
|
+
sendReleaseCommit,
|
|
495
|
+
formatCommitResult
|
|
432
496
|
};
|
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
import {
|
|
2
2
|
initProject
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-H3LKWUXE.js";
|
|
4
4
|
import {
|
|
5
5
|
DEFAULT_API_URL,
|
|
6
6
|
DEFAULT_URL_PREFIX,
|
|
7
7
|
UPLOAD_TOKEN_DEPRECATED,
|
|
8
8
|
UsageError,
|
|
9
9
|
VERSION,
|
|
10
|
+
detectCommit,
|
|
11
|
+
formatCommitResult,
|
|
10
12
|
formatResult,
|
|
11
13
|
formatSummary,
|
|
12
14
|
isCiToken,
|
|
13
15
|
isDeprecatedUploadToken,
|
|
16
|
+
sendReleaseCommit,
|
|
14
17
|
uploadSourceMaps
|
|
15
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-NKLMUZBK.js";
|
|
16
19
|
|
|
17
20
|
// src/main.ts
|
|
18
21
|
import { parseArgs } from "util";
|
|
@@ -34,6 +37,25 @@ Options:
|
|
|
34
37
|
-h, --help Show this help
|
|
35
38
|
|
|
36
39
|
Exit codes: 0 done, 1 failed (network, install), 2 usage error.`;
|
|
40
|
+
var COMMITS_USAGE = `Usage: bugwatch-cli release commits --release <version> [options]
|
|
41
|
+
|
|
42
|
+
Tells Bugwatch which commit the release was built from. Bugwatch then reads
|
|
43
|
+
the commits since the previous release from GitHub, for suspect commits on
|
|
44
|
+
issues and links from stack frames to the exact line. The project needs a
|
|
45
|
+
GitHub repository (Bugwatch: Settings \u2192 General \u2192 Repository).
|
|
46
|
+
|
|
47
|
+
Options:
|
|
48
|
+
--release <version> The release the SDK sends (Bugwatch.init({ release })). Required
|
|
49
|
+
--commit <sha> The commit (default: $GITHUB_SHA, $VERCEL_GIT_COMMIT_SHA,
|
|
50
|
+
$CI_COMMIT_SHA, $COMMIT_REF, \u2026 or git rev-parse HEAD)
|
|
51
|
+
--previous-commit <sha> Where the release's commits start (default: the previous
|
|
52
|
+
release's commit in Bugwatch)
|
|
53
|
+
--api-url <url> Bugwatch API (default: $BUGWATCH_API_URL or ${DEFAULT_API_URL})
|
|
54
|
+
--token <token> Org CI token, bwc_\u2026 (default: $BUGWATCH_UPLOAD_TOKEN; prefer the variable)
|
|
55
|
+
--project <id> Project id, required with a CI token (default: $BUGWATCH_PROJECT)
|
|
56
|
+
-h, --help Show this help
|
|
57
|
+
|
|
58
|
+
Exit codes: 0 recorded, 1 failed (network, refused), 2 usage error.`;
|
|
37
59
|
var USAGE = `Usage: bugwatch-cli sourcemaps upload <dir> --release <version> [options]
|
|
38
60
|
|
|
39
61
|
Uploads every .map file under <dir> to Bugwatch for the release.
|
|
@@ -56,7 +78,8 @@ Options:
|
|
|
56
78
|
|
|
57
79
|
Exit codes: 0 all uploaded, 1 an upload failed, 2 usage error.
|
|
58
80
|
|
|
59
|
-
Set up a new project from GitHub: bugwatch-cli init --setup <code> (see bugwatch-cli init --help)
|
|
81
|
+
Set up a new project from GitHub: bugwatch-cli init --setup <code> (see bugwatch-cli init --help).
|
|
82
|
+
Send the release's commit: bugwatch-cli release commits --release <version> (see bugwatch-cli release commits --help).`;
|
|
60
83
|
async function main(argv, env = process.env, out = (line) => process.stdout.write(`${line}
|
|
61
84
|
`), err = (line) => process.stderr.write(`${line}
|
|
62
85
|
`)) {
|
|
@@ -78,6 +101,8 @@ async function main(argv, env = process.env, out = (line) => process.stdout.writ
|
|
|
78
101
|
entry: { type: "string" },
|
|
79
102
|
"skip-install": { type: "boolean" },
|
|
80
103
|
"skip-server": { type: "boolean" },
|
|
104
|
+
commit: { type: "string" },
|
|
105
|
+
"previous-commit": { type: "string" },
|
|
81
106
|
help: { type: "boolean", short: "h" },
|
|
82
107
|
version: { type: "boolean", short: "v" }
|
|
83
108
|
}
|
|
@@ -119,6 +144,46 @@ ${USAGE}`);
|
|
|
119
144
|
return error instanceof UsageError ? 2 : 1;
|
|
120
145
|
}
|
|
121
146
|
}
|
|
147
|
+
if (positionals[0] === "release") {
|
|
148
|
+
if (values.help) {
|
|
149
|
+
out(COMMITS_USAGE);
|
|
150
|
+
return 0;
|
|
151
|
+
}
|
|
152
|
+
if (positionals[1] !== "commits" || positionals.length > 2) {
|
|
153
|
+
err(COMMITS_USAGE);
|
|
154
|
+
return 2;
|
|
155
|
+
}
|
|
156
|
+
if (!values.release) {
|
|
157
|
+
err("Error: A release is required (--release)");
|
|
158
|
+
return 2;
|
|
159
|
+
}
|
|
160
|
+
const token2 = values.token || env.BUGWATCH_UPLOAD_TOKEN || void 0;
|
|
161
|
+
if (!token2) {
|
|
162
|
+
err("Error: A token is required: set BUGWATCH_UPLOAD_TOKEN (or pass --token)");
|
|
163
|
+
return 2;
|
|
164
|
+
}
|
|
165
|
+
const commit = values.commit || detectCommit(env);
|
|
166
|
+
if (!commit) {
|
|
167
|
+
err("Error: No commit found: pass --commit <sha> (or set GITHUB_SHA), or run inside the git checkout");
|
|
168
|
+
return 2;
|
|
169
|
+
}
|
|
170
|
+
const project2 = values.project || env.BUGWATCH_PROJECT || void 0;
|
|
171
|
+
try {
|
|
172
|
+
const result = await sendReleaseCommit({
|
|
173
|
+
release: values.release,
|
|
174
|
+
commit,
|
|
175
|
+
...values["previous-commit"] ? { previousCommit: values["previous-commit"] } : {},
|
|
176
|
+
token: token2,
|
|
177
|
+
...project2 ? { project: project2 } : {},
|
|
178
|
+
apiUrl: values["api-url"] || env.BUGWATCH_API_URL || DEFAULT_API_URL
|
|
179
|
+
});
|
|
180
|
+
(result.commitsStatus === "failed" ? err : out)(formatCommitResult(result));
|
|
181
|
+
return 0;
|
|
182
|
+
} catch (error) {
|
|
183
|
+
err(`Error: ${error instanceof Error ? error.message : String(error)}`);
|
|
184
|
+
return error instanceof UsageError ? 2 : 1;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
122
187
|
if (values.help) {
|
|
123
188
|
out(USAGE);
|
|
124
189
|
return 0;
|
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-T4GRUZAC.js";
|
|
5
|
+
import "./chunk-H3LKWUXE.js";
|
|
6
|
+
import "./chunk-NKLMUZBK.js";
|
|
7
7
|
|
|
8
8
|
// src/cli.ts
|
|
9
9
|
main(process.argv.slice(2)).then((code) => {
|
package/dist/index.d.ts
CHANGED
|
@@ -237,7 +237,45 @@ declare function addImport(text: string, spec: string): string | null;
|
|
|
237
237
|
/** Runs `init`. Throws UsageError for user mistakes, Error for failures. */
|
|
238
238
|
declare function initProject(options: InitOptions): Promise<InitReport>;
|
|
239
239
|
|
|
240
|
+
/**
|
|
241
|
+
* Release commits (backend Step 144): tell Bugwatch which commit a release
|
|
242
|
+
* was built from. Bugwatch then reads the commits since the previous release
|
|
243
|
+
* from GitHub (through its GitHub App), for suspect commits and code links.
|
|
244
|
+
*/
|
|
245
|
+
/** A commit SHA as Bugwatch accepts it (7–40 hex). */
|
|
246
|
+
declare const COMMIT_SHA: RegExp;
|
|
247
|
+
/** CI variables that hold the commit being built, in order. */
|
|
248
|
+
declare const COMMIT_ENV_VARS: readonly ["GITHUB_SHA", "VERCEL_GIT_COMMIT_SHA", "CI_COMMIT_SHA", "COMMIT_REF", "CF_PAGES_COMMIT_SHA", "BITBUCKET_COMMIT"];
|
|
249
|
+
/**
|
|
250
|
+
* The commit to send: the first CI variable that holds a SHA, else `git
|
|
251
|
+
* rev-parse HEAD` in `cwd`; null when neither works (not a git checkout).
|
|
252
|
+
*/
|
|
253
|
+
declare function detectCommit(env?: NodeJS.ProcessEnv, cwd?: string, git?: (cwd: string) => string): string | null;
|
|
254
|
+
interface ReleaseCommitOptions {
|
|
255
|
+
release: string;
|
|
256
|
+
commit: string;
|
|
257
|
+
previousCommit?: string;
|
|
258
|
+
token: string;
|
|
259
|
+
/** Required with a CI token (`bwc_…`). */
|
|
260
|
+
project?: string;
|
|
261
|
+
apiUrl?: string;
|
|
262
|
+
fetch?: typeof fetch;
|
|
263
|
+
}
|
|
264
|
+
interface ReleaseCommitResult {
|
|
265
|
+
version: string;
|
|
266
|
+
commit: {
|
|
267
|
+
sha: string;
|
|
268
|
+
url: string | null;
|
|
269
|
+
} | null;
|
|
270
|
+
commitsStatus: "none" | "pending" | "ready" | "failed";
|
|
271
|
+
commitsError: string | null;
|
|
272
|
+
}
|
|
273
|
+
/** Throws a `UsageError` for bad input, an `Error` with the server's message when Bugwatch refuses. */
|
|
274
|
+
declare function sendReleaseCommit(options: ReleaseCommitOptions): Promise<ReleaseCommitResult>;
|
|
275
|
+
/** One line for the result. */
|
|
276
|
+
declare function formatCommitResult(result: ReleaseCommitResult): string;
|
|
277
|
+
|
|
240
278
|
/** Keep in sync with package.json (a test checks it). */
|
|
241
|
-
declare const VERSION = "0.
|
|
279
|
+
declare const VERSION = "0.7.0";
|
|
242
280
|
|
|
243
|
-
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 };
|
|
281
|
+
export { COMMIT_ENV_VARS, COMMIT_SHA, 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, type ReleaseCommitOptions, type ReleaseCommitResult, STOP_CODES, UPLOAD_TOKEN_DEPRECATED, type UploadOptions, type UploadReport, type UploadSummary, UsageError, VERSION, addImport, detectCommit, detectFramework, detectPackageManager, findMapOwners, findSourceMaps, formatBytes, formatCommitResult, formatResult, formatSummary, importSpecifier, initProject, installCommand, isCiToken, isCssMap, isDeprecatedUploadToken, mapName, planUploads, projectProblem, releaseProblem, remoteRepo, replaceApiKey, sdkTooOld, sendReleaseCommit, sendableMapFile, setupCodeProblem, sourceMappingUrlOf, uploadSourceMaps, urlPrefixProblem };
|
package/dist/index.js
CHANGED
|
@@ -11,8 +11,10 @@ import {
|
|
|
11
11
|
replaceApiKey,
|
|
12
12
|
sdkTooOld,
|
|
13
13
|
setupCodeProblem
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-H3LKWUXE.js";
|
|
15
15
|
import {
|
|
16
|
+
COMMIT_ENV_VARS,
|
|
17
|
+
COMMIT_SHA,
|
|
16
18
|
CONCURRENCY,
|
|
17
19
|
DEFAULT_API_URL,
|
|
18
20
|
DEFAULT_URL_PREFIX,
|
|
@@ -22,9 +24,11 @@ import {
|
|
|
22
24
|
UPLOAD_TOKEN_DEPRECATED,
|
|
23
25
|
UsageError,
|
|
24
26
|
VERSION,
|
|
27
|
+
detectCommit,
|
|
25
28
|
findMapOwners,
|
|
26
29
|
findSourceMaps,
|
|
27
30
|
formatBytes,
|
|
31
|
+
formatCommitResult,
|
|
28
32
|
formatResult,
|
|
29
33
|
formatSummary,
|
|
30
34
|
isCiToken,
|
|
@@ -34,12 +38,15 @@ import {
|
|
|
34
38
|
planUploads,
|
|
35
39
|
projectProblem,
|
|
36
40
|
releaseProblem,
|
|
41
|
+
sendReleaseCommit,
|
|
37
42
|
sendableMapFile,
|
|
38
43
|
sourceMappingUrlOf,
|
|
39
44
|
uploadSourceMaps,
|
|
40
45
|
urlPrefixProblem
|
|
41
|
-
} from "./chunk-
|
|
46
|
+
} from "./chunk-NKLMUZBK.js";
|
|
42
47
|
export {
|
|
48
|
+
COMMIT_ENV_VARS,
|
|
49
|
+
COMMIT_SHA,
|
|
43
50
|
CONCURRENCY,
|
|
44
51
|
DEFAULT_API_URL,
|
|
45
52
|
DEFAULT_INGEST_URL,
|
|
@@ -52,11 +59,13 @@ export {
|
|
|
52
59
|
UsageError,
|
|
53
60
|
VERSION,
|
|
54
61
|
addImport,
|
|
62
|
+
detectCommit,
|
|
55
63
|
detectFramework,
|
|
56
64
|
detectPackageManager,
|
|
57
65
|
findMapOwners,
|
|
58
66
|
findSourceMaps,
|
|
59
67
|
formatBytes,
|
|
68
|
+
formatCommitResult,
|
|
60
69
|
formatResult,
|
|
61
70
|
formatSummary,
|
|
62
71
|
importSpecifier,
|
|
@@ -72,6 +81,7 @@ export {
|
|
|
72
81
|
remoteRepo,
|
|
73
82
|
replaceApiKey,
|
|
74
83
|
sdkTooOld,
|
|
84
|
+
sendReleaseCommit,
|
|
75
85
|
sendableMapFile,
|
|
76
86
|
setupCodeProblem,
|
|
77
87
|
sourceMappingUrlOf,
|
package/dist/main.js
CHANGED
package/dist/vite.d.ts
CHANGED
|
@@ -23,6 +23,16 @@ interface BugwatchSourcemapsOptions {
|
|
|
23
23
|
deleteOld?: boolean;
|
|
24
24
|
/** Fail `vite build` when an upload fails. Default `false` (log and continue). */
|
|
25
25
|
failOnError?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* After uploading, send the release's commit (backend Step 144) so Bugwatch
|
|
28
|
+
* can show suspect commits and link frames to GitHub. The commit comes from
|
|
29
|
+
* `commit`, CI variables (`GITHUB_SHA`, `VERCEL_GIT_COMMIT_SHA`, …), or `git
|
|
30
|
+
* rev-parse HEAD`. Default `true`; nothing is sent when no commit is found.
|
|
31
|
+
* A failure is only a warning.
|
|
32
|
+
*/
|
|
33
|
+
commits?: boolean;
|
|
34
|
+
/** The commit to send; default: detected (see `commits`). */
|
|
35
|
+
commit?: string;
|
|
26
36
|
}
|
|
27
37
|
/** The parts of Vite's resolved config the plugin reads (keeps this package free of a `vite` dependency). */
|
|
28
38
|
interface ViteConfigLike {
|
package/dist/vite.js
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
|
+
DEFAULT_API_URL,
|
|
2
3
|
DEFAULT_URL_PREFIX,
|
|
3
4
|
UPLOAD_TOKEN_DEPRECATED,
|
|
4
5
|
UsageError,
|
|
6
|
+
detectCommit,
|
|
7
|
+
formatCommitResult,
|
|
5
8
|
formatResult,
|
|
6
9
|
formatSummary,
|
|
7
10
|
isCiToken,
|
|
8
11
|
isDeprecatedUploadToken,
|
|
12
|
+
sendReleaseCommit,
|
|
9
13
|
uploadSourceMaps
|
|
10
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-NKLMUZBK.js";
|
|
11
15
|
|
|
12
16
|
// src/vite.ts
|
|
13
17
|
import { resolve } from "path";
|
|
@@ -74,6 +78,23 @@ function bugwatchSourcemaps(options) {
|
|
|
74
78
|
});
|
|
75
79
|
logger.info(`${PREFIX} ${formatSummary(summary, { dryRun: false, release, files: results.length, deleteOld })}`);
|
|
76
80
|
if (summary.pruneError) logger.warn(`${PREFIX} Old source maps were not deleted: ${summary.pruneError}`);
|
|
81
|
+
if (options.commits !== false) {
|
|
82
|
+
const commit = options.commit || detectCommit(process.env, config.root);
|
|
83
|
+
if (commit) {
|
|
84
|
+
try {
|
|
85
|
+
const result = await sendReleaseCommit({
|
|
86
|
+
release,
|
|
87
|
+
commit,
|
|
88
|
+
token,
|
|
89
|
+
...project ? { project } : {},
|
|
90
|
+
apiUrl: options.apiUrl || process.env.BUGWATCH_API_URL || DEFAULT_API_URL
|
|
91
|
+
});
|
|
92
|
+
(result.commitsStatus === "failed" ? logger.warn : logger.info)(`${PREFIX} ${formatCommitResult(result)}`);
|
|
93
|
+
} catch (error) {
|
|
94
|
+
logger.warn(`${PREFIX} The release's commit was not sent: ${error instanceof Error ? error.message : String(error)}`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
77
98
|
if (summary.failed > 0 || summary.notSent > 0) {
|
|
78
99
|
const count = summary.failed + summary.notSent;
|
|
79
100
|
fail(`${count} source map upload${count === 1 ? "" : "s"} failed or not sent; the .map files were kept`);
|