deploy-vir 0.2.4 → 0.2.6

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.
@@ -9,12 +9,11 @@ function truncateString(value, truncateAt = 100) {
9
9
  }
10
10
  }
11
11
  function formatCommit(baseCommitUrl, commit) {
12
- const commitLine = `${commit.hash.slice(0, 7)} (${commit.author_name}) - ${truncateString(commit.message)}`;
13
12
  if (baseCommitUrl) {
14
- return `<${joinUrlPaths(baseCommitUrl, commit.hash)}|${commitLine}>`;
13
+ return `<${joinUrlPaths(baseCommitUrl, commit.hash)}|${commit.hash.slice(0, 7)}> (${commit.author_name}) ${truncateString(commit.message)}`;
15
14
  }
16
15
  else {
17
- return commitLine;
16
+ return `${commit.hash.slice(0, 7)} (${commit.author_name}) ${truncateString(commit.message)}`;
18
17
  }
19
18
  }
20
19
  /**
@@ -37,6 +36,17 @@ export async function sendNotificationToSlack({ branchConfig, deployResult: { de
37
36
  const afterText = repoConfig.commitBaseUrl
38
37
  ? `<${joinUrlPaths(repoConfig.commitBaseUrl, after.hash)}|${after.hash.slice(0, 7)}>`
39
38
  : before.hash;
39
+ const overwrittenCommitBlocks = overwrittenCommitBulletsText
40
+ ? [
41
+ {
42
+ type: 'section',
43
+ text: {
44
+ type: 'mrkdwn',
45
+ text: `\n*Overwritten Commits*\n${overwrittenCommitBulletsText}`,
46
+ },
47
+ },
48
+ ]
49
+ : [];
40
50
  const blocks = [
41
51
  {
42
52
  type: 'section',
@@ -47,10 +57,12 @@ export async function sendNotificationToSlack({ branchConfig, deployResult: { de
47
57
  },
48
58
  {
49
59
  type: 'context',
50
- text: {
51
- type: 'mrkdwn',
52
- text: `${beforeText} :arrow_right: ${afterText}`,
53
- },
60
+ elements: [
61
+ {
62
+ type: 'mrkdwn',
63
+ text: `${beforeText} :arrow_right: ${afterText}`,
64
+ },
65
+ ],
54
66
  },
55
67
  {
56
68
  type: 'section',
@@ -59,17 +71,7 @@ export async function sendNotificationToSlack({ branchConfig, deployResult: { de
59
71
  text: `\n*Deployed Commits*\n${deployedCommitBulletsText}`,
60
72
  },
61
73
  },
62
- ...(overwrittenCommitBulletsText
63
- ? [
64
- {
65
- type: 'section',
66
- text: {
67
- type: 'mrkdwn',
68
- text: `\n*Overwritten Commits*\n${overwrittenCommitBulletsText}`,
69
- },
70
- },
71
- ]
72
- : []),
74
+ ...overwrittenCommitBlocks,
73
75
  ];
74
76
  await sendSlackMessage(notification, {
75
77
  attachments: [],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deploy-vir",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
4
4
  "description": "Deploy a branch to another branch with notifications.",
5
5
  "keywords": [
6
6
  "deploy",
@@ -1,5 +1,5 @@
1
1
  import {addPrefix, capitalizeFirstLetter} from '@augment-vir/common';
2
- import {type ChatPostMessageArguments} from '@slack/web-api';
2
+ import {type ChatPostMessageArguments, type KnownBlock} from '@slack/web-api';
3
3
  import {joinUrlPaths} from 'url-vir';
4
4
  import {type SlackNotificationConfig} from '../config.js';
5
5
  import {type Commit} from '../git.js';
@@ -16,12 +16,10 @@ function truncateString(value: string, truncateAt = 100): string {
16
16
  }
17
17
 
18
18
  function formatCommit(baseCommitUrl: string | undefined, commit: Readonly<Commit>) {
19
- const commitLine = `${commit.hash.slice(0, 7)} (${commit.author_name}) - ${truncateString(commit.message)}`;
20
-
21
19
  if (baseCommitUrl) {
22
- return `<${joinUrlPaths(baseCommitUrl, commit.hash)}|${commitLine}>`;
20
+ return `<${joinUrlPaths(baseCommitUrl, commit.hash)}|${commit.hash.slice(0, 7)}> (${commit.author_name}) ${truncateString(commit.message)}`;
23
21
  } else {
24
- return commitLine;
22
+ return `${commit.hash.slice(0, 7)} (${commit.author_name}) ${truncateString(commit.message)}`;
25
23
  }
26
24
  }
27
25
 
@@ -61,7 +59,19 @@ export async function sendNotificationToSlack({
61
59
  ? `<${joinUrlPaths(repoConfig.commitBaseUrl, after.hash)}|${after.hash.slice(0, 7)}>`
62
60
  : before.hash;
63
61
 
64
- const blocks: any[] = [
62
+ const overwrittenCommitBlocks: KnownBlock[] = overwrittenCommitBulletsText
63
+ ? [
64
+ {
65
+ type: 'section',
66
+ text: {
67
+ type: 'mrkdwn',
68
+ text: `\n*Overwritten Commits*\n${overwrittenCommitBulletsText}`,
69
+ },
70
+ },
71
+ ]
72
+ : [];
73
+
74
+ const blocks: KnownBlock[] = [
65
75
  {
66
76
  type: 'section',
67
77
  text: {
@@ -71,10 +81,12 @@ export async function sendNotificationToSlack({
71
81
  },
72
82
  {
73
83
  type: 'context',
74
- text: {
75
- type: 'mrkdwn',
76
- text: `${beforeText} :arrow_right: ${afterText}`,
77
- },
84
+ elements: [
85
+ {
86
+ type: 'mrkdwn',
87
+ text: `${beforeText} :arrow_right: ${afterText}`,
88
+ },
89
+ ],
78
90
  },
79
91
  {
80
92
  type: 'section',
@@ -83,17 +95,7 @@ export async function sendNotificationToSlack({
83
95
  text: `\n*Deployed Commits*\n${deployedCommitBulletsText}`,
84
96
  },
85
97
  },
86
- ...(overwrittenCommitBulletsText
87
- ? [
88
- {
89
- type: 'section',
90
- text: {
91
- type: 'mrkdwn',
92
- text: `\n*Overwritten Commits*\n${overwrittenCommitBulletsText}`,
93
- },
94
- },
95
- ]
96
- : []),
98
+ ...overwrittenCommitBlocks,
97
99
  ];
98
100
 
99
101
  await sendSlackMessage(notification, {