@uxf/scripts 11.58.0 → 11.60.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/package.json
CHANGED
package/src/GoogleChat.js
CHANGED
|
@@ -5,12 +5,18 @@ const axios = create({});
|
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* @see https://developers.google.com/chat/api/reference/rest/v1/cards-v1
|
|
8
|
+
*
|
|
9
|
+
* @param data
|
|
10
|
+
* @param {{dryRun?: boolean|undefined, webhookUrl?: string|undefined}} config
|
|
11
|
+
*
|
|
8
12
|
* @returns {Promise<void>}
|
|
9
13
|
*/
|
|
10
|
-
async function chatPostMessage(data,
|
|
11
|
-
|
|
14
|
+
async function chatPostMessage(data, config = {}) {
|
|
15
|
+
const webhookUrl = config.webhookUrl ?? env.GOOGLE_WEBHOOK_URL;
|
|
16
|
+
|
|
17
|
+
if (webhookUrl && !config.dryRun) {
|
|
12
18
|
try {
|
|
13
|
-
await axios.post(
|
|
19
|
+
await axios.post(webhookUrl, { ...data });
|
|
14
20
|
} catch (error) {
|
|
15
21
|
process.stderr.write("GOOGLE CHAT: chat.postMessage - error");
|
|
16
22
|
console.error(error);
|
|
@@ -20,9 +26,19 @@ async function chatPostMessage(data, dryRun) {
|
|
|
20
26
|
}
|
|
21
27
|
}
|
|
22
28
|
|
|
23
|
-
|
|
29
|
+
/**
|
|
30
|
+
*
|
|
31
|
+
* @param cardsV2
|
|
32
|
+
* @param {{webhookUrl?: string}} config
|
|
33
|
+
* @returns {Promise<axios.AxiosResponse<any>>}
|
|
34
|
+
*/
|
|
35
|
+
async function messageCardsV2(cardsV2, config = {}) {
|
|
24
36
|
return axios
|
|
25
|
-
.post(
|
|
37
|
+
.post(
|
|
38
|
+
config.webhookUrl ?? env.GOOGLE_WEBHOOK_URL,
|
|
39
|
+
{ cardsV2 },
|
|
40
|
+
{ headers: { "Content-Type": "application/json; charset=UTF-8" } },
|
|
41
|
+
)
|
|
26
42
|
.then((r) => r.data);
|
|
27
43
|
}
|
|
28
44
|
|
package/src/uxf-release/index.js
CHANGED
|
@@ -88,7 +88,7 @@ module.exports = async (dryRun, channel, messageTitle) => {
|
|
|
88
88
|
|
|
89
89
|
await Slack.chatPostMessage(channel, { text: generateSlackMessage(commits, messageTitle) }, dryRun);
|
|
90
90
|
|
|
91
|
-
await GoogleChat.chatPostMessage(generateGoogleMessage(commits, messageTitle), dryRun);
|
|
91
|
+
await GoogleChat.chatPostMessage(generateGoogleMessage(commits, messageTitle), { dryRun });
|
|
92
92
|
|
|
93
93
|
await GitLab.createRelease(commits.map(generateReleaseCommitMessage).join("\n"), dryRun);
|
|
94
94
|
};
|
|
@@ -43,6 +43,11 @@ Environment variables:
|
|
|
43
43
|
type: "boolean",
|
|
44
44
|
group: "Options",
|
|
45
45
|
})
|
|
46
|
+
.option("google-chat-webhook-url", {
|
|
47
|
+
describe: "Webhook URL of Google Chat where to send the results.",
|
|
48
|
+
type: "string",
|
|
49
|
+
group: "Options",
|
|
50
|
+
})
|
|
46
51
|
.option("h", { alias: "help", group: "Options" })
|
|
47
52
|
.strict(false)
|
|
48
53
|
.exitProcess(false);
|
|
@@ -60,7 +65,13 @@ Environment variables:
|
|
|
60
65
|
env.HTTP_PASSWORD = options["http-password"];
|
|
61
66
|
}
|
|
62
67
|
|
|
63
|
-
await require("./index")(
|
|
68
|
+
await require("./index")(
|
|
69
|
+
url,
|
|
70
|
+
skip,
|
|
71
|
+
options["with-nested"],
|
|
72
|
+
options["with-images"],
|
|
73
|
+
options["google-chat-webhook-url"],
|
|
74
|
+
);
|
|
64
75
|
} catch (e) {
|
|
65
76
|
console.error(e);
|
|
66
77
|
return 1;
|
|
@@ -406,12 +406,16 @@ function logStatistics(okResults, time) {
|
|
|
406
406
|
|
|
407
407
|
/**
|
|
408
408
|
* @param resultErrors {string}
|
|
409
|
+
* @param webhookUrl {string|undefined}
|
|
409
410
|
* @return {Promise<void>}
|
|
410
411
|
*/
|
|
411
|
-
async function sendGoogleChatMessage(resultErrors) {
|
|
412
|
-
await GoogleChat.chatPostMessage(
|
|
413
|
-
|
|
414
|
-
|
|
412
|
+
async function sendGoogleChatMessage(resultErrors, webhookUrl) {
|
|
413
|
+
await GoogleChat.chatPostMessage(
|
|
414
|
+
{
|
|
415
|
+
text: resultErrors,
|
|
416
|
+
},
|
|
417
|
+
{ webhookUrl },
|
|
418
|
+
);
|
|
415
419
|
}
|
|
416
420
|
|
|
417
421
|
/**
|
|
@@ -419,9 +423,10 @@ async function sendGoogleChatMessage(resultErrors) {
|
|
|
419
423
|
* @param skip {number}
|
|
420
424
|
* @param withNested {boolean}
|
|
421
425
|
* @param withImages {boolean}
|
|
426
|
+
* @param googleWebhookUrl {string|undefined}
|
|
422
427
|
* @return {Promise<*>}
|
|
423
428
|
*/
|
|
424
|
-
module.exports = async function run(sitemapUrl, skip, withNested, withImages) {
|
|
429
|
+
module.exports = async function run(sitemapUrl, skip, withNested, withImages, googleWebhookUrl) {
|
|
425
430
|
if (!sitemapUrl) {
|
|
426
431
|
stdout.write("⛔ Required parameter --url is empty.\n");
|
|
427
432
|
return process.exit(1);
|
|
@@ -450,7 +455,7 @@ module.exports = async function run(sitemapUrl, skip, withNested, withImages) {
|
|
|
450
455
|
if (errors.length > 0) {
|
|
451
456
|
const errorText = createErrorResult(errors);
|
|
452
457
|
logErrors(errorText, "\n\n\nErrors:\n");
|
|
453
|
-
await sendGoogleChatMessage(errorText);
|
|
458
|
+
await sendGoogleChatMessage(errorText, googleWebhookUrl);
|
|
454
459
|
}
|
|
455
460
|
|
|
456
461
|
if (skippedUrls.length > 0) {
|