@uxf/scripts 11.61.2 → 11.61.4

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uxf/scripts",
3
- "version": "11.61.2",
3
+ "version": "11.61.4",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
package/src/GitLab.js CHANGED
@@ -53,6 +53,31 @@ async function loadCommits(from) {
53
53
  return commits.filter((commit) => commit.created_at !== from);
54
54
  }
55
55
 
56
+ async function findMigrationFiles(commits) {
57
+ console.log(`Hledám migrace v ${commits.length} commitech od posledního releasu ...`);
58
+
59
+ // Paralelní načtení diffů pro každý commit
60
+ const migrationFiles = new Set();
61
+ await Promise.all(commits.map(async (commit) => {
62
+ try {
63
+ const { data: diffs } = await axios.get(
64
+ `/projects/${env.CI_PROJECT_ID}/repository/commits/${commit.id}/diff`
65
+ );
66
+ diffs.forEach(({ new_path }) => {
67
+ if (/^api\/migrations\/Version.*\.php$/.test(new_path)) {
68
+ migrationFiles.add(new_path);
69
+ }
70
+ });
71
+ } catch (err) {
72
+ console.error(`Chyba při kontrole commitu ${commit.id}: ${err.message}`);
73
+ }
74
+ }));
75
+
76
+ const migrationList = Array.from(migrationFiles);
77
+ console.log(`Nalezeno ${migrationList.length} migračních souborů.`);
78
+ return migrationList;
79
+ }
80
+
56
81
  async function getLastTag() {
57
82
  const response = await axios.get(`/projects/${env.CI_PROJECT_ID}/repository/tags`, {
58
83
  params: {
@@ -115,4 +140,5 @@ module.exports = {
115
140
  getAllMergeRequests,
116
141
  getAllProjects,
117
142
  getSingleMergeRequestChanges,
118
- };
143
+ findMigrationFiles,
144
+ };
@@ -82,13 +82,42 @@ function generateReleaseCommitMessage(commit) {
82
82
  return `- ${title} ${suffix}`;
83
83
  }
84
84
 
85
+ function generateMigrationWarning(migrationFiles = []) {
86
+ if (migrationFiles.length === 0) return "";
87
+
88
+ const migrations = migrationFiles.map(f => `- ${f}`).join('\n');
89
+ return (
90
+ `⚠️ VAROVÁNÍ: Součástí této verze jsou i změny v databázi.\n\n` +
91
+ `Seznam migrací:\n${migrations}\n`
92
+ );
93
+ }
94
+
85
95
  module.exports = async (dryRun, channel, messageTitle) => {
86
96
  const lastTag = await GitLab.getLastTag();
87
97
  const commits = await GitLab.loadCommits(lastTag ? lastTag.commit.committed_date : null);
88
-
89
- await Slack.chatPostMessage(channel, { text: generateSlackMessage(commits, messageTitle) }, dryRun);
90
-
91
- await GoogleChat.chatPostMessage(generateGoogleMessage(commits, messageTitle), { dryRun });
92
-
93
- await GitLab.createRelease(commits.map(generateReleaseCommitMessage).join("\n"), dryRun);
94
- };
98
+ const migrationFiles = await GitLab.findMigrationFiles(commits);
99
+
100
+ const migrationWarning = generateMigrationWarning(migrationFiles);
101
+
102
+ // Add migration warning to Slack message if needed
103
+ const slackMessage = generateSlackMessage(commits, messageTitle);
104
+ if (migrationWarning) {
105
+ slackMessage.text = `${slackMessage.text}\n\n${migrationWarning}`;
106
+ }
107
+
108
+ await Slack.chatPostMessage(channel, { text: slackMessage.text }, dryRun);
109
+
110
+ // Add migration warning to Google Chat message if needed
111
+ const googleMessage = generateGoogleMessage(commits, messageTitle);
112
+ if (migrationWarning) {
113
+ googleMessage.text = `${googleMessage.text}\n\n${migrationWarning}`;
114
+ }
115
+
116
+ await GoogleChat.chatPostMessage(googleMessage, { dryRun });
117
+
118
+ // Add migration warning to release notes if needed
119
+ const releaseNotes = commits.map(generateReleaseCommitMessage).join("\n");
120
+ const fullReleaseNotes = migrationWarning + releaseNotes;
121
+
122
+ await GitLab.createRelease(fullReleaseNotes, dryRun);
123
+ };
@@ -251,7 +251,15 @@ async function testUrl(url, webUrl, parentUrl = undefined) {
251
251
  const indexInChecked = TESTED_URLS.findIndex((result) => result.url === url);
252
252
  if (indexInChecked === -1) {
253
253
  const result = await fetchUrl(url, webUrl, parentUrl);
254
- TESTED_URLS.push(result);
254
+ TESTED_URLS.push({
255
+ isImg: result.isImg,
256
+ message: result.message,
257
+ parentUrl: result.parentUrl,
258
+ skipped: result.skipped,
259
+ status: result.status,
260
+ ttl: result.ttl,
261
+ url: result.url,
262
+ });
255
263
  return result;
256
264
  }
257
265
  return TESTED_URLS[indexInChecked];