@uxf/scripts 11.76.0 → 11.77.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/GitLab.js +4 -6
- package/src/uxf-release/cli.js +22 -3
- package/src/uxf-release/index.js +10 -7
package/package.json
CHANGED
package/src/GitLab.js
CHANGED
|
@@ -80,11 +80,9 @@ async function findMigrationFiles(commits) {
|
|
|
80
80
|
return migrationList;
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
async function getLastTag() {
|
|
83
|
+
async function getLastTag(tagPrefix = "release-") {
|
|
84
84
|
const response = await axios.get(`/projects/${env.CI_PROJECT_ID}/repository/tags`, {
|
|
85
|
-
params: {
|
|
86
|
-
search: "^release-",
|
|
87
|
-
},
|
|
85
|
+
params: { search: `^${tagPrefix}` },
|
|
88
86
|
});
|
|
89
87
|
|
|
90
88
|
const tags = response.data;
|
|
@@ -98,8 +96,8 @@ async function getLastTag() {
|
|
|
98
96
|
return tags[0];
|
|
99
97
|
}
|
|
100
98
|
|
|
101
|
-
async function createRelease(description, dryRun = false) {
|
|
102
|
-
const tag =
|
|
99
|
+
async function createRelease(description, tagPrefix = "release-", dryRun = false) {
|
|
100
|
+
const tag = tagPrefix + dayjs().format("YYYY-MM-DD-HH-mm");
|
|
103
101
|
|
|
104
102
|
if (dryRun) {
|
|
105
103
|
console.log(`\n🎉🎉🎉 Release "${tag}" published (skipped in dry run)\n\n${description}`);
|
package/src/uxf-release/cli.js
CHANGED
|
@@ -3,7 +3,7 @@ const { argv, env } = require("process");
|
|
|
3
3
|
module.exports = async () => {
|
|
4
4
|
const cli = require("yargs")
|
|
5
5
|
.command("$0", "UXF release helper", (yargs) => {
|
|
6
|
-
yargs.demandCommand(0, 0).usage(`
|
|
6
|
+
yargs.demandCommand(0, 0).usage(`
|
|
7
7
|
Usage:
|
|
8
8
|
uxf-release [options]
|
|
9
9
|
|
|
@@ -14,6 +14,18 @@ Environment variables:
|
|
|
14
14
|
SLACK_TOKEN - optional
|
|
15
15
|
GOOGLE_WEBHOOK_URL - optional`);
|
|
16
16
|
})
|
|
17
|
+
.option("t", {
|
|
18
|
+
alias: "tag-prefix",
|
|
19
|
+
describe: "Git tag prefix",
|
|
20
|
+
type: "string",
|
|
21
|
+
group: "Options",
|
|
22
|
+
})
|
|
23
|
+
.option("g", {
|
|
24
|
+
alias: "google-chat-webhook",
|
|
25
|
+
describe: "Google chat webhook url",
|
|
26
|
+
type: "string",
|
|
27
|
+
group: "Options",
|
|
28
|
+
})
|
|
17
29
|
.option("m", {
|
|
18
30
|
alias: "message",
|
|
19
31
|
describe: "Message title",
|
|
@@ -43,10 +55,11 @@ Environment variables:
|
|
|
43
55
|
.exitProcess(false);
|
|
44
56
|
|
|
45
57
|
try {
|
|
46
|
-
const { help, p: projectId, d: dryRun, s, m, ...options } = cli.parse(argv.slice(2));
|
|
58
|
+
const { help, p: projectId, d: dryRun, s, m, g: googleChatWebhook, t, ...options } = cli.parse(argv.slice(2));
|
|
47
59
|
|
|
48
60
|
const slackChannel = s || options["slack-channel"];
|
|
49
61
|
const messageTitle = m || options["message"];
|
|
62
|
+
const tagPrefix = t || options["tag-prefix"];
|
|
50
63
|
|
|
51
64
|
if (Boolean(help)) {
|
|
52
65
|
return 0;
|
|
@@ -71,7 +84,13 @@ Environment variables:
|
|
|
71
84
|
return 1;
|
|
72
85
|
}
|
|
73
86
|
|
|
74
|
-
await require("./index")(
|
|
87
|
+
await require("./index")({
|
|
88
|
+
dryRun,
|
|
89
|
+
messageTitle,
|
|
90
|
+
tagPrefix,
|
|
91
|
+
channel: slackChannel,
|
|
92
|
+
googleChatWebhook: googleChatWebhook || eng.GOOGLE_WEBHOOK_URL,
|
|
93
|
+
});
|
|
75
94
|
} catch (e) {
|
|
76
95
|
console.error(e);
|
|
77
96
|
return 1;
|
package/src/uxf-release/index.js
CHANGED
|
@@ -89,32 +89,35 @@ function generateMigrationWarning(migrationFiles = []) {
|
|
|
89
89
|
return `⚠️ VAROVÁNÍ: Součástí této verze jsou i změny v databázi.\n\n` + `Seznam migrací:\n${migrations}\n`;
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
/**
|
|
93
|
+
* @param config {{dryRun?: boolean, channel?: string, messageTitle?: string, googleChatWebhook?: string, tagPrefix?: string}}
|
|
94
|
+
*/
|
|
95
|
+
module.exports = async function (config) {
|
|
96
|
+
const lastTag = await GitLab.getLastTag(config.tagPrefix);
|
|
94
97
|
const commits = await GitLab.loadCommits(lastTag ? lastTag.commit.committed_date : null);
|
|
95
98
|
const migrationFiles = await GitLab.findMigrationFiles(commits);
|
|
96
99
|
|
|
97
100
|
const migrationWarning = generateMigrationWarning(migrationFiles);
|
|
98
101
|
|
|
99
102
|
// Add migration warning to Slack message if needed
|
|
100
|
-
const slackMessage = generateSlackMessage(commits, messageTitle);
|
|
103
|
+
const slackMessage = generateSlackMessage(commits, config.messageTitle);
|
|
101
104
|
if (migrationWarning) {
|
|
102
105
|
slackMessage.text = `${slackMessage.text}\n\n${migrationWarning}`;
|
|
103
106
|
}
|
|
104
107
|
|
|
105
|
-
await Slack.chatPostMessage(channel, { text: slackMessage.text }, dryRun);
|
|
108
|
+
await Slack.chatPostMessage(config.channel, { text: slackMessage.text }, config.dryRun);
|
|
106
109
|
|
|
107
110
|
// Add migration warning to Google Chat message if needed
|
|
108
|
-
const googleMessage = generateGoogleMessage(commits, messageTitle);
|
|
111
|
+
const googleMessage = generateGoogleMessage(commits, config.messageTitle);
|
|
109
112
|
if (migrationWarning) {
|
|
110
113
|
googleMessage.text = `${googleMessage.text}\n\n${migrationWarning}`;
|
|
111
114
|
}
|
|
112
115
|
|
|
113
|
-
await GoogleChat.chatPostMessage(googleMessage, { dryRun });
|
|
116
|
+
await GoogleChat.chatPostMessage(googleMessage, { dryRun: config.dryRun, webhookUrl: config.googleChatWebhook });
|
|
114
117
|
|
|
115
118
|
// Add migration warning to release notes if needed
|
|
116
119
|
const releaseNotes = commits.map(generateReleaseCommitMessage).join("\n");
|
|
117
120
|
const fullReleaseNotes = migrationWarning + releaseNotes;
|
|
118
121
|
|
|
119
|
-
await GitLab.createRelease(fullReleaseNotes, dryRun);
|
|
122
|
+
await GitLab.createRelease(fullReleaseNotes, config.tagPrefix, config.dryRun);
|
|
120
123
|
};
|