@tahminator/pipeline 1.0.37 โ†’ 1.0.39

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.
@@ -37,4 +37,5 @@ export declare class GitHubClient {
37
37
  createTag(...args: Parameters<GitHubTagManager["createTag"]>): Promise<void>;
38
38
  outputToGithubOutput(...args: Parameters<GitHubOutputManager["outputToGithubOutput"]>): Promise<void>;
39
39
  updateK8sTagWithPR(...args: Parameters<GitHubPRManager["updateK8sTagWithPR"]>): Promise<void>;
40
+ sendPrMessage(...args: Parameters<GitHubPRManager["sendPrMessage"]>): Promise<void>;
40
41
  }
package/dist/gh/client.js CHANGED
@@ -62,4 +62,7 @@ export class GitHubClient {
62
62
  updateK8sTagWithPR(...args) {
63
63
  return this.prManager.updateK8sTagWithPR(...args);
64
64
  }
65
+ sendPrMessage(...args) {
66
+ return this.prManager.sendPrMessage(...args);
67
+ }
65
68
  }
@@ -34,4 +34,10 @@ export declare class GitHubPRManager {
34
34
  originRepo: [OwnerString, RepoString];
35
35
  manifestRepo: [OwnerString, RepoString];
36
36
  }): Promise<void>;
37
+ sendPrMessage({ prId, owner, repository, message, }: {
38
+ prId: number;
39
+ owner: string;
40
+ repository: string;
41
+ message: string;
42
+ }): Promise<void>;
37
43
  }
@@ -98,4 +98,12 @@ export class GitHubPRManager {
98
98
  merge_method: "squash",
99
99
  });
100
100
  }
101
+ async sendPrMessage({ prId, owner, repository, message, }) {
102
+ await this.client.rest.issues.createComment({
103
+ issue_number: prId,
104
+ owner,
105
+ repo: repository,
106
+ body: message,
107
+ });
108
+ }
101
109
  }
@@ -1,9 +1,14 @@
1
- import type { PreviewResult, UpResult } from "@pulumi/pulumi/automation";
1
+ import type { OpMap, OpType, PreviewResult, UpResult } from "@pulumi/pulumi/automation";
2
2
  import { type PulumiClientCreateArgs } from "./types";
3
3
  export declare class PulumiClient {
4
4
  private readonly strategy;
5
+ static opTypeMetadata: Record<OpType, {
6
+ emoji: string;
7
+ label: string;
8
+ }>;
5
9
  private constructor();
6
10
  static create(args: PulumiClientCreateArgs): Promise<PulumiClient>;
7
11
  up(): Promise<UpResult>;
8
12
  preview(): Promise<PreviewResult>;
13
+ static parseChangeSumaryToPrettyTable(changeSummary: OpMap): string;
9
14
  }
@@ -2,6 +2,26 @@ import { AzurePulumiClientStrategy, } from "./strategy";
2
2
  import { PulumiClientStrategy } from "./types";
3
3
  export class PulumiClient {
4
4
  strategy;
5
+ static opTypeMetadata = {
6
+ create: { emoji: "๐ŸŸข", label: "Create" },
7
+ update: { emoji: "๐ŸŸก", label: "Update" },
8
+ replace: { emoji: "๐Ÿ”ต", label: "Replace" },
9
+ delete: { emoji: "๐Ÿ”ด", label: "Delete" },
10
+ same: { emoji: "โšช", label: "Unchanged" },
11
+ refresh: { emoji: "๐Ÿ”„", label: "Refresh" },
12
+ import: { emoji: "๐Ÿ“ฅ", label: "Import" },
13
+ read: { emoji: "๐Ÿ”", label: "Read" },
14
+ discard: { emoji: "๐Ÿ’จ", label: "Discard" },
15
+ "create-replacement": { emoji: "โœณ๏ธ", label: "Create Replacement" },
16
+ "delete-replaced": { emoji: "๐Ÿ—‘๏ธ", label: "Delete Replaced" },
17
+ "read-replacement": { emoji: "๐Ÿ“–", label: "Read Replacement" },
18
+ "import-replacement": { emoji: "๐Ÿ“ฅ", label: "Import Replacement" },
19
+ "discard-replaced": { emoji: "๐Ÿ’จ", label: "Discard Replaced" },
20
+ "remove-pending-replace": {
21
+ emoji: "๐Ÿงน",
22
+ label: "Remove Pending Replace",
23
+ },
24
+ };
5
25
  constructor(strategy) {
6
26
  this.strategy = strategy;
7
27
  }
@@ -17,4 +37,32 @@ export class PulumiClient {
17
37
  async preview() {
18
38
  return this.strategy.preview();
19
39
  }
40
+ static parseChangeSumaryToPrettyTable(changeSummary) {
41
+ const entries = Object.entries(changeSummary).filter(([_, count]) => count > 0);
42
+ if (entries.length === 0) {
43
+ return "โœ… **No infrastructure changes detected.** Everything is in sync.";
44
+ }
45
+ // prioritize important ops
46
+ (() => {
47
+ const priority = [
48
+ "delete",
49
+ "replace",
50
+ "delete-replaced",
51
+ "create",
52
+ "update",
53
+ ];
54
+ entries.sort((a, b) => {
55
+ const indexA = priority.indexOf(a[0]);
56
+ const indexB = priority.indexOf(b[0]);
57
+ return (indexA === -1 ? 99 : indexA) - (indexB === -1 ? 99 : indexB);
58
+ });
59
+ })();
60
+ let table = "| | Operation | Count |\n";
61
+ table += "| :--- | :--- | :--- |\n";
62
+ for (const [op, count] of entries) {
63
+ const meta = this.opTypeMetadata[op];
64
+ table += `| ${meta.emoji} | **${meta.label}** | \`${count}\` |\n`;
65
+ }
66
+ return table;
67
+ }
20
68
  }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "type": "module",
4
4
  "author": "Tahmid Ahmed",
5
5
  "description": "A collection of Bun shell scripts that can be re-used in various CICD pipelines.",
6
- "version": "1.0.37",
6
+ "version": "1.0.39",
7
7
  "repository": {
8
8
  "url": "git+https://github.com/tahminator/pipeline.git"
9
9
  },