@uxf/scripts 11.53.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 +1 -1
- package/src/GoogleChat.js +21 -5
- package/src/uxf-release/index.js +1 -1
- package/src/uxf-sitemap-check/cli.js +12 -1
- package/src/uxf-sitemap-check/index.js +20 -12
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;
|
|
@@ -348,13 +348,16 @@ async function testNested(urls, parentIndex, parentUrl, label, webUrl) {
|
|
|
348
348
|
}
|
|
349
349
|
}
|
|
350
350
|
|
|
351
|
+
let lastLogTime = 0;
|
|
351
352
|
function printProgress() {
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
353
|
+
const now = Date.now();
|
|
354
|
+
// Only log every 5 seconds in non-TTY
|
|
355
|
+
if (now - lastLogTime > 5000) {
|
|
356
|
+
stdout.write(
|
|
357
|
+
`Progress: ${TESTED_URLS.length}/${URLS_TO_CHECK.size} completed, ${TESTED_URLS.filter((u) => u.skipped).length} skipped, ${TESTED_URLS.filter((u) => u.status !== 200 && u.skipped === false).length} errors\n`,
|
|
358
|
+
);
|
|
359
|
+
lastLogTime = now;
|
|
360
|
+
}
|
|
358
361
|
}
|
|
359
362
|
|
|
360
363
|
/**
|
|
@@ -403,12 +406,16 @@ function logStatistics(okResults, time) {
|
|
|
403
406
|
|
|
404
407
|
/**
|
|
405
408
|
* @param resultErrors {string}
|
|
409
|
+
* @param webhookUrl {string|undefined}
|
|
406
410
|
* @return {Promise<void>}
|
|
407
411
|
*/
|
|
408
|
-
async function sendGoogleChatMessage(resultErrors) {
|
|
409
|
-
await GoogleChat.chatPostMessage(
|
|
410
|
-
|
|
411
|
-
|
|
412
|
+
async function sendGoogleChatMessage(resultErrors, webhookUrl) {
|
|
413
|
+
await GoogleChat.chatPostMessage(
|
|
414
|
+
{
|
|
415
|
+
text: resultErrors,
|
|
416
|
+
},
|
|
417
|
+
{ webhookUrl },
|
|
418
|
+
);
|
|
412
419
|
}
|
|
413
420
|
|
|
414
421
|
/**
|
|
@@ -416,9 +423,10 @@ async function sendGoogleChatMessage(resultErrors) {
|
|
|
416
423
|
* @param skip {number}
|
|
417
424
|
* @param withNested {boolean}
|
|
418
425
|
* @param withImages {boolean}
|
|
426
|
+
* @param googleWebhookUrl {string|undefined}
|
|
419
427
|
* @return {Promise<*>}
|
|
420
428
|
*/
|
|
421
|
-
module.exports = async function run(sitemapUrl, skip, withNested, withImages) {
|
|
429
|
+
module.exports = async function run(sitemapUrl, skip, withNested, withImages, googleWebhookUrl) {
|
|
422
430
|
if (!sitemapUrl) {
|
|
423
431
|
stdout.write("⛔ Required parameter --url is empty.\n");
|
|
424
432
|
return process.exit(1);
|
|
@@ -447,7 +455,7 @@ module.exports = async function run(sitemapUrl, skip, withNested, withImages) {
|
|
|
447
455
|
if (errors.length > 0) {
|
|
448
456
|
const errorText = createErrorResult(errors);
|
|
449
457
|
logErrors(errorText, "\n\n\nErrors:\n");
|
|
450
|
-
await sendGoogleChatMessage(errorText);
|
|
458
|
+
await sendGoogleChatMessage(errorText, googleWebhookUrl);
|
|
451
459
|
}
|
|
452
460
|
|
|
453
461
|
if (skippedUrls.length > 0) {
|