@uxf/scripts 11.123.0 → 11.125.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/README.md +33 -33
- package/package.json +4 -5
- package/src/cli-args.js +43 -0
- package/src/cli-args.test.js +61 -0
- package/src/{GitLab.js → gitlab.js} +43 -21
- package/src/gitlab.test.js +207 -0
- package/src/{GoogleChat.js → google-chat.js} +10 -12
- package/src/google-chat.test.js +95 -0
- package/src/http.js +86 -0
- package/src/http.test.js +155 -0
- package/src/sitemap.js +80 -0
- package/src/sitemap.test.js +64 -0
- package/src/{Slack.js → slack.js} +9 -8
- package/src/slack.test.js +81 -0
- package/src/uxf-i18n-namespaces-gen/dependency-tree.js +102 -0
- package/src/uxf-i18n-namespaces-gen/dependency-tree.test.js +46 -0
- package/src/uxf-i18n-namespaces-gen/index.js +62 -44
- package/src/uxf-i18n-namespaces-gen/index.test.js +32 -1
- package/src/uxf-merge-requests-notifier/cli.js +9 -12
- package/src/uxf-merge-requests-notifier/index.js +44 -10
- package/src/uxf-merge-requests-notifier/index.test.js +103 -0
- package/src/uxf-push-notifier/cli.js +14 -13
- package/src/uxf-push-notifier/index.js +32 -23
- package/src/uxf-release/index.js +3 -3
- package/src/uxf-sitemap-check/index.js +6 -2
- package/src/uxf-sitemap-check/index.test.js +2 -2
- package/src/uxf-sitemap-meta-export/index.js +3 -3
- package/src/Logger.js +0 -12
- package/src/Sitemap.js +0 -60
|
@@ -1,30 +1,36 @@
|
|
|
1
|
-
const { create } = require("axios");
|
|
2
1
|
const process = require("process");
|
|
2
|
+
const { request } = require("../http");
|
|
3
3
|
|
|
4
4
|
const { GITLAB_TOKEN, CI_SERVER_URL, CI_COMMIT_SHA, CI_COMMIT_BEFORE_SHA, CI_PROJECT_ID, CI_COMMIT_REF_NAME } =
|
|
5
5
|
process.env;
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
/**
|
|
8
|
+
* @param {string} url
|
|
9
|
+
* @param {{params?: Record<string, any>}} options
|
|
10
|
+
*/
|
|
11
|
+
function gitlabRequest(url, options = {}) {
|
|
12
|
+
return request(url, {
|
|
13
|
+
...options,
|
|
14
|
+
baseUrl: `${CI_SERVER_URL}/api/v4`,
|
|
15
|
+
headers: { Authorization: `Bearer ${GITLAB_TOKEN}` },
|
|
16
|
+
});
|
|
17
|
+
}
|
|
15
18
|
|
|
16
19
|
function findCurrentlyMergedMergeRequest() {
|
|
17
|
-
return
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
return gitlabRequest(`/projects/${CI_PROJECT_ID}/merge_requests`, {
|
|
21
|
+
params: {
|
|
22
|
+
state: "merged",
|
|
23
|
+
target_branch: CI_COMMIT_REF_NAME,
|
|
24
|
+
order_by: "updated_at",
|
|
25
|
+
sort: "desc",
|
|
26
|
+
},
|
|
27
|
+
}).then((response) => (response.data?.[0]?.sha === CI_COMMIT_SHA ? response.data[0] : null));
|
|
22
28
|
}
|
|
23
29
|
|
|
24
30
|
function getApprovalUserNames(iid) {
|
|
25
|
-
return
|
|
26
|
-
.
|
|
27
|
-
|
|
31
|
+
return gitlabRequest(`/projects/${CI_PROJECT_ID}/merge_requests/${iid}/approvals`).then((response) =>
|
|
32
|
+
response.data.approved_by.map((item) => item.user.name),
|
|
33
|
+
);
|
|
28
34
|
}
|
|
29
35
|
|
|
30
36
|
function getPushedCommits() {
|
|
@@ -35,9 +41,9 @@ function getPushedCommits() {
|
|
|
35
41
|
return Promise.resolve([]);
|
|
36
42
|
}
|
|
37
43
|
|
|
38
|
-
return
|
|
39
|
-
|
|
40
|
-
|
|
44
|
+
return gitlabRequest(`/projects/${CI_PROJECT_ID}/repository/compare`, {
|
|
45
|
+
params: { from: CI_COMMIT_BEFORE_SHA, to: CI_COMMIT_SHA },
|
|
46
|
+
}).then((response) => response.data.commits);
|
|
41
47
|
}
|
|
42
48
|
|
|
43
49
|
module.exports = async function (googleChatWebhookUrl) {
|
|
@@ -54,15 +60,18 @@ Autor: ${mr.author.name}
|
|
|
54
60
|
Schválil: ${isApproved ? approvalUserNames.join(", ") : "*bez schválení*"}
|
|
55
61
|
Zamergoval: ${mr.merged_by.name}`;
|
|
56
62
|
|
|
57
|
-
await
|
|
63
|
+
await request(googleChatWebhookUrl, { method: "POST", body: { text } });
|
|
58
64
|
} else {
|
|
59
65
|
const commits = (await getPushedCommits()).map(
|
|
60
66
|
(commit) => `${commit.author_name} - <${commit.web_url}|${commit.title}>`,
|
|
61
67
|
);
|
|
62
68
|
|
|
63
|
-
await
|
|
64
|
-
|
|
69
|
+
await request(googleChatWebhookUrl, {
|
|
70
|
+
method: "POST",
|
|
71
|
+
body: {
|
|
72
|
+
text: `❗ Bylo pushnuto do developu.
|
|
65
73
|
${commits.join("\n")}`,
|
|
74
|
+
},
|
|
66
75
|
});
|
|
67
76
|
}
|
|
68
77
|
};
|
package/src/uxf-release/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const GitLab = require("../
|
|
2
|
-
const Slack = require("../
|
|
3
|
-
const GoogleChat = require("../
|
|
1
|
+
const GitLab = require("../gitlab");
|
|
2
|
+
const Slack = require("../slack");
|
|
3
|
+
const GoogleChat = require("../google-chat");
|
|
4
4
|
const parseCommitMessage = require("./utils/parse-commit-message");
|
|
5
5
|
|
|
6
6
|
function generateSlackCommitMessage(commit) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const Sitemap = require("../
|
|
1
|
+
const Sitemap = require("../sitemap");
|
|
2
2
|
const { performance } = require("perf_hooks");
|
|
3
3
|
const { stdout } = require("process");
|
|
4
4
|
const cheerio = require("cheerio");
|
|
5
|
-
const GoogleChat = require("../
|
|
5
|
+
const GoogleChat = require("../google-chat");
|
|
6
6
|
const robotsTxtParser = require("robots-txt-parser");
|
|
7
7
|
|
|
8
8
|
const got = (url, init) => import("got").then((mod) => mod.default(url, init));
|
|
@@ -78,6 +78,10 @@ function fetcher(url, options) {
|
|
|
78
78
|
return got(url, {
|
|
79
79
|
throwHttpErrors: false,
|
|
80
80
|
decompress: false,
|
|
81
|
+
// BEZPEČNOST: vypnuté ověřování TLS certifikátu — platí na VŠECHNY procházené
|
|
82
|
+
// URL, tedy i externí a produkční, ne jen na staging se self-signed certem.
|
|
83
|
+
// Crawler tím nepozná podvržený certifikát (MITM). Čistší by bylo podmínit to
|
|
84
|
+
// env proměnnou nebo přidat CA do trust storu. Stejná poznámka je v sitemap.js.
|
|
81
85
|
https: {
|
|
82
86
|
rejectUnauthorized: false,
|
|
83
87
|
},
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* @jest-environment node
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
jest.mock("../
|
|
6
|
-
jest.mock("../
|
|
5
|
+
jest.mock("../sitemap");
|
|
6
|
+
jest.mock("../google-chat");
|
|
7
7
|
jest.mock("cheerio");
|
|
8
8
|
jest.mock("got");
|
|
9
9
|
jest.mock("robots-txt-parser", () => () => ({ useRobotsFor: jest.fn(), canCrawl: jest.fn() }));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const Sitemap = require("../
|
|
1
|
+
const Sitemap = require("../sitemap");
|
|
2
2
|
const cheerio = require("cheerio");
|
|
3
3
|
const fs = require("fs");
|
|
4
4
|
|
|
@@ -17,9 +17,9 @@ module.exports = async function run() {
|
|
|
17
17
|
for (const url of urls) {
|
|
18
18
|
process.stdout.write(`${++i} / ${urls.length} ${url} \n`);
|
|
19
19
|
try {
|
|
20
|
-
const
|
|
20
|
+
const body = await Sitemap.fetchPage(url);
|
|
21
21
|
|
|
22
|
-
const $ = cheerio.load(
|
|
22
|
+
const $ = cheerio.load(body, { xmlMode: true, decodeEntities: false });
|
|
23
23
|
|
|
24
24
|
let title = "";
|
|
25
25
|
let ogTitle = "";
|
package/src/Logger.js
DELETED
package/src/Sitemap.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
const https = require("https");
|
|
2
|
-
const { create } = require("axios");
|
|
3
|
-
const cheerio = require("cheerio");
|
|
4
|
-
|
|
5
|
-
const { HTTP_USERNAME, HTTP_PASSWORD } = process.env;
|
|
6
|
-
|
|
7
|
-
async function getSitemap(xml) {
|
|
8
|
-
const { data } = await axios.get(xml);
|
|
9
|
-
const $ = cheerio.load(data, { xmlMode: true });
|
|
10
|
-
|
|
11
|
-
const urls = [];
|
|
12
|
-
|
|
13
|
-
$("loc").each(function () {
|
|
14
|
-
urls.push($(this).text());
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
return urls;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const agent = new https.Agent({
|
|
21
|
-
rejectUnauthorized: false,
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
const axios = create({
|
|
25
|
-
auth:
|
|
26
|
-
HTTP_PASSWORD && HTTP_USERNAME
|
|
27
|
-
? {
|
|
28
|
-
username: HTTP_USERNAME,
|
|
29
|
-
password: HTTP_PASSWORD,
|
|
30
|
-
}
|
|
31
|
-
: undefined,
|
|
32
|
-
withCredentials: true,
|
|
33
|
-
maxRedirects: 0,
|
|
34
|
-
timeout: 20000,
|
|
35
|
-
httpsAgent: agent,
|
|
36
|
-
headers: {
|
|
37
|
-
"User-Agent":
|
|
38
|
-
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36",
|
|
39
|
-
Accept: "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
|
|
40
|
-
"Accept-Encoding": "gzip, deflate, br",
|
|
41
|
-
"Accept-Language": "en-US,en;q=0.9,cs-CZ;q=0.8,cs;q=0.7,de;q=0.6",
|
|
42
|
-
"Cache-Control": "no-cache",
|
|
43
|
-
Connection: "keep-alive",
|
|
44
|
-
Pragma: "no-cache",
|
|
45
|
-
"Sec-Ch-Ua": '"Google Chrome";v="111", "Not(A:Brand";v="8", "Chromium";v="111"',
|
|
46
|
-
"Sec-Ch-Ua-Arch": '"x86"',
|
|
47
|
-
"Sec-Ch-Ua-Mobile": "?0",
|
|
48
|
-
"Sec-Ch-Ua-Platform": '"Windows"',
|
|
49
|
-
"Sec-Fetch-Dest": "document",
|
|
50
|
-
"Sec-Fetch-Mode": "navigate",
|
|
51
|
-
"Sec-Fetch-Site": "cross-site",
|
|
52
|
-
"Sec-Fetch-User": "?1",
|
|
53
|
-
"Sec-Fetch-User-Agent": "?1",
|
|
54
|
-
},
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
module.exports = {
|
|
58
|
-
getSitemap,
|
|
59
|
-
axios,
|
|
60
|
-
};
|