@uxf/scripts 11.78.0 → 11.80.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uxf/scripts",
3
- "version": "11.78.0",
3
+ "version": "11.80.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
package/src/GitLab.js CHANGED
@@ -33,14 +33,14 @@ async function getAll(url, config) {
33
33
  return data;
34
34
  }
35
35
 
36
- async function loadCommits(from) {
36
+ async function loadCommits(from, ref_name = "master") {
37
37
  const commits = [];
38
38
 
39
39
  let nextPage = "1";
40
40
  do {
41
41
  const response = await axios.get(`/projects/${env.CI_PROJECT_ID}/repository/commits`, {
42
42
  params: {
43
- ref_name: "master",
43
+ ref_name,
44
44
  since: from ? dayjs(from).toISOString() : undefined,
45
45
  per_page: "100",
46
46
  page: nextPage,
@@ -80,20 +80,30 @@ async function findMigrationFiles(commits) {
80
80
  return migrationList;
81
81
  }
82
82
 
83
- async function getLastTag(tagPrefix = "release-") {
84
- const response = await axios.get(`/projects/${env.CI_PROJECT_ID}/repository/tags`, {
83
+ async function getLastTag(tagPrefix = "release-", ref_name = "master") {
84
+ const { data: commits } = await axios.get(`/projects/${env.CI_PROJECT_ID}/repository/commits`, {
85
+ params: {
86
+ ref_name,
87
+ per_page: "100",
88
+ },
89
+ });
90
+
91
+ const commitIds = commits.map((commit) => commit.id);
92
+
93
+ const { data: tags } = await axios.get(`/projects/${env.CI_PROJECT_ID}/repository/tags`, {
85
94
  params: { search: `^${tagPrefix}` },
95
+ per_page: "100",
86
96
  });
87
97
 
88
- const tags = response.data;
98
+ const tag = tags.find((tag) => commitIds.includes(tag.commit.id)) ?? null;
89
99
 
90
- if (tags.length === 0) {
100
+ if (!tag) {
91
101
  console.log("- release tag not found");
92
102
  return null;
93
103
  }
94
104
 
95
- console.log(`- last tag: ${tags[0].name}`);
96
- return tags[0];
105
+ console.log(`- last tag: ${tag.name}`);
106
+ return tag;
97
107
  }
98
108
 
99
109
  async function createRelease(description, tagPrefix = "release-", dryRun = false) {
@@ -93,8 +93,8 @@ function generateMigrationWarning(migrationFiles = []) {
93
93
  * @param config {{dryRun?: boolean, channel?: string, messageTitle?: string, googleChatWebhook?: string, tagPrefix?: string}}
94
94
  */
95
95
  module.exports = async function (config) {
96
- const lastTag = await GitLab.getLastTag(config.tagPrefix);
97
- const commits = await GitLab.loadCommits(lastTag ? lastTag.commit.committed_date : null);
96
+ const lastTag = await GitLab.getLastTag(config.tagPrefix, "master");
97
+ const commits = await GitLab.loadCommits(lastTag ? lastTag.commit.committed_date : null, "master");
98
98
  const migrationFiles = await GitLab.findMigrationFiles(commits);
99
99
 
100
100
  const migrationWarning = generateMigrationWarning(migrationFiles);