bugwatch-cli 0.1.0 → 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/README.md +2 -1
- package/dist/{chunk-J4RLBS7A.js → chunk-6YRBKOB7.js} +3 -3
- package/dist/{chunk-FITJFXB5.js → chunk-NWO6RFO7.js} +13 -4
- package/dist/cli.js +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/main.js +2 -2
- package/dist/vite.d.ts +6 -2
- package/dist/vite.js +16 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -46,7 +46,8 @@ export default defineConfig({
|
|
|
46
46
|
build: { sourcemap: "hidden" },
|
|
47
47
|
plugins: [
|
|
48
48
|
bugwatchSourcemaps({
|
|
49
|
-
|
|
49
|
+
// e.g. the git SHA or package version, set by CI; without it, nothing is uploaded
|
|
50
|
+
release: process.env.RELEASE ?? "",
|
|
50
51
|
}),
|
|
51
52
|
],
|
|
52
53
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/version.ts
|
|
2
|
-
var VERSION = "0.1.
|
|
2
|
+
var VERSION = "0.1.1";
|
|
3
3
|
|
|
4
4
|
// src/upload.ts
|
|
5
5
|
import { readdir, readFile, stat, unlink } from "fs/promises";
|
|
@@ -18,7 +18,7 @@ var UsageError = class extends Error {
|
|
|
18
18
|
}
|
|
19
19
|
};
|
|
20
20
|
function releaseProblem(release) {
|
|
21
|
-
if (!release) return "A release is required
|
|
21
|
+
if (!release) return "A release is required";
|
|
22
22
|
if (release.length > 200) return "The release must be at most 200 characters";
|
|
23
23
|
if (/[\s\u0000-\u001f\u007f]/.test(release)) return "The release must not contain spaces or control characters";
|
|
24
24
|
if (release === "." || release === "..") return 'The release must not be "." or ".."';
|
|
@@ -135,7 +135,7 @@ async function uploadSourceMaps(options) {
|
|
|
135
135
|
if (prefixError) throw new UsageError(prefixError);
|
|
136
136
|
if (!/^https?:\/\//.test(apiUrl)) throw new UsageError("The API URL must start with http:// or https://");
|
|
137
137
|
if (!options.dryRun && !options.token) {
|
|
138
|
-
throw new UsageError("An upload token is required: set BUGWATCH_UPLOAD_TOKEN
|
|
138
|
+
throw new UsageError("An upload token is required: set BUGWATCH_UPLOAD_TOKEN");
|
|
139
139
|
}
|
|
140
140
|
const dir = resolve(options.dir);
|
|
141
141
|
try {
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
UsageError,
|
|
9
9
|
VERSION,
|
|
10
10
|
uploadSourceMaps
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-6YRBKOB7.js";
|
|
12
12
|
|
|
13
13
|
// src/main.ts
|
|
14
14
|
import { parseArgs } from "util";
|
|
@@ -69,11 +69,20 @@ ${USAGE}`);
|
|
|
69
69
|
}
|
|
70
70
|
const dryRun = values["dry-run"] === true;
|
|
71
71
|
const apiUrl = values["api-url"] || env.BUGWATCH_API_URL || DEFAULT_API_URL;
|
|
72
|
+
const token = values.token || env.BUGWATCH_UPLOAD_TOKEN || void 0;
|
|
73
|
+
if (!values.release) {
|
|
74
|
+
err("Error: A release is required (--release)");
|
|
75
|
+
return 2;
|
|
76
|
+
}
|
|
77
|
+
if (!dryRun && !token) {
|
|
78
|
+
err("Error: An upload token is required: set BUGWATCH_UPLOAD_TOKEN (or pass --token)");
|
|
79
|
+
return 2;
|
|
80
|
+
}
|
|
72
81
|
try {
|
|
73
82
|
const { results, summary } = await uploadSourceMaps({
|
|
74
83
|
dir,
|
|
75
|
-
release: values.release
|
|
76
|
-
token
|
|
84
|
+
release: values.release,
|
|
85
|
+
token,
|
|
77
86
|
urlPrefix: values["url-prefix"] ?? DEFAULT_URL_PREFIX,
|
|
78
87
|
apiUrl,
|
|
79
88
|
deleteAfterUpload: values["delete-after-upload"] === true,
|
|
@@ -82,7 +91,7 @@ ${USAGE}`);
|
|
|
82
91
|
onRetry: ({ file, attempt, delayMs, reason }) => err(`retry ${file} (attempt ${attempt + 1}, in ${Math.round(delayMs / 100) / 10} s): ${reason}`)
|
|
83
92
|
});
|
|
84
93
|
out("");
|
|
85
|
-
out(formatSummary(summary, { dryRun, release: values.release
|
|
94
|
+
out(formatSummary(summary, { dryRun, release: values.release, files: results.length }));
|
|
86
95
|
if (summary.failed > 0 && values["delete-after-upload"]) {
|
|
87
96
|
out("Kept the local .map files because an upload failed.");
|
|
88
97
|
}
|
package/dist/cli.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
main
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-NWO6RFO7.js";
|
|
5
5
|
import "./chunk-QGLOKEF7.js";
|
|
6
|
-
import "./chunk-
|
|
6
|
+
import "./chunk-6YRBKOB7.js";
|
|
7
7
|
|
|
8
8
|
// src/cli.ts
|
|
9
9
|
main(process.argv.slice(2)).then((code) => {
|
package/dist/index.d.ts
CHANGED
|
@@ -78,6 +78,6 @@ declare function findSourceMaps(dir: string): Promise<string[]>;
|
|
|
78
78
|
declare function uploadSourceMaps(options: UploadOptions): Promise<UploadReport>;
|
|
79
79
|
|
|
80
80
|
/** Keep in sync with package.json (a test checks it). */
|
|
81
|
-
declare const VERSION = "0.1.
|
|
81
|
+
declare const VERSION = "0.1.1";
|
|
82
82
|
|
|
83
83
|
export { CONCURRENCY, DEFAULT_API_URL, DEFAULT_URL_PREFIX, type FileResult, MAX_MAP_BYTES, MAX_RETRIES, type Outcome, type UploadOptions, type UploadReport, type UploadSummary, UsageError, VERSION, findSourceMaps, mapName, releaseProblem, uploadSourceMaps, urlPrefixProblem };
|
package/dist/index.js
CHANGED
package/dist/main.js
CHANGED
package/dist/vite.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
interface BugwatchSourcemapsOptions {
|
|
2
|
-
/**
|
|
3
|
-
|
|
2
|
+
/**
|
|
3
|
+
* The release the SDK sends (`Bugwatch.init({ release })`). Required, but
|
|
4
|
+
* may be `undefined` so `release: process.env.RELEASE` type-checks: then
|
|
5
|
+
* nothing is uploaded and the build logs why (or fails with `failOnError`).
|
|
6
|
+
*/
|
|
7
|
+
release: string | undefined;
|
|
4
8
|
/** Upload token. Default: the `BUGWATCH_UPLOAD_TOKEN` environment variable. */
|
|
5
9
|
token?: string;
|
|
6
10
|
/** Default `~/` (any host). */
|
package/dist/vite.js
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
DEFAULT_URL_PREFIX,
|
|
7
7
|
UsageError,
|
|
8
8
|
uploadSourceMaps
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-6YRBKOB7.js";
|
|
10
10
|
|
|
11
11
|
// src/vite.ts
|
|
12
12
|
import { resolve } from "path";
|
|
@@ -35,18 +35,30 @@ function bugwatchSourcemaps(options) {
|
|
|
35
35
|
if (failOnError) throw new Error(`${PREFIX} ${message}`);
|
|
36
36
|
logger.error(`${PREFIX} ${message}`);
|
|
37
37
|
};
|
|
38
|
+
const release = options.release;
|
|
39
|
+
const token = options.token || process.env.BUGWATCH_UPLOAD_TOKEN || void 0;
|
|
40
|
+
if (!release) {
|
|
41
|
+
fail(
|
|
42
|
+
"Source maps not uploaded: no release. Pass release to bugwatchSourcemaps() (e.g. release: process.env.RELEASE) and set it in CI"
|
|
43
|
+
);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (!token) {
|
|
47
|
+
fail("Source maps not uploaded: no upload token. Set BUGWATCH_UPLOAD_TOKEN or the token option");
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
38
50
|
try {
|
|
39
51
|
const { results, summary } = await uploadSourceMaps({
|
|
40
52
|
dir: resolve(config.root, build.outDir),
|
|
41
|
-
release
|
|
42
|
-
token
|
|
53
|
+
release,
|
|
54
|
+
token,
|
|
43
55
|
urlPrefix: options.urlPrefix ?? DEFAULT_URL_PREFIX,
|
|
44
56
|
apiUrl: options.apiUrl || process.env.BUGWATCH_API_URL || void 0,
|
|
45
57
|
deleteAfterUpload: options.deleteAfterUpload ?? true,
|
|
46
58
|
onResult: (result) => (result.outcome === "failed" ? logger.error : logger.info)(`${PREFIX} ${formatResult(result)}`),
|
|
47
59
|
onRetry: ({ file, attempt, reason }) => logger.warn(`${PREFIX} retry ${file} (attempt ${attempt + 1}): ${reason}`)
|
|
48
60
|
});
|
|
49
|
-
logger.info(`${PREFIX} ${formatSummary(summary, { dryRun: false, release
|
|
61
|
+
logger.info(`${PREFIX} ${formatSummary(summary, { dryRun: false, release, files: results.length })}`);
|
|
50
62
|
if (summary.failed > 0) {
|
|
51
63
|
fail(`${summary.failed} source map upload${summary.failed === 1 ? "" : "s"} failed; the .map files were kept`);
|
|
52
64
|
}
|