@ubiquity-os/plugin-sdk 3.1.9 → 3.1.11
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.d.mts +6 -5
- package/dist/index.d.ts +6 -5
- package/dist/index.js +17 -11
- package/dist/index.mjs +17 -11
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -52,7 +52,7 @@ declare class CommentHandler {
|
|
|
52
52
|
_getIssueNumber(context: Context): number | undefined;
|
|
53
53
|
_getCommentId(context: Context): number | undefined;
|
|
54
54
|
_extractIssueContext(context: Context): IssueContext | null;
|
|
55
|
-
_processMessage(context: Context, message: LogReturn | Error):
|
|
55
|
+
_processMessage(context: Context, message: LogReturn | Error): {
|
|
56
56
|
metadata: {
|
|
57
57
|
message: string;
|
|
58
58
|
name: string;
|
|
@@ -88,14 +88,15 @@ declare class CommentHandler {
|
|
|
88
88
|
level: _ubiquity_os_ubiquity_os_logger.LogLevel;
|
|
89
89
|
type: _ubiquity_os_ubiquity_os_logger.LogLevelWithOk;
|
|
90
90
|
};
|
|
91
|
-
}
|
|
91
|
+
};
|
|
92
92
|
_getInstigatorName(context: Context): string;
|
|
93
|
-
_createMetadataContent(context: Context, metadata: Metadata):
|
|
93
|
+
_createMetadataContent(context: Context, metadata: Metadata): {
|
|
94
94
|
header: string;
|
|
95
95
|
jsonPretty: string;
|
|
96
|
-
}
|
|
96
|
+
};
|
|
97
97
|
_formatMetadataContent(logMessage: LogReturn["logMessage"], header: string, jsonPretty: string): string;
|
|
98
|
-
|
|
98
|
+
createCommentBody(context: Context, message: LogReturn | Error, options?: Pick<CommentOptions, "raw">): string;
|
|
99
|
+
private _createCommentBody;
|
|
99
100
|
postComment(context: Context, message: LogReturn | Error, options?: CommentOptions): Promise<WithIssueNumber<PostedGithubComment> | null>;
|
|
100
101
|
}
|
|
101
102
|
|
package/dist/index.d.ts
CHANGED
|
@@ -52,7 +52,7 @@ declare class CommentHandler {
|
|
|
52
52
|
_getIssueNumber(context: Context): number | undefined;
|
|
53
53
|
_getCommentId(context: Context): number | undefined;
|
|
54
54
|
_extractIssueContext(context: Context): IssueContext | null;
|
|
55
|
-
_processMessage(context: Context, message: LogReturn | Error):
|
|
55
|
+
_processMessage(context: Context, message: LogReturn | Error): {
|
|
56
56
|
metadata: {
|
|
57
57
|
message: string;
|
|
58
58
|
name: string;
|
|
@@ -88,14 +88,15 @@ declare class CommentHandler {
|
|
|
88
88
|
level: _ubiquity_os_ubiquity_os_logger.LogLevel;
|
|
89
89
|
type: _ubiquity_os_ubiquity_os_logger.LogLevelWithOk;
|
|
90
90
|
};
|
|
91
|
-
}
|
|
91
|
+
};
|
|
92
92
|
_getInstigatorName(context: Context): string;
|
|
93
|
-
_createMetadataContent(context: Context, metadata: Metadata):
|
|
93
|
+
_createMetadataContent(context: Context, metadata: Metadata): {
|
|
94
94
|
header: string;
|
|
95
95
|
jsonPretty: string;
|
|
96
|
-
}
|
|
96
|
+
};
|
|
97
97
|
_formatMetadataContent(logMessage: LogReturn["logMessage"], header: string, jsonPretty: string): string;
|
|
98
|
-
|
|
98
|
+
createCommentBody(context: Context, message: LogReturn | Error, options?: Pick<CommentOptions, "raw">): string;
|
|
99
|
+
private _createCommentBody;
|
|
99
100
|
postComment(context: Context, message: LogReturn | Error, options?: CommentOptions): Promise<WithIssueNumber<PostedGithubComment> | null>;
|
|
100
101
|
}
|
|
101
102
|
|
package/dist/index.js
CHANGED
|
@@ -76,7 +76,7 @@ var PluginRuntimeInfo = class _PluginRuntimeInfo {
|
|
|
76
76
|
};
|
|
77
77
|
var CfRuntimeInfo = class extends PluginRuntimeInfo {
|
|
78
78
|
get version() {
|
|
79
|
-
return
|
|
79
|
+
return this._env.CLOUDFLARE_VERSION_METADATA?.id ?? "CLOUDFLARE_VERSION_METADATA";
|
|
80
80
|
}
|
|
81
81
|
get runUrl() {
|
|
82
82
|
const accountId = this._env.CLOUDFLARE_ACCOUNT_ID ?? "<missing-cloudflare-account-id>";
|
|
@@ -89,7 +89,7 @@ var CfRuntimeInfo = class extends PluginRuntimeInfo {
|
|
|
89
89
|
};
|
|
90
90
|
var NodeRuntimeInfo = class extends PluginRuntimeInfo {
|
|
91
91
|
get version() {
|
|
92
|
-
return
|
|
92
|
+
return import_github.default.context.sha;
|
|
93
93
|
}
|
|
94
94
|
get runUrl() {
|
|
95
95
|
return import_github.default.context.payload.repository ? `${import_github.default.context.payload.repository?.html_url}/actions/runs/${import_github.default.context.runId}` : "http://localhost";
|
|
@@ -97,7 +97,7 @@ var NodeRuntimeInfo = class extends PluginRuntimeInfo {
|
|
|
97
97
|
};
|
|
98
98
|
var DenoRuntimeInfo = class extends PluginRuntimeInfo {
|
|
99
99
|
get version() {
|
|
100
|
-
return
|
|
100
|
+
return Deno.env.get("DENO_DEPLOYMENT_ID");
|
|
101
101
|
}
|
|
102
102
|
get runUrl() {
|
|
103
103
|
const projectName = Deno.env.get("DENO_PROJECT_NAME");
|
|
@@ -235,7 +235,7 @@ var CommentHandler = class _CommentHandler {
|
|
|
235
235
|
repo: context2.payload.repository.name
|
|
236
236
|
};
|
|
237
237
|
}
|
|
238
|
-
|
|
238
|
+
_processMessage(context2, message) {
|
|
239
239
|
if (message instanceof Error) {
|
|
240
240
|
const metadata2 = {
|
|
241
241
|
message: message.message,
|
|
@@ -258,11 +258,11 @@ var CommentHandler = class _CommentHandler {
|
|
|
258
258
|
}
|
|
259
259
|
return context2.payload.sender?.login || _CommentHandler.HEADER_NAME;
|
|
260
260
|
}
|
|
261
|
-
|
|
261
|
+
_createMetadataContent(context2, metadata) {
|
|
262
262
|
const jsonPretty = sanitizeMetadata(metadata);
|
|
263
263
|
const instigatorName = this._getInstigatorName(context2);
|
|
264
264
|
const runUrl = PluginRuntimeInfo.getInstance().runUrl;
|
|
265
|
-
const version =
|
|
265
|
+
const version = PluginRuntimeInfo.getInstance().version;
|
|
266
266
|
const callingFnName = metadata.caller || "anonymous";
|
|
267
267
|
return {
|
|
268
268
|
header: `<!-- ${_CommentHandler.HEADER_NAME} - ${callingFnName} - ${version} - @${instigatorName} - ${runUrl}`,
|
|
@@ -274,11 +274,17 @@ var CommentHandler = class _CommentHandler {
|
|
|
274
274
|
const metadataHidden = [header, jsonPretty, "-->"].join("\n");
|
|
275
275
|
return logMessage?.type === "fatal" ? [metadataVisible, metadataHidden].join("\n") : metadataHidden;
|
|
276
276
|
}
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
277
|
+
/*
|
|
278
|
+
* Creates the body for the comment, embeds the metadata and the header hidden in the body as well.
|
|
279
|
+
*/
|
|
280
|
+
createCommentBody(context2, message, options) {
|
|
281
|
+
return this._createCommentBody(context2, message, options);
|
|
282
|
+
}
|
|
283
|
+
_createCommentBody(context2, message, options) {
|
|
284
|
+
const { metadata, logMessage } = this._processMessage(context2, message);
|
|
285
|
+
const { header, jsonPretty } = this._createMetadataContent(context2, metadata);
|
|
280
286
|
const metadataContent = this._formatMetadataContent(logMessage, header, jsonPretty);
|
|
281
|
-
return `${options
|
|
287
|
+
return `${options?.raw ? logMessage?.raw : logMessage?.diff}
|
|
282
288
|
|
|
283
289
|
${metadataContent}
|
|
284
290
|
`;
|
|
@@ -289,7 +295,7 @@ ${metadataContent}
|
|
|
289
295
|
context2.logger.info("Cannot post comment: missing issue context in payload");
|
|
290
296
|
return null;
|
|
291
297
|
}
|
|
292
|
-
const body =
|
|
298
|
+
const body = this._createCommentBody(context2, message, options);
|
|
293
299
|
const { issueNumber, commentId, owner, repo } = issueContext;
|
|
294
300
|
const params = { owner, repo, body, issueNumber };
|
|
295
301
|
if (options.updateComment) {
|
package/dist/index.mjs
CHANGED
|
@@ -38,7 +38,7 @@ var PluginRuntimeInfo = class _PluginRuntimeInfo {
|
|
|
38
38
|
};
|
|
39
39
|
var CfRuntimeInfo = class extends PluginRuntimeInfo {
|
|
40
40
|
get version() {
|
|
41
|
-
return
|
|
41
|
+
return this._env.CLOUDFLARE_VERSION_METADATA?.id ?? "CLOUDFLARE_VERSION_METADATA";
|
|
42
42
|
}
|
|
43
43
|
get runUrl() {
|
|
44
44
|
const accountId = this._env.CLOUDFLARE_ACCOUNT_ID ?? "<missing-cloudflare-account-id>";
|
|
@@ -51,7 +51,7 @@ var CfRuntimeInfo = class extends PluginRuntimeInfo {
|
|
|
51
51
|
};
|
|
52
52
|
var NodeRuntimeInfo = class extends PluginRuntimeInfo {
|
|
53
53
|
get version() {
|
|
54
|
-
return
|
|
54
|
+
return github.context.sha;
|
|
55
55
|
}
|
|
56
56
|
get runUrl() {
|
|
57
57
|
return github.context.payload.repository ? `${github.context.payload.repository?.html_url}/actions/runs/${github.context.runId}` : "http://localhost";
|
|
@@ -59,7 +59,7 @@ var NodeRuntimeInfo = class extends PluginRuntimeInfo {
|
|
|
59
59
|
};
|
|
60
60
|
var DenoRuntimeInfo = class extends PluginRuntimeInfo {
|
|
61
61
|
get version() {
|
|
62
|
-
return
|
|
62
|
+
return Deno.env.get("DENO_DEPLOYMENT_ID");
|
|
63
63
|
}
|
|
64
64
|
get runUrl() {
|
|
65
65
|
const projectName = Deno.env.get("DENO_PROJECT_NAME");
|
|
@@ -197,7 +197,7 @@ var CommentHandler = class _CommentHandler {
|
|
|
197
197
|
repo: context2.payload.repository.name
|
|
198
198
|
};
|
|
199
199
|
}
|
|
200
|
-
|
|
200
|
+
_processMessage(context2, message) {
|
|
201
201
|
if (message instanceof Error) {
|
|
202
202
|
const metadata2 = {
|
|
203
203
|
message: message.message,
|
|
@@ -220,11 +220,11 @@ var CommentHandler = class _CommentHandler {
|
|
|
220
220
|
}
|
|
221
221
|
return context2.payload.sender?.login || _CommentHandler.HEADER_NAME;
|
|
222
222
|
}
|
|
223
|
-
|
|
223
|
+
_createMetadataContent(context2, metadata) {
|
|
224
224
|
const jsonPretty = sanitizeMetadata(metadata);
|
|
225
225
|
const instigatorName = this._getInstigatorName(context2);
|
|
226
226
|
const runUrl = PluginRuntimeInfo.getInstance().runUrl;
|
|
227
|
-
const version =
|
|
227
|
+
const version = PluginRuntimeInfo.getInstance().version;
|
|
228
228
|
const callingFnName = metadata.caller || "anonymous";
|
|
229
229
|
return {
|
|
230
230
|
header: `<!-- ${_CommentHandler.HEADER_NAME} - ${callingFnName} - ${version} - @${instigatorName} - ${runUrl}`,
|
|
@@ -236,11 +236,17 @@ var CommentHandler = class _CommentHandler {
|
|
|
236
236
|
const metadataHidden = [header, jsonPretty, "-->"].join("\n");
|
|
237
237
|
return logMessage?.type === "fatal" ? [metadataVisible, metadataHidden].join("\n") : metadataHidden;
|
|
238
238
|
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
239
|
+
/*
|
|
240
|
+
* Creates the body for the comment, embeds the metadata and the header hidden in the body as well.
|
|
241
|
+
*/
|
|
242
|
+
createCommentBody(context2, message, options) {
|
|
243
|
+
return this._createCommentBody(context2, message, options);
|
|
244
|
+
}
|
|
245
|
+
_createCommentBody(context2, message, options) {
|
|
246
|
+
const { metadata, logMessage } = this._processMessage(context2, message);
|
|
247
|
+
const { header, jsonPretty } = this._createMetadataContent(context2, metadata);
|
|
242
248
|
const metadataContent = this._formatMetadataContent(logMessage, header, jsonPretty);
|
|
243
|
-
return `${options
|
|
249
|
+
return `${options?.raw ? logMessage?.raw : logMessage?.diff}
|
|
244
250
|
|
|
245
251
|
${metadataContent}
|
|
246
252
|
`;
|
|
@@ -251,7 +257,7 @@ ${metadataContent}
|
|
|
251
257
|
context2.logger.info("Cannot post comment: missing issue context in payload");
|
|
252
258
|
return null;
|
|
253
259
|
}
|
|
254
|
-
const body =
|
|
260
|
+
const body = this._createCommentBody(context2, message, options);
|
|
255
261
|
const { issueNumber, commentId, owner, repo } = issueContext;
|
|
256
262
|
const params = { owner, repo, body, issueNumber };
|
|
257
263
|
if (options.updateComment) {
|