@uxf/scripts 1.5.4 → 1.5.5
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/Makefile +1 -1
- package/package.json +1 -1
- package/src/GoogleChat.js +20 -0
- package/src/uxf-release/index.js +21 -0
- package/src/uxf-sitemap-check/index.js +16 -3
package/Makefile
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
uxf-release:
|
|
2
|
-
CI_SERVER_URL=https://gitlab.uxf.cz GITLAB_TOKEN= SLACK_TOKEN=xoxb- ./bin/uxf-release.js --slack-channel=C01NQK3LY9Z --project-id=156 --message=":beer: Kalkulator.cz"
|
|
2
|
+
CI_SERVER_URL=https://gitlab.uxf.cz GITLAB_TOKEN= SLACK_TOKEN=xoxb- GOOGLE_WEBHOOK_URL="https://chat.googleapis.com/v1/spaces/AAAAREmdmUk/messages?key=AIzaSyDdI0hCZtE6vySjMm-WEfRq3CPzqKqqsHI&token=Id5HWMI4jMIp2JZx0kK4eJCiKmLUjUJuxpZtpqGqjfY%3D" ./bin/uxf-release.js --slack-channel=C01NQK3LY9Z --project-id=156 --message=":beer-mug: Kalkulator.cz"
|
package/package.json
CHANGED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const { env } = require("process");
|
|
2
|
+
const { create } = require("axios");
|
|
3
|
+
|
|
4
|
+
const axios = create({});
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @see https://developers.google.com/chat/api/reference/rest/v1/cards-v1
|
|
8
|
+
* @returns {Promise<void>}
|
|
9
|
+
*/
|
|
10
|
+
async function chatPostMessage(data, dryRun) {
|
|
11
|
+
if (env.GOOGLE_WEBHOOK_URL && !dryRun) {
|
|
12
|
+
await axios.post(env.GOOGLE_WEBHOOK_URL, { ...data });
|
|
13
|
+
} else {
|
|
14
|
+
process.stdout.write("GOOGLE CHAT: chat.postMessage - skipped");
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
module.exports = {
|
|
19
|
+
chatPostMessage,
|
|
20
|
+
};
|
package/src/uxf-release/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const GitLab = require("../GitLab");
|
|
2
2
|
const Slack = require("../Slack");
|
|
3
|
+
const GoogleChat = require("../GoogleChat");
|
|
3
4
|
|
|
4
5
|
function addCommitsToIssues(commits, issues) {
|
|
5
6
|
issues.forEach(issue => {
|
|
@@ -41,6 +42,21 @@ function generateSlackMessage(issues, commitsWithoutIssues, messageTitle) {
|
|
|
41
42
|
return message;
|
|
42
43
|
}
|
|
43
44
|
|
|
45
|
+
function generateGoogleMessage(issues, commitsWithoutIssues, messageTitle) {
|
|
46
|
+
const texts = [messageTitle];
|
|
47
|
+
issues.forEach(issue => {
|
|
48
|
+
texts.push(`*${issue.title}* <${issue.web_url}|#${issue.iid}>`);
|
|
49
|
+
issue.commits.forEach((commit) => texts.push(generateSlackCommitMessage(commit)));
|
|
50
|
+
});
|
|
51
|
+
if (commitsWithoutIssues.length > 0) {
|
|
52
|
+
texts.push(`*Commity bez issue*`);
|
|
53
|
+
commitsWithoutIssues.forEach((commit) => texts.push(generateSlackCommitMessage(commit)));
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
text: texts.join('\n')
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
44
60
|
function generateSlackCommitMessage(commit) {
|
|
45
61
|
const { title, parsedTitle, short_id, web_url, author_email } = commit;
|
|
46
62
|
|
|
@@ -74,5 +90,10 @@ module.exports = async (dryRun, channel, messageTitle) => {
|
|
|
74
90
|
dryRun,
|
|
75
91
|
);
|
|
76
92
|
|
|
93
|
+
await GoogleChat.chatPostMessage(
|
|
94
|
+
generateGoogleMessage(issues, commitsWithoutIssue, messageTitle),
|
|
95
|
+
dryRun,
|
|
96
|
+
);
|
|
97
|
+
|
|
77
98
|
await GitLab.createRelease(commits.map(generateCommitMessage).join("\n"), dryRun);
|
|
78
99
|
};
|
|
@@ -4,6 +4,7 @@ const { performance } = require("perf_hooks");
|
|
|
4
4
|
const { env, stdout } = require("process");
|
|
5
5
|
const { axios } = require("../Sitemap");
|
|
6
6
|
const cheerio = require("cheerio");
|
|
7
|
+
const GoogleChat = require("../GoogleChat");
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
*
|
|
@@ -170,9 +171,11 @@ async function testSitemapUrls(urls, webUrl, sitemapUrl, skip, testNested) {
|
|
|
170
171
|
const changedUrl = webUrl ? `${webUrl}${new URL(url).pathname}` : null;
|
|
171
172
|
|
|
172
173
|
printUrlInfo(changedUrl ?? url, i, urls.length);
|
|
173
|
-
printUrlResult(await testUrl(changedUrl ?? url));
|
|
174
174
|
|
|
175
|
-
|
|
175
|
+
const result = await testUrl(changedUrl ?? url);
|
|
176
|
+
printUrlResult(result);
|
|
177
|
+
|
|
178
|
+
if (testNested && result.status === 200) {
|
|
176
179
|
await testAllNestedUrls(changedUrl ?? url, i, webUrl ?? sitemapUrl.split("/").slice(0, 3).join("/"));
|
|
177
180
|
}
|
|
178
181
|
}
|
|
@@ -309,6 +312,15 @@ async function sendSlackMessage(errorText, slackChannel) {
|
|
|
309
312
|
});
|
|
310
313
|
}
|
|
311
314
|
|
|
315
|
+
/**
|
|
316
|
+
* @return {Promise<void>}
|
|
317
|
+
*/
|
|
318
|
+
async function sendGoogleChatMessage(resultErrors) {
|
|
319
|
+
await GoogleChat.chatPostMessage({
|
|
320
|
+
text: "*Odkazy uvedené v sitemap.xml nejsou dostupné*\n" + resultErrors.map(r => `${r.url} ${r.status}`).join('\n')
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
|
|
312
324
|
/**
|
|
313
325
|
*
|
|
314
326
|
* @param sitemapUrl {string}
|
|
@@ -335,7 +347,7 @@ module.exports = async function run(sitemapUrl, webUrl, slackChannel, skip, test
|
|
|
335
347
|
}
|
|
336
348
|
|
|
337
349
|
const startTime = performance.now();
|
|
338
|
-
await testSitemapUrls(await Sitemap.getSitemap(sitemapUrl), webUrl, sitemapUrl, skip, testNested);
|
|
350
|
+
await testSitemapUrls((await Sitemap.getSitemap(sitemapUrl)), webUrl, sitemapUrl, skip, testNested);
|
|
339
351
|
const finishTime = performance.now();
|
|
340
352
|
|
|
341
353
|
const errors = TESTED_URLS.filter(r => r.status !== 200);
|
|
@@ -345,6 +357,7 @@ module.exports = async function run(sitemapUrl, webUrl, slackChannel, skip, test
|
|
|
345
357
|
const errorText = createErrorResult(errors);
|
|
346
358
|
logErrors(errorText);
|
|
347
359
|
await sendSlackMessage(errorText, slackChannel);
|
|
360
|
+
await sendGoogleChatMessage(errors);
|
|
348
361
|
}
|
|
349
362
|
logStatistics(ok, Math.ceil(finishTime - startTime));
|
|
350
363
|
|