@tourmind-frontend/monitor-plugin-webpack 1.0.5 → 1.1.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/dist/index.cjs +3 -7
- package/dist/index.d.ts +2 -5
- package/dist/index.js +3 -7
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -82,8 +82,7 @@ async function uploadFiles({ url, query, files }) {
|
|
|
82
82
|
var UploadSourceMapPlugin = class {
|
|
83
83
|
constructor(options) {
|
|
84
84
|
if (!(options == null ? void 0 : options.url)) throw new Error(`${LOG_PREFIX} "url" is required`);
|
|
85
|
-
if (!options.
|
|
86
|
-
if (!options.branch) throw new Error(`${LOG_PREFIX} "branch" is required`);
|
|
85
|
+
if (!options.token) throw new Error(`${LOG_PREFIX} "token" is required`);
|
|
87
86
|
this.options = options;
|
|
88
87
|
}
|
|
89
88
|
apply(compiler) {
|
|
@@ -103,14 +102,11 @@ var UploadSourceMapPlugin = class {
|
|
|
103
102
|
const commit = (_a2 = options.commit) != null ? _a2 : "";
|
|
104
103
|
const timestamp = (_b = options.timestamp) != null ? _b : Date.now();
|
|
105
104
|
const query = {
|
|
106
|
-
|
|
107
|
-
branch: options.branch,
|
|
105
|
+
token: options.token,
|
|
108
106
|
timestamp: String(timestamp)
|
|
109
107
|
};
|
|
110
108
|
if (commit) query.commit = commit;
|
|
111
|
-
uploadPromise = uploadFiles({ url: options.url, query, files }).then(
|
|
112
|
-
() => log("info", `uploaded ${files.length} sourcemap file(s) (branch=${options.branch}, commit=${commit || "-"})`)
|
|
113
|
-
).catch((err) => log("error", "upload failed", err instanceof Error ? err.message : err));
|
|
109
|
+
uploadPromise = uploadFiles({ url: options.url, query, files }).then(() => log("info", `uploaded ${files.length} sourcemap file(s) (commit=${commit || "-"})`)).catch((err) => log("error", "upload failed", err instanceof Error ? err.message : err));
|
|
114
110
|
});
|
|
115
111
|
compiler.hooks.done.tapPromise("UploadSourceMapPlugin", async () => {
|
|
116
112
|
if (uploadPromise) await uploadPromise;
|
package/dist/index.d.ts
CHANGED
|
@@ -2,11 +2,8 @@ import { Compiler } from "webpack";
|
|
|
2
2
|
export interface UploadSourceMapOptions {
|
|
3
3
|
/** 上传接口地址,例如 `https://monitor.example.com/api/upload`。 */
|
|
4
4
|
url: string;
|
|
5
|
-
/**
|
|
6
|
-
|
|
7
|
-
/** 分支名,必填,由调用方自行解析(如 `git rev-parse --abbrev-ref HEAD`)。
|
|
8
|
-
* 服务端使用此字段标识来源;主分支(`main` / `master`)等同于"生产环境"。 */
|
|
9
|
-
branch: string;
|
|
5
|
+
/** monitor 项目 token,从 web 控制台创建项目后获取,内部已绑定仓库 + 分支。 */
|
|
6
|
+
token: string;
|
|
10
7
|
/** Commit hash,由调用方自行解析(如 `git rev-parse HEAD`)。 */
|
|
11
8
|
commit?: string;
|
|
12
9
|
/** 构建时间戳(毫秒),未设置时取上传时刻的 `Date.now()`。 */
|
package/dist/index.js
CHANGED
|
@@ -48,8 +48,7 @@ async function uploadFiles({ url, query, files }) {
|
|
|
48
48
|
var UploadSourceMapPlugin = class {
|
|
49
49
|
constructor(options) {
|
|
50
50
|
if (!(options == null ? void 0 : options.url)) throw new Error(`${LOG_PREFIX} "url" is required`);
|
|
51
|
-
if (!options.
|
|
52
|
-
if (!options.branch) throw new Error(`${LOG_PREFIX} "branch" is required`);
|
|
51
|
+
if (!options.token) throw new Error(`${LOG_PREFIX} "token" is required`);
|
|
53
52
|
this.options = options;
|
|
54
53
|
}
|
|
55
54
|
apply(compiler) {
|
|
@@ -69,14 +68,11 @@ var UploadSourceMapPlugin = class {
|
|
|
69
68
|
const commit = (_a2 = options.commit) != null ? _a2 : "";
|
|
70
69
|
const timestamp = (_b = options.timestamp) != null ? _b : Date.now();
|
|
71
70
|
const query = {
|
|
72
|
-
|
|
73
|
-
branch: options.branch,
|
|
71
|
+
token: options.token,
|
|
74
72
|
timestamp: String(timestamp)
|
|
75
73
|
};
|
|
76
74
|
if (commit) query.commit = commit;
|
|
77
|
-
uploadPromise = uploadFiles({ url: options.url, query, files }).then(
|
|
78
|
-
() => log("info", `uploaded ${files.length} sourcemap file(s) (branch=${options.branch}, commit=${commit || "-"})`)
|
|
79
|
-
).catch((err) => log("error", "upload failed", err instanceof Error ? err.message : err));
|
|
75
|
+
uploadPromise = uploadFiles({ url: options.url, query, files }).then(() => log("info", `uploaded ${files.length} sourcemap file(s) (commit=${commit || "-"})`)).catch((err) => log("error", "upload failed", err instanceof Error ? err.message : err));
|
|
80
76
|
});
|
|
81
77
|
compiler.hooks.done.tapPromise("UploadSourceMapPlugin", async () => {
|
|
82
78
|
if (uploadPromise) await uploadPromise;
|
package/package.json
CHANGED